Skip to content

Instantly share code, notes, and snippets.

@ppisarczyk
Forked from obscuresec/dirtywebserver.ps1
Created August 27, 2016 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ppisarczyk/12705506e458c7420e5707f050bf2acd to your computer and use it in GitHub Desktop.
Save ppisarczyk/12705506e458c7420e5707f050bf2acd to your computer and use it in GitHub Desktop.
Dirty PowerShell Webserver
$Hso = New-Object Net.HttpListener
$Hso.Prefixes.Add("http://+:8000/")
$Hso.Start()
While ($Hso.IsListening) {
$HC = $Hso.GetContext()
$HRes = $HC.Response
$HRes.Headers.Add("Content-Type","text/plain")
$Buf = [Text.Encoding]::UTF8.GetBytes((GC (Join-Path $Pwd ($HC.Request).RawUrl)))
$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