MailSniper icon indicating copy to clipboard operation
MailSniper copied to clipboard

Invoke-WebRequest

Open Fahad0x9d3 opened this issue 6 years ago • 1 comments

here is the command i typed : " Invoke-DomainHarvestOWA -ExchHostname "mail.****.com" -DomainList .\domainlist.txt -OutFile potential-domains.txt -Brute" i have tried without " -Brute " also the same error message

here is the error i got : " Invoke-WebRequest : The underlying connection was closed: A connection that was expected to be kept alive was closed by the server. At C:\Users\fm2\Desktop\MailSniper-master\MailSniper.ps1:2166 char:21

  • ... $owalogin = Invoke-WebRequest -Uri $OWAURL -Method POST -Body $POSTpa ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand"

Fahad0x9d3 avatar May 15 '18 07:05 Fahad0x9d3

Webrequets within the Get-BaseLineResponseTime are configured to validate certificates. All of the other functions ignore self signed certs, but not this function. Adding the following code ~ line 2619 fixed my issue:

add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
    public bool CheckValidationResult(
        ServicePoint srvPoint, X509Certificate certificate,
        WebRequest request, int certificateProblem) {
        return true;
    }
}
"@
$AllProtocols = [System.Net.SecurityProtocolType]'Ssl3,Tls,Tls11,Tls12'
[System.Net.ServicePointManager]::SecurityProtocol = $AllProtocols
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

i128 avatar Jun 27 '18 20:06 i128