File splunk_xslt_authenticated_rce.rb
has 331 lines of code (exceeds 250 allowed). Consider refactoring. Open
class MetasploitModule < Msf::Exploit::Remote
Rank = ExcellentRanking
include Msf::Exploit::Remote::HttpClient
prepend Msf::Exploit::Remote::AutoCheck
Method upload_malicious_file
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def upload_malicious_file(file_content, csrf_token, cookie_string)
unless csrf_token
print_error('CSRF token not found')
return nil
end
Method initialize
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
def initialize(info = {})
super(
update_info(
info,
'Name' => 'Splunk Authenticated XSLT Upload RCE',
Method exploit
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def exploit
cookie_string ||= authenticate
unless cookie_string
fail_with(Failure::NoAccess, 'Authentication failed')
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method upload_malicious_file
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def upload_malicious_file(file_content, csrf_token, cookie_string)
unless csrf_token
print_error('CSRF token not found')
return nil
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method authenticate
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
def authenticate
login_url = normalize_uri(target_uri.path, 'en-US', 'account', 'login')
res = send_request_cgi({
'method' => 'GET',
Method exploit
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def exploit
cookie_string ||= authenticate
unless cookie_string
fail_with(Failure::NoAccess, 'Authentication failed')
end
Method trigger_xslt_transform
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
def trigger_xslt_transform(jsid, text_value, cookie_string)
return nil unless jsid && text_value
exploit_endpoint = normalize_uri(target_uri.path, 'en-US', 'api', 'search', 'jobs', jsid, 'results')
exploit_endpoint << "?xsl=/opt/splunk/var/run/splunk/dispatch/#{text_value}/#{datastore['RANDOM_FILENAME']}.xsl"
Method trigger_payload
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
def trigger_payload(jsid, csrf_token, cookie_string)
return nil unless jsid && csrf_token
runshellscript_url = normalize_uri(target_uri.path, 'en-US', 'splunkd', '__raw', 'servicesNS', datastore['USERNAME'], 'search', 'search', 'jobs')
runshellscript_data = {
Method check
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def check
unless splunk?
return CheckCode::Unknown('Target does not appear to be a Splunk instance')
end
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method authenticate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def authenticate
login_url = normalize_uri(target_uri.path, 'en-US', 'account', 'login')
res = send_request_cgi({
'method' => 'GET',
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Avoid too many return
statements within this method. Open
return nil
Avoid too many return
statements within this method. Open
return text_value
Avoid too many return
statements within this method. Open
return nil
Method trigger_payload
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def trigger_payload(jsid, csrf_token, cookie_string)
return nil unless jsid && csrf_token
runshellscript_url = normalize_uri(target_uri.path, 'en-US', 'splunkd', '__raw', 'servicesNS', datastore['USERNAME'], 'search', 'search', 'jobs')
runshellscript_data = {
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Method trigger_xslt_transform
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def trigger_xslt_transform(jsid, text_value, cookie_string)
return nil unless jsid && text_value
exploit_endpoint = normalize_uri(target_uri.path, 'en-US', 'api', 'search', 'jobs', jsid, 'results')
exploit_endpoint << "?xsl=/opt/splunk/var/run/splunk/dispatch/#{text_value}/#{datastore['RANDOM_FILENAME']}.xsl"
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"