资源简介
简单的网络嗅探器
代码片段和文件信息
/*
* arp.c
*
* Created on: 2009-7-7
* Author: lele
*
* 处理ARP请求
* Hardware type Protocol type
Hardware address length Protocol address length Opcode
Source hardware address :::
Source protocol address :::
Destination hardware address :::
Destination protocol address :::
Data :::
*
*/
#include “sniffer.h“
void handle_arp (const u_char* packet)
{
//ARP 头
struct nast_arp_hdr *arp;
struct libnet_ethernet_hdr *eptr;
u_short ether_type;
eptr = (struct libnet_ethernet_hdr *) packet;
arp = (struct nast_arp_hdr *) (packet+offset);
ether_type = ntohs(eptr->ether_type);
if (ether_type == ETHERTYPE_ARP)
{
fprintf(logfile “\n---[ ARP ]-----------------------------------------------------------\n“);
fprintf(logfile “%s -> “ nast_hex_ntoa (eptr->ether_shost));
fprintf(logfile “%s\n“ nast_hex_ntoa (eptr->ether_dhost));
switch (ntohs(arp->ar_op))
{
case 1:
{
fprintf(logfile “类型: ARP 请求: “);
fprintf(logfile “Who has %d.%d.%d.%d? “arp->__ar_tip[0]arp->__ar_tip[1]arp->__ar_tip[2]arp->__ar_tip[3]);
fprintf(logfile “Tell %d.%d.%d.%d\n“arp->__ar_sip[0]arp->__ar_sip[1]arp->__ar_sip[2]arp->__ar_sip[3]);
}
break;
case 2:
{
fprintf(logfile “类型: ARP 应答: “);
fprintf(logfile “%d.%d.%d.%d is at %s\n“arp->__ar_sip[0]arp->__ar_sip[1]arp->__ar_sip[2]arp->__ar_sip[3] nast_hex_ntoa (eptr->ether_shost));
}
break;
case 8:
fprintf(logfile “类型: InARP 请求“);
break;
case 9:
fprintf(logfile “类型: InARP 应答\t“);
break;
default:
fprintf(logfile “类型: 未知操作符“);
break;
}
fprintf(logfile “硬件大小: %d - “ arp->ar_hln);
fprintf(logfile “协议大小: %d\n“ arp->ar_pln);
}
else if (eptr->ether_type == ETHERTYPE_REVARP)
{
fprintf(logfile “\n---[ RARP ]----------------------------------------------------------\n“);
fprintf(logfile “%s -> “ nast_hex_ntoa (eptr->ether_shost));
fprintf(logfile “%s\n“ nast_hex_ntoa (eptr->ether_dhost));
switch (ntohs(arp->ar_op))
{
case 3:
fprintf(logfile “类型: RARP 请求“);
break;
case 4:
fprintf(logfile “类型: RARP 应答\t“);
break;
case 8:
fprintf(logfile “类型: InARP 请求“);
break;
case 9:
fprintf(logfile “类型: InARP 应答\t“);
break;
default:
fprintf(logfile “类型: 未知操作符“);
break;
}
fprintf(logfile “\t硬件大小: %d - “arp->ar_hln);
fprintf(logfile “协议大小: %d\n“arp->ar_pln);
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-02-14 02:59 src\
文件 2680 2009-07-08 05:42 src\arp.c
文件 2462 2009-07-08 05:42 src\common.c
文件 800 2009-07-08 05:24 src\device.c
文件 918 2009-07-07 13:15 src\ethernet.c
文件 4977 2009-07-08 07:05 src\find_gateway.c
文件 7581 2009-07-08 05:02 src\icmp.c
文件 1965 2009-07-07 14:16 src\igmp.c
文件 3730 2009-07-08 07:06 src\main.c
文件 112 2009-07-08 12:43 src\makefile
文件 7828 2009-07-08 05:17 src\port.c
文件 4052 2009-07-08 04:56 src\sniffer.c
文件 2611 2009-07-08 06:28 src\sniffer.h
文件 3776 2009-07-07 14:20 src\tcp.c
文件 1834 2009-07-07 14:22 src\udp.c
文件 247760 2019-02-14 02:56 src\sniffer
文件 54431 2019-02-14 02:59 src\log.txt
- 上一篇:opencv2.4.4
- 下一篇:sx1276 sx1278 阻抗匹配设计指南
相关资源
- rm.bat 在win下模拟linux rm命令的bat文件
- Linux下串口读写例程
- 《嵌入式Linux应用程序开发标准教程》
- linux的arpSpoof源代码加编译好的程序
- linux和win32下通用的互斥锁Mutex封装
- 在Linux下添加系统调用
- ARM&linux嵌入式系统教程每章答案-马忠
- Vsftp2.3.4 for linux
- intel_parallel_studio_xe_2013_update2_intel64_
- 最新 socks5-v1.0r11.tar.gz linux代理配置源
- linux ftp服务器安装包vsftpd-1.1.3-8.i386
- Linux常用Shell脚本珍藏
- Linux运维工程师成长必经之路.pdf
- 基于linux下用c编写的socket通信传输文
- linux rootkit源码
- linux下shell编程实验报告-考勤系统
- Linux网络编程 第2版带详细目录
- Linux JDK 1.6 1.7 1.8 齐全
- debian-10.4.0-amd64-netinst.iso
- linux Qt4 软键盘
- cuda_9.0.103_384.59_linux.run 百度网盘地址
- cudnn-9.0-linux-x64-v7 百度网盘地址
- linux ov5640驱动源码
- mp3 播放器的linux c代码
- 自己总结的Linux_Shell_脚本讲解+
- linux,windosarm 三版本lcx
- Linux更换JDK+weblogic更换JDK
- Linux 实验8
- Linux就该这么学第16期视频
- e1000e-3.5.1.tar.gz
评论
共有 条评论