-
-
Save DanielRTeixeira/d07ed423affee222f775d4f732e952c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Start-PACFileHosting() | |
{ | |
# Example PAC File Hosting | |
# Pattern after http://obscuresecurity.blogspot.com/2014/05/dirty-powershell-webserver.html | |
# example: http://localhost:8083/i.pac | |
# Be Certain Line 19 matches your Interceptor Config | |
Start-Job -ScriptBlock { | |
$Hso = New-Object Net.HttpListener | |
$Hso.Prefixes.Add("http://+:8083/") | |
$Hso.Start() | |
While ($Hso.IsListening) { | |
$HC = $Hso.GetContext() | |
$HRes = $HC.Response | |
$HRes.Headers.Add("Content-Type","text/plain") | |
$Buf = [Text.Encoding]::UTF8.GetBytes('function FindProxyForURL(url, host){ | |
// Intercepted Domains | |
if (shExpMatch(url, "https://www.google.com/*")) | |
return "PROXY 127.0.0.1:8081"; | |
// DEFAULT RULE: All other traffic, use below proxies, in fail-over order. | |
return "DIRECT"; | |
}') | |
$HRes.ContentLength64 = $Buf.Length | |
$HRes.OutputStream.Write($Buf,0,$Buf.Length) | |
$HRes.Close() | |
} | |
$Hso.Stop() | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment