@@ -83,24 +83,34 @@ def is_app_epmp1000?
83
83
'method' => 'GET'
84
84
}
85
85
)
86
+
86
87
rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError
87
88
print_error ( "#{ rhost } :#{ rport } - HTTP Connection Failed..." )
88
89
return false
89
90
end
90
91
91
- if ( res && res . code == 200 && res . headers [ 'Server' ] && ( res . headers [ 'Server' ] . include? ( 'Cambium HTTP Server' ) || res . body . include? ( 'cambiumnetworks.com' ) ) )
92
+ good_response = (
93
+ res &&
94
+ res . code == 200 &&
95
+ res . headers [ 'Server' ] &&
96
+ ( res . headers [ 'Server' ] . include? ( 'Cambium HTTP Server' ) || res . body . include? ( 'cambiumnetworks.com' ) )
97
+ )
92
98
99
+ if good_response
93
100
get_epmp_ver = res . body . match ( /"sw_version">([^<]*)/ )
94
- epmp_ver = get_epmp_ver [ 1 ]
95
-
96
- print_good ( "#{ rhost } :#{ rport } - Running Cambium ePMP 1000 version #{ epmp_ver } ..." )
97
- return true
98
-
101
+ if !get_epmp_ver . nil?
102
+ epmp_ver = get_epmp_ver [ 1 ]
103
+ if !epmp_ver . nil?
104
+ print_good ( "#{ rhost } :#{ rport } - Running Cambium ePMP 1000 version #{ epmp_ver } ..." )
105
+ return true
106
+ else
107
+ print_good ( "#{ rhost } :#{ rport } - Running Cambium ePMP 1000..." )
108
+ return true
109
+ end
110
+ end
99
111
else
100
-
101
112
print_error ( "#{ rhost } :#{ rport } - Application does not appear to be Cambium ePMP 1000. Module will not continue." )
102
113
return false
103
-
104
114
end
105
115
end
106
116
@@ -109,15 +119,16 @@ def is_app_epmp1000?
109
119
#
110
120
111
121
def do_login ( user , pass )
112
- print_status ( "#{ rhost } :#{ rport } - Trying username:#{ user . inspect } with password:#{ pass . inspect } " )
113
-
122
+ print_status ( "#{ rhost } :#{ rport } - Attempting to login..." )
114
123
begin
115
-
116
124
res = send_request_cgi (
117
125
{
118
- 'uri' => '/cgi-bin/luci' ,
119
- 'method' => 'POST' ,
120
- 'headers' => { 'X-Requested-With' => 'XMLHttpRequest' , 'Accept' => 'application/json, text/javascript, */*; q=0.01' } ,
126
+ 'uri' => '/cgi-bin/luci' ,
127
+ 'method' => 'POST' ,
128
+ 'headers' => {
129
+ 'X-Requested-With' => 'XMLHttpRequest' ,
130
+ 'Accept' => 'application/json, text/javascript, */*; q=0.01'
131
+ } ,
121
132
'vars_post' =>
122
133
{
123
134
'username' => 'dashboard' ,
@@ -126,63 +137,70 @@ def do_login(user, pass)
126
137
}
127
138
)
128
139
129
- rescue ::Rex ::ConnectionRefused , ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionError , ::Errno ::EPIPE
130
-
131
- vprint_error ( "#{ rhost } :#{ rport } - HTTP Connection Failed..." )
132
- return :abort
133
-
134
- end
135
-
136
- if ( res && res . code == 200 && res . headers . include? ( 'Set-Cookie' ) && res . headers [ 'Set-Cookie' ] . include? ( 'sysauth' ) )
137
-
138
- sysauth_value = res . headers [ 'Set-Cookie' ] . match ( /((.*)[$ ])/ )
139
- cookie1 = "#{ sysauth_value } ; " + "globalParams=%7B%22dashboard%22%3A%7B%22refresh_rate%22%3A%225%22%7D%2C%22#{ user } %22%3A%7B%22refresh_rate%22%3A%225%22%7D%7D"
140
-
141
- res = send_request_cgi (
142
- {
143
- 'uri' => '/cgi-bin/luci' ,
144
- 'method' => 'POST' ,
145
- 'cookie' => cookie1 ,
146
- 'headers' => { 'X-Requested-With' => 'XMLHttpRequest' , 'Accept' => 'application/json, text/javascript, */*; q=0.01' , 'Connection' => 'close' } ,
147
- 'vars_post' =>
148
- {
149
- 'username' => user ,
150
- 'password' => pass
151
- }
152
- }
153
- )
154
-
155
- end
156
-
157
- if ( res && res . code == 200 && res . headers . include? ( 'Set-Cookie' ) && res . headers [ 'Set-Cookie' ] . include? ( 'stok=' ) )
158
-
159
- print_good ( "SUCCESSFUL LOGIN - #{ rhost } :#{ rport } - #{ user . inspect } :#{ pass . inspect } " )
160
-
161
- #
162
- # Extract ePMP version
163
- #
164
- res = send_request_cgi (
165
- {
166
- 'uri' => '/' ,
167
- 'method' => 'GET'
168
- }
140
+ good_response = (
141
+ res &&
142
+ res . code == 200 &&
143
+ res . headers . include? ( 'Set-Cookie' ) &&
144
+ res . headers [ 'Set-Cookie' ] . include? ( 'sysauth' )
169
145
)
170
146
171
- get_epmp_ver = res . body . match ( /"sw_version">([^<]*)/ )
172
- epmp_ver = get_epmp_ver [ 1 ]
173
-
174
- report_cred (
175
- ip : rhost ,
176
- port : rport ,
177
- service_name : "Cambium ePMP 1000 version #{ epmp_ver } " ,
178
- user : user ,
179
- password : pass
147
+ if good_response
148
+ sysauth_value = res . headers [ 'Set-Cookie' ] . match ( /((.*)[$ ])/ )
149
+
150
+ cookie1 = "#{ sysauth_value } ; " + "globalParams=%7B%22dashboard%22%3A%7B%22refresh_rate%22%3A%225%22%7D%2C%22#{ user } %22%3A%7B%22refresh_rate%22%3A%225%22%7D%7D"
151
+
152
+ res = send_request_cgi (
153
+ {
154
+ 'uri' => '/cgi-bin/luci' ,
155
+ 'method' => 'POST' ,
156
+ 'cookie' => cookie1 ,
157
+ 'headers' => {
158
+ 'X-Requested-With' => 'XMLHttpRequest' ,
159
+ 'Accept' => 'application/json, text/javascript, */*; q=0.01' ,
160
+ 'Connection' => 'close'
161
+ } ,
162
+ 'vars_post' =>
163
+ {
164
+ 'username' => user ,
165
+ 'password' => pass
166
+ }
167
+ }
168
+ )
169
+ end
170
+
171
+ good_response = (
172
+ res &&
173
+ res . code == 200 &&
174
+ res . headers . include? ( 'Set-Cookie' ) &&
175
+ res . headers [ 'Set-Cookie' ] . include? ( 'stok=' )
180
176
)
181
177
182
- else
183
-
184
- print_error ( "FAILED LOGIN - #{ rhost } :#{ rport } - #{ user . inspect } :#{ pass . inspect } " )
185
-
178
+ if good_response
179
+ print_good ( "SUCCESSFUL LOGIN - #{ rhost } :#{ rport } - #{ user . inspect } :#{ pass . inspect } " )
180
+
181
+ #
182
+ # Extract ePMP version
183
+ #
184
+ res = send_request_cgi (
185
+ {
186
+ 'uri' => '/' ,
187
+ 'method' => 'GET'
188
+ }
189
+ )
190
+
191
+ epmp_ver = res . body . match ( /"sw_version">([^<]*)/ ) [ 1 ]
192
+
193
+ report_cred (
194
+ ip : rhost ,
195
+ port : rport ,
196
+ service_name : "Cambium ePMP 1000 version #{ epmp_ver } " ,
197
+ user : user ,
198
+ password : pass
199
+ )
200
+
201
+ else
202
+ print_error ( "FAILED LOGIN - #{ rhost } :#{ rport } - #{ user . inspect } :#{ pass . inspect } " )
203
+ end
186
204
end
187
205
end
188
206
end
0 commit comments