arp--c语言实现

博客探讨了ARP欺骗的问题,包括为何在网关被欺骗后部分应用仍能上网,路由器缺乏防护措施。同时指出ARP请求广播时,局域网设备是否会更新ARP列表,并提到了在虚拟机桥接模式下和手机上的不同响应情况。
摘要由CSDN通过智能技术生成
//以太网头部
typedef struct ethernet_head
{
    u_char dst_mac[6];
    u_char src_mac[6];
    u_short eth_type;
}ethernet_head;
//arp头部
typedef struct arp_head
{
    u_char hardware_type[2];
    u_char protocol_type[2];
    u_char hardware_size;
    u_char protocol_size;
    u_char opcode[2];
    u_char  send_mac[6];
    u_char  send_ip[4];
    u_char  target_mac[6];
    u_char  target_ip[4];
 
}arp_head;
 
 
 
int main()
{
    pcap_if_t *alldevs;
    pcap_if_t *d;
    pcap_t * adhandler;
    char errbuf[PCAP_ERRBUF_SIZE];
    int num;
 
    ethernet_head  ether_data;
    arp_head       arp_data;
 
    u_char packet[100];
    //以太网头部
 
    *((unsigned long long*)&ether_data.dst_mac)=0xffffffffffff;
    *((unsigned long long*)&ether_data.src_mac)=0xaaaaaaaaaaaa;
 
 
    ether_data.eth_type=htons(0x0806);
    //arp头部
 
    *((u_short*)&arp_data.hardware_type)=htons(0x0001);
    *((u_short*)&arp_data.protocol_type)=
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值