QQ蠕虫的行为检测方法

admin 2021年4月25日04:34:28评论35 views字数 3511阅读11分42秒阅读模式

1、选题背景

QQ蠕虫是一种利用QQ等腾讯公司相关产品进行传播的一种特殊蠕虫。

该蠕虫的基本原理是利用了QQ帐户的快速登录机制,只要当前系统中有一个QQ帐户成功登录,就可以通过后台接口实现该帐户相关应用的快速登录而不需要再次输入帐户密码。


登录后蠕虫可以访问QQ应用的各种网络接口。

例如:通过接口实现加QQ好友、加入QQ群、发消息、发日志、发微博、上传群共享文件等操作,且完全不需要用户同意。


借用这种技术,QQ蠕虫可以实现非常快速的传播。

这种蠕虫诞生于QQ体系之上,其影响和传播主要集中在国内地区。

因此国外品牌的杀软对这类蠕虫识别和支持非常有限,国内的杀软品牌对该蠕虫检测也不是特别理想,从而导致了该QQ蠕虫的传播更加快速,影响范围更广。


基于以上信息,利用WinPcap技术抓取网络数据包,对HTTP POST包进行分析,过滤出对域名qq.com访问的数据包。

但是由于WinPcap考虑到很多数据结构需要自己封装且时间很少,所以决定使用sharpPcap+C# 代替常用的 WinPcap+VC来捕获数据包。


2、实现基本思路:

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

GET /somedir/page.html HTTP/1.1

Host: www.someschool.edu

Connection: close

User-agent: Mozilla/4.0

Accept-language: fr


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

一般熟知的大概就是GET和POST。

(3)利用这个我们就可以用 sharpPcap 技术抓取网络数据包,在数据包中判断TCP数据报文里是否保存了HTTP数据。

如果有HTTP数据且是请求报文,就获得了HTTP的 GET、POST 请求数据后进行解析。

数据的解析可以通过Content-Type分析数据格式,并按照相应的解析方式进行解码,解码过程中还有对于中文字符的处理等等。

3、部分功能实现

基于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 */


/*获取驱动列表*/


foreach (var dev in devices)

{

//Console.WriteLine("{0}n", dev.ToString());

fileOperate.wtiteToTxtFile(@".123.txt", dev.ToString());

strTemp += dev.ToString();

}


//在对话框中显示相关的设备信息

ShowForm showForm = new ShowForm();

showForm.setRichTextBoxStr(strTemp);

showForm.ShowDialog();


/*接收数据包时间等各种数据*/

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 = "HourtMinutetSecondtMillisecondtlenn";

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() + "tt" + len.ToString() + "n";


Console.WriteLine(e.Packet.ToString());

strTemp += "n" + e.Packet.ToString() + "n";

fileOperate.wtiteToTxtFile(@".data.txt", strTemp);

}

}

}


设备信息截图:

QQ蠕虫的行为检测方法


获取数据包数据截图:

QQ蠕虫的行为检测方法


附上exe下载地址:http://pan.baidu.com/s/1mgp3kWo

本文始发于微信公众号(T00ls):QQ蠕虫的行为检测方法

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年4月25日04:34:28
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   QQ蠕虫的行为检测方法https://cn-sec.com/archives/352946.html

发表评论

匿名网友 填写信息