QQ蠕蟲是一種利用QQ等騰訊公司相關(guān)產(chǎn)品進(jìn)行傳播的一種特殊蠕蟲,該蠕蟲的基本原理是利用了QQ帳戶的快速登錄機(jī)制,只要當(dāng)前系統(tǒng)中有一個(gè)QQ帳戶成功登錄,就可以通過后臺接口實(shí)現(xiàn)該帳戶相關(guān)應(yīng)用的快速登錄而不需要再次輸入帳戶密碼。登錄后蠕蟲可以訪問QQ應(yīng)用的各種網(wǎng)絡(luò)接口,例如:通過接口實(shí)現(xiàn)加QQ好友、加入QQ群、發(fā)消息、發(fā)日志、發(fā)微博、上傳群共享文件等操作,且完全不需要用戶同意。借用這種技術(shù),QQ蠕蟲可以實(shí)現(xiàn)非??焖俚膫鞑?。這種蠕蟲誕生于QQ體系之上,其影響和傳播主要集中在國內(nèi)地區(qū),因此國外品牌的殺軟對這類蠕蟲識別和支持非常有限,國內(nèi)的殺軟品牌對該蠕蟲檢測也不是特別理想,從而導(dǎo)致了該QQ蠕蟲的傳播更加快速,影響范圍更廣。

基于以上信息,利用WinPcap技術(shù)抓取網(wǎng)絡(luò)數(shù)據(jù)包,對HTTP POST包進(jìn)行分析,過濾出對域名qq.com訪問的數(shù)據(jù)包,但是由于WinPcap考慮到很多數(shù)據(jù)結(jié)構(gòu)需要自己封裝且第一階段比賽時(shí)間結(jié)束只有幾天,所以決定使用sharpPcap+C# 代替常用的WinPcap+VC來捕獲數(shù)據(jù)包。
實(shí)現(xiàn)基本思路:
(1)經(jīng)典的HTTP請求方式:
GET /somedir/page.html HTTP/1.1 Host: www.someschool.edu Connection: close User-agent: Mozilla/4.0 Accept-language: fr
(2)我們注意到HTTP請求報(bào)文中的第一行是以GET打頭的,它實(shí)際上是HTTP請求的一種方法,類似的還有POST、HEAD等等。一般熟知的大概就是GET和POST。
(3)利用這個(gè)我們就可以用 sharpPcap 技術(shù)抓取網(wǎng)絡(luò)數(shù)據(jù)包,在數(shù)據(jù)包中判斷TCP數(shù)據(jù)報(bào)文里是否保存了HTTP數(shù)據(jù)。如果有HTTP數(shù)據(jù)且是請求報(bào)文,就獲得了HTTP的 GET、POST 請求數(shù)據(jù)后進(jìn)行解析,數(shù)據(jù)的解析可以通過Content-Type分析數(shù)據(jù)格式,并按照相應(yīng)的解析方式進(jìn)行解碼,解碼過程中還有對于中文字符的處理等等。
部分功能實(shí)現(xiàn)
基于sharpPcap,C#寫的抓包程序源代碼
using System; using System.Collections.Generic; using System.Linq; using System.Text; using SharpPcap; namespace SharpPcapTest { class Program { static void Main(string[] args) { PacketArrivalForm packArrivalForm = new PacketArrivalForm(); packArrivalForm.ShowDialog(); FileOperate fileOperate = new FileOperate(); string ver = SharpPcap.Version.VersionString; Console.WriteLine("SharpPcap {0}, Example1.IfList.cs", ver); String strTemp = "SharpPcap" + ver + "\n"; fileOperate.wtiteToTxtFile(@".\123.txt", strTemp); // Retrieve the device list var devices = LivePcapDeviceList.Instance; // If no devices were found print an error if (devices.Count < 1) { Console.WriteLine("No devices were found on this machine"); return; } Console.WriteLine("\nThe following devices are available on this machine:"); Console.WriteLine("----------------------------------------------------\n"); /* Scan the list printing every entry */ /*獲取驅(qū)動列表*/ foreach (var dev in devices) { //Console.WriteLine("{0}\n", dev.ToString()); fileOperate.wtiteToTxtFile(@".\123.txt", dev.ToString()); strTemp += dev.ToString(); } //在對話框中顯示相關(guān)的設(shè)備信息 ShowForm showForm = new ShowForm(); showForm.setRichTextBoxStr(strTemp); showForm.ShowDialog(); /*接收數(shù)據(jù)包時(shí)間等各種數(shù)據(jù)*/ int i = int.Parse(Console.ReadLine()); LivePcapDevice device = devices[i]; // Register our handler function to the 'packet arrival' event device.OnPacketArrival += new PacketArrivalEventHandler(device_OnPacketArrival); // Open the device for capturing int readTimeoutMilliseconds = 1000; device.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds); Console.WriteLine(); Console.WriteLine("-- Listening on {0}, hit 'Enter' to stop...",device.Description); strTemp = "Hour\tMinute\tSecond\tMillisecond\tlen\n"; fileOperate.wtiteToTxtFile(@".\data.txt", strTemp); // Start the capturing process device.StartCapture(); // Wait for 'Enter' from the user. Console.ReadLine(); // Stop the capturing process device.StopCapture(); Console.WriteLine("-- Capture stopped."); // Print out the device statistics Console.WriteLine(device.Statistics().ToString()); fileOperate.wtiteToTxtFile(@".\data.txt", device.Statistics().ToString()); Console.Write("Hit 'Enter' to exit..."); Console.ReadLine(); } private static void device_OnPacketArrival(object sender, CaptureEventArgs e) { FileOperate fileOperate = new FileOperate(); var time = e.Packet.Timeval.Date; var len = e.Packet.Data.Length; Console.WriteLine("{0}:{1}:{2},{3} Len={4}",time.Hour, time.Minute, time.Second, time.Millisecond, len); string strTemp = time.Hour.ToString() + "\t" + time.Minute.ToString() + "\t" + time.Second.ToString() + "\t" + time.Millisecond.ToString() + "\t\t" + len.ToString() + "\n"; Console.WriteLine(e.Packet.ToString()); strTemp += "\n" + e.Packet.ToString() + "\n"; fileOperate.wtiteToTxtFile(@".\data.txt", strTemp); } } }
設(shè)備信息截圖:


獲取數(shù)據(jù)包數(shù)據(jù)截圖:

完整程序下載:http://pan.baidu.com/s/1i3vEX1r