Skip to content

Commit da0a9f6

Browse files
committed
Resolved all msftidy vars_get warnings
1 parent dc7ec45 commit da0a9f6

23 files changed

+206
-113
lines changed

lib/rex/proto/http/client_request.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,16 @@ def to_s
112112

113113
opts['vars_get'].each_pair do |var,val|
114114
var = var.to_s
115-
val = val.to_s
116115

117116
qstr << '&' if qstr.length > 0
118117
qstr << (opts['encode_params'] ? set_encode_uri(var) : var)
119-
qstr << '='
120-
qstr << (opts['encode_params'] ? set_encode_uri(val) : val)
118+
# support get paraemter without value
119+
# Example: uri?parameter
120+
if val
121+
val = val.to_s
122+
qstr << '='
123+
qstr << (opts['encode_params'] ? set_encode_uri(val) : val)
124+
end
121125
end
122126

123127
if (opts['pad_post_params'])

modules/auxiliary/scanner/sap/sap_soap_bapi_user_create1.rb

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,21 @@ def run_host(ip)
7070
data << '</env:Envelope>'
7171
begin
7272
print_status("[SAP] #{ip}:#{rport} - Attempting to create user '#{datastore['BAPI_USER']}' with password '#{datastore['BAPI_PASSWORD']}'")
73+
7374
res = send_request_cgi({
74-
'uri' => '/sap/bc/soap/rfc?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
75+
'uri' => '/sap/bc/soap/rfc',
7576
'method' => 'POST',
7677
'data' => data,
77-
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
78+
'cookie' => "sap-usercontext=sap-language=EN&sap-client=#{datastore['CLIENT']}",
7879
'ctype' => 'text/xml; charset=UTF-8',
7980
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
80-
'headers' =>
81-
{
82-
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
83-
}
81+
'headers' => {
82+
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
83+
},
84+
'vars_get' => {
85+
'sap-client' => datastore['CLIENT'],
86+
'sap-language' => 'EN'
87+
}
8488
})
8589
if res and res.code == 200
8690
if res.body =~ /<h1>Logon failed<\/h1>/

modules/auxiliary/scanner/sap/sap_soap_rfc_brute_login.rb

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,19 @@ def bruteforce(username,password,client)
118118
data << '</env:Envelope>'
119119
begin
120120
res = send_request_cgi({
121-
'uri' => '/sap/bc/soap/rfc?sap-client=' + client + '&sap-language=EN',
121+
'uri' => '/sap/bc/soap/rfc',
122122
'method' => 'POST',
123123
'data' => data,
124-
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + client,
124+
'cookie' => "sap-usercontext=sap-language=EN&sap-client=#{client}",
125125
'ctype' => 'text/xml; charset=UTF-8',
126126
'authorization' => basic_auth(username, password),
127-
'headers' =>
128-
{
129-
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
130-
}
127+
'headers' => {
128+
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
129+
},
130+
'vars_get' => {
131+
'sap-client' => client,
132+
'sap-language' => 'EN'
133+
}
131134
})
132135
if res and res.code == 200
133136
report_auth_info(

modules/auxiliary/scanner/sap/sap_soap_rfc_dbmcli_sxpg_call_system_command_exec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,18 @@ def exec_command(ip,data)
9393
print_status("[SAP] #{ip}:#{rport} - sending SOAP SXPG_CALL_SYSTEM request")
9494
begin
9595
res = send_request_cgi({
96-
'uri' => '/sap/bc/soap/rfc?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
96+
'uri' => '/sap/bc/soap/rfc',
9797
'method' => 'POST',
9898
'data' => data,
99-
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
99+
'cookie' => "sap-usercontext=sap-language=EN&sap-client=#{datastore['CLIENT']}",
100100
'ctype' => 'text/xml; charset=UTF-8',
101101
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
102-
'headers' =>{
102+
'headers' => {
103103
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
104+
},
105+
'vars_get' => {
106+
'sap-client' => datastore['CLIENT'],
107+
'sap-language' => 'EN'
104108
}
105109
})
106110
if res and res.code != 500 and res.code != 200

modules/auxiliary/scanner/sap/sap_soap_rfc_dbmcli_sxpg_command_exec.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,18 @@ def exec_command(ip,data)
9494
print_status("[SAP] #{ip}:#{rport} - sending SOAP SXPG_COMMAND_EXECUTE request")
9595
begin
9696
res = send_request_cgi({
97-
'uri' => '/sap/bc/soap/rfc?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
97+
'uri' => '/sap/bc/soap/rfc',
9898
'method' => 'POST',
9999
'data' => data,
100-
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
100+
'cookie' => "sap-usercontext=sap-language=EN&sap-client=#{datastore['CLIENT']}",
101101
'ctype' => 'text/xml; charset=UTF-8',
102102
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
103-
'headers' =>{
103+
'headers' => {
104104
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
105+
},
106+
'vars_get' => {
107+
'sap-client' => datastore['CLIENT'],
108+
'sap-language' => 'EN'
105109
}
106110
})
107111
if res

modules/auxiliary/scanner/sap/sap_soap_rfc_ping.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,20 @@ def run_host(ip)
6262
print_status("[SAP] #{ip}:#{rport} - sending SOAP RFC_PING request")
6363
begin
6464
res = send_request_cgi({
65-
'uri' => '/sap/bc/soap/rfc?sap-client=' + client + '&sap-language=EN',
65+
'uri' => '/sap/bc/soap/rfc',
6666
'method' => 'POST',
67-
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + client,
67+
'cookie' => "sap-usercontext=sap-language=EN&sap-client=#{client}",
6868
'data' => data,
6969
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
7070
'ctype' => 'text/xml; charset=UTF-8',
71-
'headers' =>
72-
{
73-
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions'
74-
}
75-
})
71+
'headers' => {
72+
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions'
73+
},
74+
'vars_get' => {
75+
'sap-client' => client,
76+
'sap-language' => 'EN'
77+
}
78+
})
7679
if res and res.code != 500 and res.code != 200
7780
if res and res.body =~ /<h1>Logon failed<\/h1>/
7881
print_error("[SAP] #{ip}:#{rport} - login failed!")

modules/auxiliary/scanner/sap/sap_soap_rfc_read_table.rb

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,20 @@ def exec(ip,fields)
8383
print_status("[SAP] #{ip}:#{rport} - sending SOAP RFC_READ_TABLE request")
8484
begin
8585
res = send_request_cgi({
86-
'uri' => '/sap/bc/soap/rfc?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
86+
'uri' => '/sap/bc/soap/rfc',
8787
'method' => 'POST',
8888
'data' => data,
89-
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
89+
'cookie' => "sap-usercontext=sap-language=EN&sap-client=#{datastore['CLIENT']}",
9090
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
9191
'ctype' => 'text/xml; charset=UTF-8',
92-
'headers' =>{
92+
'headers' => {
9393
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
94-
#'Cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
95-
#'Authorization' => 'Basic ' + user_pass,
96-
#'Content-Type' =>
97-
}
98-
})
94+
},
95+
'vars_get' => {
96+
'sap-client' => datastore['CLIENT'],
97+
'sap-language' => 'EN'
98+
}
99+
})
99100
if res and res.code != 500 and res.code != 200
100101
# to do - implement error handlers for each status code, 404, 301, etc.
101102
if res.body =~ /<h1>Logon failed<\/h1>/

modules/auxiliary/scanner/sap/sap_soap_rfc_susr_rfc_user_interface.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,17 +70,20 @@ def run_host(ip)
7070
begin
7171
vprint_status("[SAP] #{ip}:#{rport} - Attempting to create user '#{datastore['ABAP_USER']}' with password '#{datastore['ABAP_PASSWORD']}'")
7272
res = send_request_cgi({
73-
'uri' => '/sap/bc/soap/rfc?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
73+
'uri' => '/sap/bc/soap/rfc',
7474
'method' => 'POST',
7575
'data' => data,
76-
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
76+
'cookie' => "sap-usercontext=sap-language=EN&sap-client=#{datastore['CLIENT']}",
7777
'ctype' => 'text/xml; charset=UTF-8',
7878
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
79-
'headers' =>
80-
{
81-
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions'
82-
}
83-
})
79+
'headers' => {
80+
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions'
81+
},
82+
'vars_get' => {
83+
'sap-client' => datastore['CLIENT'],
84+
'sap-language' => 'EN'
85+
}
86+
})
8487
if res and res.code == 200
8588
if res.body =~ /<h1>Logon failed<\/h1>/
8689
vprint_error("[SAP] #{ip}:#{rport} - Logon failed")

modules/auxiliary/scanner/sap/sap_soap_rfc_sxpg_call_system_exec.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,20 @@ def run_host(ip)
7373
print_status("[SAP] #{ip}:#{rport} - sending SOAP SXPG_COMMAND_EXECUTE request")
7474
begin
7575
res = send_request_cgi({
76-
'uri' => '/sap/bc/soap/rfc?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
76+
'uri' => '/sap/bc/soap/rfc',
7777
'method' => 'POST',
7878
'data' => data,
79-
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
79+
'cookie' => "sap-usercontext=sap-language=EN&sap-client=#{datastore['CLIENT']}",
8080
'ctype' => 'text/xml; charset=UTF-8',
8181
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
82-
'headers' =>{
82+
'headers' => {
8383
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
84-
}
85-
})
84+
},
85+
'vars_get' => {
86+
'sap-client' => datastore['CLIENT'],
87+
'sap-language' => 'EN'
88+
}
89+
})
8690
if res and res.code != 500 and res.code != 200
8791
# to do - implement error handlers for each status code, 404, 301, etc.
8892
print_error("[SAP] #{ip}:#{rport} - something went wrong!")

modules/auxiliary/scanner/sap/sap_soap_rfc_sxpg_command_exec.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,18 @@ def run_host(ip)
7373
print_status("[SAP] #{ip}:#{rport} - sending SOAP SXPG_COMMAND_EXECUTE request")
7474
begin
7575
res = send_request_cgi({
76-
'uri' => '/sap/bc/soap/rfc?sap-client=' + datastore['CLIENT'] + '&sap-language=EN',
76+
'uri' => '/sap/bc/soap/rfc',
7777
'method' => 'POST',
7878
'data' => data,
79-
'cookie' => 'sap-usercontext=sap-language=EN&sap-client=' + datastore['CLIENT'],
79+
'cookie' => "sap-usercontext=sap-language=EN&sap-client=#{datastore['CLIENT']}",
8080
'ctype' => 'text/xml; charset=UTF-8',
8181
'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),
8282
'headers' =>{
8383
'SOAPAction' => 'urn:sap-com:document:sap:rfc:functions',
84+
},
85+
'vars_get' => {
86+
'sap-client' => datastore['CLIENT'],
87+
'sap-language' => 'EN'
8488
}
8589
})
8690
if res and res.code != 500 and res.code != 200

0 commit comments

Comments
 (0)