Skip to content

Instantly share code, notes, and snippets.

@nicholasmckinney
Created May 8, 2017 00:27
Show Gist options
  • Save nicholasmckinney/30f507b50ebe1d6c9497232864344125 to your computer and use it in GitHub Desktop.
Save nicholasmckinney/30f507b50ebe1d6c9497232864344125 to your computer and use it in GitHub Desktop.
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