using System; using System.Net; using System.Text; namespace NCSIResponder { class Program { private static string NCSI_RESPONSE = "Microsoft NCSI"; private static byte[] NCSI_RESPONSE_BYTE = Encoding.UTF8.GetBytes(NCSI_RESPONSE); static void Main(string[] args) { var listener = new HttpListener(); listener.Prefixes.Add("http://127.0.0.1/"); listener.Start(); while (true) { var context = listener.GetContext(); var request = context.Request; Console.WriteLine("[" + DateTime.Now + "] " + request.RemoteEndPoint.Address + " - " + request.Url); if (request.RawUrl == "/ncsi.txt") { context.Response.StatusCode = 200; context.Response.OutputStream.Write(NCSI_RESPONSE_BYTE, 0, NCSI_RESPONSE_BYTE.Length); context.Response.Close(); } else { context.Response.StatusCode = 404; context.Response.Close(); } } } } }