Banner grabbing with C#
TcpClient client = new TcpClient("http://mywebsite.com", 80);
client.SendTimeout = 2000;
client.ReceiveTimeout = 2000;
NetworkStream ns = client.GetStream();
StreamWriter sw = new StreamWriter(ns);
sw.Write("HEAD / HTTP/1.1rn"
	   + "User-Agent: Test agent 1.0rn"
	   + "Host: www.example.orgrn"
	   + "Connection: Closernrn");
sw.Flush();
 
byte[] bytes = new byte[2048];
int bytesRead = ns.Read(bytes, 0, bytes.Length);
String response = Encoding.ASCII.GetString(bytes, 0, bytesRead);
Categories: C# Tags: , ,
%d bloggers like this: