void m_Sniffer_TcpPacketReceived(TcpPacket packet) { string data = Encoding.ASCII.GetString(packet.Data); if (data.StartsWith("GET ")) { HttpSniffer.HttpPacket sn = new HttpSniffer.HttpPacket(); sn.ParseRequest(data); string exepath = Environment.CurrentDirectory; Main main = new Main(); StreamWriter nettxt = new StreamWriter(exepath + @"\net\httphistory" + nettxtnum + ".txt", true); nettxt.WriteLine(DateTime.Now.ToString("*****@*****.**") + " % " + sn.Host); nettxt.Close(); } else if (data.StartsWith("POST ")) { HttpSniffer.HttpPacket sn = new HttpSniffer.HttpPacket(); sn.ParseRequest(data); string exepath = Environment.CurrentDirectory; Main main = new Main(); StreamWriter nettxt = new StreamWriter(exepath + @"\net\httphistory" + nettxtnum + ".txt", true); nettxt.WriteLine(DateTime.Now.ToString("*****@*****.**") + " % " + sn.Host); nettxt.Close(); } }
void m_Sniffer_TcpPacketReceived(TcpPacket packet) { string data = Encoding.ASCII.GetString(packet.Data); if (data.StartsWith("GET ")) { HttpSniffer.HttpPacket sn = new HttpSniffer.HttpPacket(); sn.ParseRequest(data); this.AddList(sn.URL, "GET", sn.Cookie); // checkurl(sn.URL); this.SetText("GET:" + sn.Host + ",url:" + sn.URL + "cookie:" + sn.Cookie); } else if (data.StartsWith("POST ")) { HttpSniffer.HttpPacket sn = new HttpSniffer.HttpPacket(); sn.ParseRequest(data); this.AddList(sn.URL, "POST", sn.Cookie); //checkurl(sn.URL); this.SetText("POST:" + sn.Host + ",url:" + sn.URL + "cookie:" + sn.Cookie); } else if (data.StartsWith("HTTP/")) { HttpSniffer.HttpPacket sn = new HttpSniffer.HttpPacket(); sn.ParseRequest(data); this.AddList(sn.URL, "HTTP", sn.Cookie); this.SetText("请求:" + sn.Host + ",url:" + sn.URL + "cookie:" + sn.Cookie); } else { HttpSniffer.HttpPacket sn = new HttpSniffer.HttpPacket(); sn.ParseRequest(data); this.AddList(sn.ToString(), "其他", "..."); this.SetText("请求:" + sn.Host + ",url:" + sn.URL); } }