Check PID
parent
ad108900d5
commit
2cedcad810
|
@ -65,7 +65,7 @@ class Metasploit3 < Msf::Exploit::Local
|
||||||
# Figures out which PID to inject to
|
# Figures out which PID to inject to
|
||||||
def get_pid
|
def get_pid
|
||||||
pid = datastore['PID']
|
pid = datastore['PID']
|
||||||
if pid == 0 or datastore['NEWPROCESS']
|
if pid == 0 or datastore['NEWPROCESS'] or not has_pid?(pid)
|
||||||
print_status("Launching notepad.exe...")
|
print_status("Launching notepad.exe...")
|
||||||
pid = create_temp_proc
|
pid = create_temp_proc
|
||||||
end
|
end
|
||||||
|
@ -73,6 +73,29 @@ class Metasploit3 < Msf::Exploit::Local
|
||||||
return pid
|
return pid
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# Determines if a PID actually exists
|
||||||
|
def has_pid?(pid)
|
||||||
|
procs = []
|
||||||
|
begin
|
||||||
|
procs = client.sys.process.processes
|
||||||
|
rescue Rex::Post::Meterpreter::RequestError
|
||||||
|
print_error("Unable to enumerate processes")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
pids = []
|
||||||
|
|
||||||
|
procs.each do |p|
|
||||||
|
found_pid = p['pid']
|
||||||
|
return true if found_pid == pid
|
||||||
|
end
|
||||||
|
|
||||||
|
print_error("PID #{pid.to_s} does not actually exist.")
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
# Checks the Architeture of a Payload and PID are compatible
|
# Checks the Architeture of a Payload and PID are compatible
|
||||||
# Returns true if they are false if they are not
|
# Returns true if they are false if they are not
|
||||||
def arch_check(pid)
|
def arch_check(pid)
|
||||||
|
|
Loading…
Reference in New Issue