Skip to content

Commit 2c0c732

Browse files
committed
Fix rapid7#4414 & rapid7#4415 - exitfunc and proper null-terminated string
This patch fixes the following for messagebox.rb Issue 1 (rapid7#4415) When exitfunc is none, the payload will not be able to generate due to an "invalid opcode" error. Issue 2: (rapid7#4414) After "user32.dll" is pushed onto the stack for the LoadLibrary call, the payload does not actually ensure bl is a null byte, it just assumes it is and uses it to modify the stack to get a null-terminated string. Fix rapid7#4414 Fix rapid7#4415
1 parent 723998e commit 2c0c732

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

modules/payloads/singles/windows/messagebox.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,19 @@ def generate
8686
call [ebp+8] ;ExitProcess/Thread(0)
8787
EOS
8888

89-
# if exit is set to seh, overrule
89+
# if exit is set to seh or none, overrule
9090
if datastore['EXITFUNC'].upcase.strip == "SEH"
9191
# routine to exit via exception
9292
doexit = <<EOS
9393
xor eax,eax
9494
call eax
9595
EOS
9696
getexitfunc = ''
97+
elsif datastore['EXITFUNC'].upcase.strip == "NONE"
98+
doexit = <<-EOS
99+
nop
100+
EOS
101+
getexitfunc = ''
97102
end
98103

99104
# Generate code to get ptr to Title
@@ -232,6 +237,7 @@ def generate
232237
push 0x41206c6c
233238
push 0x642e3233
234239
push 0x72657375 ;user32.dll
240+
xor bl,bl ;make sure we have a null byte
235241
mov [esp+0xA],bl ;null byte
236242
mov esi,esp ;put pointer to string on top of stack
237243
push esi

0 commit comments

Comments
 (0)