调用libnet 广播arp包
来源:互联网 发布:赛鸽记录软件 编辑:程序博客网 时间:2024/05/29 14:10
//编译方式gcc arp.c -lnet//arp.c#include <stdio.h>#include <libnet.h>#define MAC_ADDR_LEN 6#define IP_ADDR_LEN 4//向同一网络内所有机器发送ARP REPLY包,告诉他们,23.23.23.2Z在00:df:17:17:17:f2那里int main(int argc, char *argv[]){ printf("into arp\n"); libnet_t *l = NULL; // libnet context int i = 0; char *device = "eth0"; char err_buf[LIBNET_ERRBUF_SIZE]; libnet_ptag_t p_tag; unsigned char src_mac[MAC_ADDR_LEN]//自己机器的MAC地址f4:6d:04:65:48:18 = {0xf4, 0x6d, 0x04, 0x65, 0x48, 0x18}; unsigned char dest_mac[MAC_ADDR_LEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; char *src_ip_str = "192.168.100.91"; unsigned long src_ip, dest_ip = 0; src_ip = libnet_name2addr4(l, src_ip_str, LIBNET_RESOLVE); // create libnet environment l = libnet_init(LIBNET_LINK_ADV, device, err_buf); if(!l) printf("libnet_init error\n"), exit(1); //构造ARP数据包 p_tag = libnet_build_arp( // construct arp packet ARPHRD_ETHER, // hardware type ethernet ETHERTYPE_IP, // protocol type MAC_ADDR_LEN, // mac length IP_ADDR_LEN, // protocol length ARPOP_REPLY, // op type (u_int8_t*)src_mac, // source mac addr这里作用是更新目的地的ARP表 IP-MAC (u_int8_t*)&src_ip, // source ip addr (u_int8_t*)dest_mac, // dest mac addr (u_int8_t*)&dest_ip, // dest ip addr NULL, // payload 0, // payload length l, // libnet context 0 //0 stands to build a new one ); if(-1 == p_tag) printf("libnet_build_arp error\n"), exit(1); //以太网头部 p_tag = libnet_build_ethernet( // create ethernet header (u_int8_t*)dest_mac, // dest mac addr (u_int8_t*)src_mac, // source mac addr这里说明你链路层的源MAC地址,如果改了可以伪装自己 ETHERTYPE_ARP, // protocol type NULL, // payload 0, // payload length l, // libnet context 0 // 0 to build a new one ); if(-1 == p_tag) printf("libnet_build_ethernet error!\n"), exit(1); int res; for(;;){ if(-1 == (res = libnet_write(l))){ printf("libnet_write error!\n");exit(1); } printf("arp packet has been sent\n"); sleep(1); } libnet_destroy(l); printf("out of arp\n"); return 0;}
0 0
- 调用libnet 广播arp包
- libnet发包例子(tcp udp arp广播)
- libnet发包例子(tcp udp arp广播)
- 使用libnet构造ARP响应包
- Ubuntu下C语言+libnet实现ARP数据包广播
- libnet--arp/arp应答
- libnet和pcap模拟ARP
- libnet
- libnet
- 不用安装Wincap程序实现ARP广播包的发送和接收
- WinPcap和Libnet开发包介绍
- arp应答包初始化
- ARP包详解
- 接收ARP包
- 三个源码包libnet、libnids、libpcap学习TCP/IP
- 使用libnet构造源mac持续更新的arp攻击程序
- 发送arp包获取mac
- PERL脚本ARP抓包
- [WebGL入门]十一,着色器的编译和连接
- 蚊子132来到一个大型互联网公司
- xml的两种解析方式
- (韩顺平讲解)jdbc学习(二)---jdbc开发之mysql
- 命令行进入ftp服务器
- 调用libnet 广播arp包
- 人生哪能事事顺心——JAVA异常类
- Android使用HttpClient实现下载,并监控进度
- CSerialport用于多串口烧录MCU时丢失数据的分析与解决办法
- oracle 11g streams 捕获(capture)进程使用示例
- 继承的精华
- 多校第五场 归并排序+暴力矩阵乘+模拟+java大数&记忆化递归
- OC中对外不可变、对内实现可变
- <csapp> malloc lab (《深入理解计算机系统》lab6) (附lab4\lab5下载地址)