Skip to content

Instantly share code, notes, and snippets.

@Kaicastledine
Forked from Zagrophyte/MS15-034Tester.ps1
Created January 25, 2017 11:20
Show Gist options
  • Save Kaicastledine/e018fd0569d2352d128337f9161f024f to your computer and use it in GitHub Desktop.
Save Kaicastledine/e018fd0569d2352d128337f9161f024f to your computer and use it in GitHub Desktop.
Sends a CVE-2015-1635 / MS15-034 Request and checks for vulnerability
# Sends a CVE-2015-1635 / MS15-034 Request and checks for vulnerability
function TestMS15_034($hostname, $port)
{
if ($port -eq $null)
{
$port = 80
}
$tc = New-Object Net.Sockets.TcpClient
try
{
$tc.Connect($hostname, $port)
$ns = $tc.GetStream()
try
{
$sw = New-Object System.IO.StreamWriter($ns)
$sr = New-Object System.IO.StreamReader($ns)
$req = ""
$req += "GET / HTTP/1.0`r`n"
$req += "Host: test`r`n"
$req += "Range: bytes=0-18446744073709551615`r`n"
$req += "`r`n"
$sw.Write($req);
$sw.Flush();
$response = $sr.ReadToEnd()
if ($response.Contains("Requested Range Not Satisfiable"))
{
Write-Host ("{0}:{1} - VULNERABLE" -f $hostname,$port) -ForegroundColor "Red"
}
else
{
if ($response.Contains("The request has an invalid header name"))
{
Write-Host ("{0}:{1} - Patched" -f $hostname,$port) -ForegroundColor "Green"
}
else
{
Write-Host ("{0}:{1} - Indeterminate" -f $hostname,$port)
}
}
}
catch
{
Write-Host ("{0}:{1} - Indeterminate: {2}" -f $hostname,$port,$Error[0].Exception.Message) -ForegroundColor "Yellow"
}
finally
{
$ns.Dispose()
}
}
catch
{
Write-Host ("{0}:{1} - Indeterminate: {2}" -f $hostname,$port,$Error[0].Exception.Message) -ForegroundColor "Yellow"
}
finally
{
$tc.Close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment