QQ蠕虫的行为检测方法

安全 移动安全
QQ蠕虫是一种利用QQ等腾讯公司相关产品进行传播的一种特殊蠕虫,该蠕虫的基本原理是利用了QQ帐户的快速登录机制,只要当前系统中有一个QQ帐户成功登录,就可以通过后台接口实现该帐户相关应用的快速登录而不需要再次输入帐户密码。

QQ蠕虫是一种利用QQ等腾讯公司相关产品进行传播的一种特殊蠕虫,该蠕虫的基本原理是利用了QQ帐户的快速登录机制,只要当前系统中有一个QQ帐户成功登录,就可以通过后台接口实现该帐户相关应用的快速登录而不需要再次输入帐户密码。登录后蠕虫可以访问QQ应用的各种网络接口,例如:通过接口实现加QQ好友、加入QQ群、发消息、发日志、发微博、上传群共享文件等操作,且完全不需要用户同意。借用这种技术,QQ蠕虫可以实现非常快速的传播。这种蠕虫诞生于QQ体系之上,其影响和传播主要集中在国内地区,因此国外品牌的杀软对这类蠕虫识别和支持非常有限,国内的杀软品牌对该蠕虫检测也不是特别理想,从而导致了该QQ蠕虫的传播更加快速,影响范围更广。 

[[114765]]

基于以上信息,利用WinPcap技术抓取网络数据包,对HTTP POST包进行分析,过滤出对域名qq.com访问的数据包,但是由于WinPcap考虑到很多数据结构需要自己封装且第一阶段比赛时间结束只有几天,所以决定使用sharpPcap+C# 代替常用的WinPcap+VC来捕获数据包。

实现基本思路

(1)经典的HTTP请求方式:

  1. GET /somedir/page.html HTTP/1.1  
  2. Host:  www.someschool.edu  
  3. Connection: close  
  4. User-agent: Mozilla/4.0  
  5. Accept-language: fr 

(2)我们注意到HTTP请求报文中的第一行是以GET打头的,它实际上是HTTP请求的一种方法,类似的还有POST、HEAD等等。一般熟知的大概就是GET和POST。

(3)利用这个我们就可以用 sharpPcap 技术抓取网络数据包,在数据包中判断TCP数据报文里是否保存了HTTP数据。如果有HTTP数据且是请求报文,就获得了HTTP的 GET、POST 请求数据后进行解析,数据的解析可以通过Content-Type分析数据格式,并按照相应的解析方式进行解码,解码过程中还有对于中文字符的处理等等。

部分功能实现

基于sharpPcap,C#写的抓包程序源代码

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using SharpPcap;  
  6. namespace SharpPcapTest  
  7. {  
  8. class Program  
  9. {  
  10. static void Main(string[] args)  
  11. {  
  12. PacketArrivalForm packArrivalForm = new PacketArrivalForm();  
  13. packArrivalForm.ShowDialog();  
  14. FileOperate fileOperate = new FileOperate();  
  15. string ver = SharpPcap.Version.VersionString;  
  16. Console.WriteLine("SharpPcap {0}, Example1.IfList.cs", ver);  
  17. String strTemp = "SharpPcap" + ver + "\n";  
  18. fileOperate.wtiteToTxtFile(@".\123.txt", strTemp);  
  19. // Retrieve the device list  
  20. var devices = LivePcapDeviceList.Instance;  
  21. // If no devices were found print an error  
  22. if (devices.Count < 1)  
  23. {  
  24. Console.WriteLine("No devices were found on this machine");  
  25. return;  
  26. }  
  27. Console.WriteLine("\nThe following devices are available on this machine:");  
  28. Console.WriteLine("----------------------------------------------------\n");  
  29. /* Scan the list printing every entry */  
  30. /*获取驱动列表*/  
  31. foreach (var dev in devices)  
  32. {  
  33. //Console.WriteLine("{0}\n", dev.ToString());  
  34. fileOperate.wtiteToTxtFile(@".\123.txt", dev.ToString());  
  35. strTemp += dev.ToString();  
  36. }  
  37. //在对话框中显示相关的设备信息  
  38. ShowForm showForm = new ShowForm();  
  39. showForm.setRichTextBoxStr(strTemp);  
  40. showForm.ShowDialog();  
  41. /*接收数据包时间等各种数据*/  
  42. int  i = int.Parse(Console.ReadLine());  
  43. LivePcapDevice device = devices[i];  
  44. // Register our handler function to the 'packet arrival' event  
  45. device.OnPacketArrival += new PacketArrivalEventHandler(device_OnPacketArrival);  
  46. // Open the device for capturing  
  47. int readTimeoutMilliseconds = 1000;  
  48. device.Open(DeviceMode.Promiscuous, readTimeoutMilliseconds);  
  49. Console.WriteLine();  
  50. Console.WriteLine("-- Listening on {0}, hit 'Enter' to stop...",device.Description);  
  51. strTemp = "Hour\tMinute\tSecond\tMillisecond\tlen\n";  
  52. fileOperate.wtiteToTxtFile(@".\data.txt", strTemp);  
  53. // Start the capturing process  
  54. device.StartCapture();  
  55. // Wait for 'Enter' from the user.  
  56. Console.ReadLine();  
  57. // Stop the capturing process  
  58. device.StopCapture();  
  59. Console.WriteLine("-- Capture stopped.");  
  60. // Print out the device statistics  
  61. Console.WriteLine(device.Statistics().ToString());  
  62. fileOperate.wtiteToTxtFile(@".\data.txt", device.Statistics().ToString());  
  63. Console.Write("Hit 'Enter' to exit...");  
  64. Console.ReadLine();  
  65. }  
  66. private static void device_OnPacketArrival(object sender, CaptureEventArgs e)  
  67.    
  68. {  
  69. FileOperate fileOperate = new FileOperate();  
  70. var time = e.Packet.Timeval.Date;  
  71. var len = e.Packet.Data.Length;  
  72. Console.WriteLine("{0}:{1}:{2},{3} Len={4}",time.Hour, time.Minute, time.Second, time.Millisecond, len);  
  73. string strTemp = time.Hour.ToString() + "\t" + time.Minute.ToString() + "\t" +  time.Second.ToString() + "\t" + time.Millisecond.ToString() + "\t\t" +  len.ToString() + "\n";  
  74. Console.WriteLine(e.Packet.ToString());  
  75. strTemp += "\n" + e.Packet.ToString() + "\n";  
  76. fileOperate.wtiteToTxtFile(@".\data.txt", strTemp);  
  77. }  
  78. }  

 设备信息截图:

QQ蠕虫的行为检测方法 

QQ蠕虫的行为检测方法

获取数据包数据截图:

QQ蠕虫的行为检测方法

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

责任编辑:蓝雨泪 来源: 网络安全攻防实验室
相关推荐

2010-07-20 10:26:50

2010-12-17 10:07:55

2010-02-03 16:13:37

2022-11-09 11:02:00

2016-09-02 09:14:26

2013-04-27 13:33:33

2009-09-25 11:11:22

2010-08-26 10:12:54

2012-06-15 09:41:40

Linux内核

2021-07-28 09:53:53

FalconEye注入安全检测

2010-09-14 15:34:29

sql server死

2023-12-31 16:44:30

2023-07-07 06:48:18

2010-11-16 13:40:52

Oracle命令行

2013-05-07 10:34:16

2019-12-19 14:54:10

工信部APP违规

2020-05-13 11:10:32

安全 机器学习数据

2018-12-14 14:30:12

安全检测布式系测试

2010-04-13 11:24:42

光纤端面检测布线

2009-01-03 09:13:00

点赞
收藏

51CTO技术栈公众号