Skip to content

Instantly share code, notes, and snippets.

@obscuresec
Created May 19, 2014 01:17
Show Gist options
  • Save obscuresec/146e23d34611e0179b65 to your computer and use it in GitHub Desktop.
Save obscuresec/146e23d34611e0179b65 to your computer and use it in GitHub Desktop.
Simple but dirty Powershell web proxy
#simple and dirty proxy
#usage: http://127.0.0.1:8000/?url=http://www.obscuresec.com
$Up = "http://+:8000/"
$Hso = New-Object Net.HttpListener
$Wco = New-Object Net.Webclient
#ignore self-signed/invalid ssl certs
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$True}
Foreach ($P in $Up) {$Hso.Prefixes.Add($P)}
$Hso.Start()
While ($Hso.IsListening) {
$HC = $Hso.GetContext()
$HReq = $HC.Request
$HRes = $HC.Response
$HRes.Headers.Add("Content-Type","text/html")
$ProxURL = $HReq.QueryString['URL']
If ($ProxURL) {$Content = $Wco.downloadString("$ProxURL")}
$Buf = [Text.Encoding]::UTF8.GetBytes($Content)
$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