资源简介
简单的网络嗅探器

代码片段和文件信息
/*
* 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 阻抗匹配设计指南
相关资源
- uboot到linux logo显示不间断 补丁
- UNIX/LINUX编程实践教程的源码
- Linux任务管理器
- linux应用层的华容道游戏源代码
- ubuntu9.10 可加载内核模块和字符设备驱
- MP3文件ID3v2ID3v2APEv2标签读取
- 操作系统实验——虚存管理实验
- linux下的发包工具sendip
- 尚观培训linux许巍关于c 的笔记和讲义
- 尚观培训linux董亮老师关于数据结构的
- linux 线程池源码 c 版
- linux C 电梯程序练习
- linux下用多进程同步方法解决生产者
- 电梯模拟程序C/C 算法实现
- Linux 操作系统实验(全)
- Linux From Scratch 中文手册
- linux 网络实验 ftp程序
- Linux命令大全离线版&在线版
- 操作系统共享内存实验
- dos 下运行Linux 命令--gnu_utils
- linux 0.12内核源代码
- linux简易shell C实现
- linux实验报告及心得体会
- 基于GTK的Linux环境下的简易任务管理器
- linux扫雷游戏代码
- CAN Linux驱动代码
- Linux系统教材
- intel 82579LM 网卡驱动Linux系统版 v1.9.
- SA1110处理器掌上电脑液晶显示器设计
- 基于Linux的串口服务器设计
评论
共有 条评论