涉及数据包的一些操作 的常用工具以及库

来源:互联网 发布:如何注册网站域名 编辑:程序博客网 时间:2024/06/07 04:48

1、 wireshark  --------------- 数据包 抓取工具

 有linux版本  && window版本  ,可以截取想要编号的数据包

file -> export specified packets  导出一条数据流。


2、tcpdump  ------------------linux 命令行 抓包工具

如:   

tcpdump  -i   eth0  host 192.168.2.1 -w  lcf.pcap             

含义: 《通过网卡eth0 抓取 ip 192.168.2.1 的数据包 并将其 保存为 lcf.pcap》


3、tcpreplay    -------------------数据包回放指令 

如:  

tcpreplay  -i  eth3  -M 600  -l 1   t500.pcap 

       含义:  通过 网卡eth3 , 以600M/s 的速率, 循环一次回放 数据包 t500.pcap 里面的 数据,-l 0 表示循环播放

   (当然 你可以在某些网站下载一些数据包播放器)


有时候特殊 比如要发一个 很大的数据包 这个时候需要使用 PF_RING的用户态程序pfsend进行发包pfsend & large pcap filesthe idea of pfsend is to be able to reproduce the file as fast as possible. Hence we load the pcap in memory and inject it. The consequence is that in case of huge files we have the problem you reported.



4、Bittwiste - pcap 编辑工具

Bittwiste的官方开源地址:bittwist.sourceforge.net。软件提供了三个版本,分别针对FreeBSD、Linux、Windows系统。需要在什么平台编译,下载相关的源码包即可.


示例:

将目的ip从192.168.1.3修改为10.10.10.10

# bittwiste -I in.pcap -O out.pcap -T ip -d 192.168.1.3,10.10.10.10

将一个 数据包生成多个数据包,并将所有的数据包的192.168.2.1 改为 192.168.2.X  

for((i=1;i<251;i++))dobittwiste -I  test.pcap -O test-${i}.pcap -T ip -s 192.168.2.1,192.168.2.${i} -d 192.168.2.1,192.168.2.${i}done

reference:

 http://bittwist.sourceforge.net/

 http://www.lovemytool.com/blog/2011/05/bittwiste-pcap-capture-file-editor-by-joke-snelders.html

5、 libnet

    调用库函数的一些api填充里面的一些 结构体字段信息 ,以此来发送数据包 给特定ip


6、libpcap,winpcap 

同样调用一些库函数api,以此来抓取特定数据包,保存成pcap文件。

0 0
原创粉丝点击