Skip to content

Instantly share code, notes, and snippets.

@cmbaughman
Forked from obscuresec/dirtywebserver.ps1
Created June 25, 2019 00:47
Show Gist options
  • Save cmbaughman/9a0e4c2ab6c9fd0095d1bfcab761807e to your computer and use it in GitHub Desktop.
Save cmbaughman/9a0e4c2ab6c9fd0095d1bfcab761807e 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