资源简介
局域网内dns欺骗的实现代码,已经实现,可以直接运行使用。

代码片段和文件信息
// PcapTest.cpp : Defines the entry point for the console application.
#include “stdio.h“
#include “pcap.h“
#include “remote-ext.h“
#include “winsock.h“
#include
void packet_hander(u_char *paramconst struct pcap_pkthdr *headerconst u_char *pkt_data);
//4字节的IP地址
typedef struct ip_address
{
u_char byte1;
u_char byte2;
u_char byte3;
u_char byte4;
}ip_address;
//IP包头
typedef struct ip_header
{
u_char ver_ihl; //版本 4bit + 首部长度 4bit
u_char tos; //服务类型
u_short tlen; //总长度
u_short identification;
u_short flags_fo;
u_char ttl; //存活时间 time to live
u_char proto; //协议
u_short crc;
ip_address saddr;
ip_address daddr;
}ip_header;
//TCP包头部结构
typedef struct tcp_header {
WORD SourPort;
WORD DestPort;
DWORD SeqNo;
DWORD AckNo;
BYTE Hlen;
BYTE Flag;
WORD WndSize;
WORD ChkSum;
WORD UrgPtr;
}tcp_header;
//TCP伪首部
typedef struct tcp_pseheader
{
ip_address saddr;
ip_address daddr;
u_char placeholder;
u_char proto;
WORD tcplength;
}tcp_pseheader;
//UDP头部结构
typedef struct udp_header
{
u_short sport; //源端口
u_short dport; //目的端口
u_short len;
u_short crc;
}udp_header;
//UDP伪首部
typedef struct psd
{
ip_address saddr;
ip_address daddr;
char mbz;
char ptcl;
unsigned short udpl;
}PSD*PPSD;
//DNS结构
typedef struct dns
{
unsigned short id;
unsigned short flags;
unsigned short quests;
unsigned short answers;
unsigned short author;
unsigned short addition;
}DNS*PDNS;
//DNS问题结构
typedef struct query
{
unsigned short type;
unsigned short classes;
}QUERY*PQUERY;
//DNS回答结构
typedef struct response
{
unsigned short name;
unsigned short type;
unsigned short classes;
unsigned short ttl1;
unsigned short ttl2;
unsigned short length;
unsigned short addr1;
unsigned short addr2;
}RESPONSE*PRESPONSE;
typedef struct Author
{
short name;
short type;
short Class;
int ttl;
short datalength;
};
pcap_t *adhandle;
int main(int argcchar **argv)
{
pcap_if_t* alldevs;
pcap_if_t* d;
int i=0;
int inum;
char errbuf[PCAP_ERRBUF_SIZE];
u_int netmask;
char packet_filter[]=“ip and udp“;
struct bpf_program fcode;
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRINGNULL&alldevserrbuf)==-1)
{
fprintf(stderr“error in pcap_findalldevs_ex:%s\r\n“errbuf);
printf(“\r\n“);
return 0;
}
for (d=alldevs;d;d=d->next)
{
printf(“%d.%s\n“++id->name);
printf(“\r\n“);
if (d->description)
{
printf((“{%s}\n“d->description));
printf(“\r\n“);
}
else
{
printf(“{No description}\n}“);
printf(“\r\n“);
}
}
if (i == 0)
{
printf(“{\r\nNo interface found! Make sure WinPcap is install}“);
return 0;
}
printf(“Enter the interface number{1-%d}:“i);
scanf(“%d“&inum);
if (inum<1||inum>i)
{
printf(“\nInterface number out of range.\n“);
pcap_freealldevs(alldevs);
return -1;
}
for (d=alldevsi=0;i
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 240 2010-11-12 16:17 DNS\ip.dat
文件 9493 2010-12-03 09:01 DNS\SendTcp.cpp
文件 4343 2010-11-15 15:54 DNS\SendTcp.dsp
文件 539 2010-11-10 17:50 DNS\SendTcp.dsw
文件 50176 2010-12-03 09:03 DNS\SendTcp.ncb
文件 54784 2010-12-03 09:03 DNS\SendTcp.opt
文件 1831 2010-12-03 09:01 DNS\SendTcp.plg
文件 13627 2010-11-16 09:33 DNS\新建 文本文档 (2).txt
文件 8858 2010-11-16 08:21 DNS\新建 文本文档.txt
目录 0 2010-12-17 13:28 DNS
----------- --------- ---------- ----- ----
143891 10
- 上一篇:555芯片从基础到精通含30个实用电路
- 下一篇:基于内核的Linux键盘记录器
相关资源
- bp神经网络源代码,可直接运行
- 随机森林R语言代码
- 计算机图形学 边填充算法实现代码
- 直流无刷电机方波驱动 stm32 例程代码
- 仿知乎界面小程序源代码
- 贪吃蛇源代码.fla
- 周立功开发板ProASIC3实验-syn_FIFO代码
- IMX385驱动代码.zip
- dotnet 写字板 实验 源代码 不好请要不
- 图像二维小波变换的实现源代码
- 八三编码器设计 VHDL代码 简单,包附
- linux应用层的华容道游戏源代码
- 交通咨询模拟系统完整代码
- http请求状态代码
- 数值分析所有实验代码
- 网上拍卖系统完整源代码
- 音乐代码转换软件 单片机编程时用
- CSMA/CD等动画演示加源代码
- silicon lab公司的收音IC SI47XX全套开发工
- 用51单片机实现G代码翻译
- 合同管理系统的源代码(附数据库)
- 用VC 编写的仿QQ聊天室程序源代码
- web班级网站设计代码
- 38k单片机红外发送代码、keil
- STM32F103 串口程序(完整版)
- 网络唤醒代码
- VPC3_DPV1源代码,Profibus
- PB做的托盘程序(最小化后在左下角显
- RSA算法源码
- ubuntu9.10 可加载内核模块和字符设备驱
评论
共有 条评论