资源简介
linux下使用原始套接字抓包并发现网络网元,构造数据包,实现过滤规则与数据包统计

代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define MAX_frame_LEN 1500
typedef struct option
{
int ethernet_flag;
int arp_flag;
int ip_flag;
int icmp_flag;
int tcp_flag;
int udp_flag;
int dump_flag;
int aflag;
int f_flag;
}opt;
typedef struct dataid
{
char s_time[50];
char e_time[50];
int total_packet;
int ip_packet;
int udp_packet;
int tcp_packet;
int icmp_packet;
int arp_packet;
int mac_broad;
int mac_short;
int mac_long;
int byte;
int redirect;
int unreach;
}did;
did num;
void inital_opt(opt* node);
void inital_did(did* node);
char* mac_ntoa(char* mac_buf);
char* tcp_ftoa(struct tcphdr* ptcp);
int is_exist(FILE* fpchar* s);
void sig_handle(int sig);
void info_file();
struct iphdr* fill_iphead(const char *src_ip const char *dst_ip int ip_packet_len);
struct tcphdr* fill_tcphead(int src_portint dst_port);
void make_packet(const char *src_ip int src_port const char *dst_ip int dst_port const char *data);
int catch_packet(char* stropt* nodechar* filtersint portchar* ip);
void print_ethernet(struct ether_header* peth);
void do_ip(char* dataopt* node);
void print_ip(struct iphdr* pip);
void do_arp(char* dataopt* node);
void print_arp(struct arphdr* parp);
void do_icmp(char* dataopt* node);
void print_icmp(struct icmphdr* picmp);
void do_udp(char* dataopt* node);
void print_udp(struct udphdr* pudp);
void do_tcp(char* dataopt* node);
void print_tcp(struct tcphdr* ptcp);
void Dump_packet(unsigned char* bufint len);
void inital_did(did* node)
{
node->total_packet=0;
node->ip_packet=0;
node->udp_packet=0;
node->tcp_packet=0;
node->icmp_packet=0;
node->arp_packet=0;
node->mac_broad=0;
node->mac_short=0;
node->mac_long=0;
node->byte=0;
node->redirect=0;
node->unreach=0;
}
void inital_opt(opt* node)
{
node->ethernet_flag=0;
node->arp_flag=1;
node->ip_flag=1;
node->icmp_flag=0;
node->tcp_flag=0;
node->udp_flag=0;
node->dump_flag=0;
node->aflag=0;
node->f_flag=0;
}
char* mac_ntoa(char* mac_buf)
{
static char buf[18];
sprintf(buf “%02x:%02x:%02x:%02x:%02x:%02x\n“ (unsigned char)*mac_buf
(unsigned char)(*(mac_buf + 1)) (unsigned char)(*(mac_buf + 2))
(unsigned char)*(mac_buf + 3) (unsigned char)(*(mac_buf + 4))
(unsigned char)*(mac_buf + 5));
buf[17]=0;
return buf;
}
char* tcp_ftoa(struct tcphdr* ptcp)
{
static char flag[9]={‘0‘‘0‘‘0‘‘0‘‘0‘‘0‘‘0‘‘0‘};
if(ntohs(ptcp->ece)!=0)
{
flag[0]=‘e‘;
}
if(ntohs(ptcp->cwr)!=0)
{
flag[1]=‘c‘;
}
if(ntohs(ptcp->urg)!=0)
{
flag[2]=‘u‘;
}
if(ntohs(ptcp->ack)!=0)
{
flag[3]=‘a‘;
}
if(ntohs(ptcp->psh)!
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 23696 2018-12-03 14:22 ipdump_complex.c
- 上一篇:SSD1306 oled 驱动代码
- 下一篇:杭电考博复习矩阵理论试题A.doc
相关资源
- 抓包工具 sniffer
- ipv6网络抓包程序
- Fiddler中文版.zip
- 北邮 现代交换原理实验 sip电话 抓包
- 网络抓包工具Wireshark 破解版
- 截取封包工具
- Http Analyzer 7(http抓包工具)7 7.6.4破解
- 强大的抓包工具:Fiddler_4.6.1.5
- Fiddler5.0汉化版
- rtmp抓包分析
- 易语言原始套接字应用源码
- 解析抓包软件中tcp包装的数据并转换
- 2000个PNG图标
- 手把手 网络抓包学习视频 跟着pingi
- 基于winpcap的网络数据采集器的实现
- MentoHUST(含抓包工具及使用说明)
- 基于SIP协议的抓包工具
- 基于qt的一款sip抓包工具
- cisco模拟器,可实现虚拟路由器的抓包
- Realtek wifi omnipeak 抓包驱动
- 原始套接字Sniffer程序
- 安卓 网络请求抓包软件 免root
- Device Monitoring Studio-USB抓包工具破解版
- 海康sip信令抓包
- Wireshark实验讲义.doc
- 对指定进程抓包软件WSExplorer+1.3.exe
- IP抓包工具
- 各种协议抓包 汇总
- WPE模拟器手游抓包IP代理配置
- xcap最新完整版
评论
共有 条评论