@@ -108,26 +108,27 @@ def exec_command(ip,data)
108
108
'Content-Type' => 'text/xml; charset=UTF-8'
109
109
}
110
110
} , 45 )
111
- if res and res . code != 500 and res . code != 200
112
- print_error ( "[SAP] #{ ip } :#{ rport } - something went wrong!" )
113
- return
114
- elsif res and res . body =~ /faultstring/
115
- error = res . body . scan ( %r{<faultstring>(.*?)</faultstring>} ) . flatten
116
- 0 . upto ( output . length -1 ) do |i |
117
- print_error ( "[SAP] #{ ip } :#{ rport } - error #{ error [ i ] } " )
111
+ if res
112
+ if res . code != 500 and res . code != 200
113
+ print_error ( "[SAP] #{ ip } :#{ rport } - something went wrong!" )
114
+ return
115
+ elsif res . body =~ /faultstring/
116
+ error = res . body . scan ( %r{<faultstring>(.*?)</faultstring>} ) . flatten
117
+ 0 . upto ( output . length -1 ) do |i |
118
+ print_error ( "[SAP] #{ ip } :#{ rport } - error #{ error [ i ] } " )
119
+ end
120
+ return
118
121
end
119
- return
120
- elsif res
121
122
print_status ( "[SAP] #{ ip } :#{ rport } - got response" )
122
123
output = res . body . scan ( %r{<MESSAGE>([^<]+)</MESSAGE>} ) . flatten
123
124
result = [ ]
124
125
0 . upto ( output . length -1 ) do |i |
125
126
if output [ i ] =~ /E[rR][rR]/ || output [ i ] =~ /---/ || output [ i ] =~ /for database \( /
126
- #nothing
127
+ #nothing
127
128
elsif output [ i ] =~ /unknown host/ || output [ i ] =~ /; \( see/ || output [ i ] =~ /returned with/
128
- #nothing
129
+ #nothing
129
130
elsif output [ i ] =~ /External program terminated with exit code/
130
- #nothing
131
+ #nothing
131
132
else
132
133
temp = output [ i ] . gsub ( ">" , ">" )
133
134
temp_ = temp . gsub ( """ , "\" " )
@@ -143,18 +144,17 @@ def exec_command(ip,data)
143
144
'Indent' => 1 ,
144
145
'Columns' => [ "Output" ]
145
146
)
146
- for i in 0 .. result . length /2 -1
147
+ 0 . upto ( result . length /2 -1 ) do | i |
147
148
saptbl << [ result [ i ] . chomp ]
148
149
end
149
150
print ( saptbl . to_s )
150
151
return
151
152
else
152
- print_error ( "[SAP] #{ ip } :#{ rport } - Unknown error" )
153
- return
153
+ print_error ( "[SAP] #{ ip } :#{ rport } - no response" )
154
154
end
155
155
rescue ::Rex ::ConnectionError
156
156
print_error ( "[SAP] #{ ip } :#{ rport } - Unable to connect" )
157
157
return
158
158
end
159
159
end
160
- end
160
+ end
0 commit comments