GUNiffer.cpp文件:
//
// //
// GUNiffer For Win2K by Shotgun //
// //
// Version: 0.30 Beta //
// Released: [2001.4] //
// Author: [Shotgun] //
// Homepage: //
// [http://IT.Xici.Net] //
// [http://www.Patching.Net] //
// //
//
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <Winsock2.h>
#include <mstcpip.h>
#define STATUS_FAILED 0xFFFF file://定义异常出错代码
#define MAX_PACK_LEN 65535 file://接收的最大IP报文
#define MAX_ADDR_LEN 16 file://点分十进制地址的最大长度
#define MAX_PROTO_TEXT_LEN 16 file://子协议名称(如"TCP")最大长度
#define MAX_PROTO_NUM 12 file://子协议数量
#define MAX_HOSTNAME_LAN 255 file://最大主机名长度
#define CMD_PARAM_HELP true
typedef struct _iphdr
{
unsigned char h_lenver; file://4位首部长度+4位IP版本号
unsigned char tos; file://8位服务类型TOS
unsigned short total_len; file://16位总长度(字节)
unsigned short ident; file://16位标识
unsigned short frag_and_flags; file://3位标志位
unsigned char ttl; file://8位生存时间 TTL
unsigned char proto; file://8位协议 (TCP, UDP 或其他)
unsigned short checksum; file://16位IP首部校验和
unsigned int sourceIP; file://32位源IP地址
unsigned int destIP; file://32位目的IP地址
}IP_HEADER;
typedef struct _tcphdr file://定义TCP首部
{
USHORT th_sport; file://16位源端口
USHORT th_dport; file://16位目的端口
unsigned int th_seq; file://32位序列号
unsigned int th_ack; file://32位确认号
unsigned char th_lenres; file://4位首部长度/6位保留字
unsigned char th_flag; file://6位标志位
USHORT th_win; file://16位窗口大小
USHORT th_sum; file://16位校验和
USHORT th_urp; file://16位紧急数据偏移量
}TCP_HEADER;
typedef struct _udphdr file://定义UDP首部
{
unsigned short uh_sport; file://16位源端口
unsigned short uh_dport; file://16位目的端口
unsigned short uh_len; file://16位长度
unsigned short uh_sum; file://16位校验和
} UDP_HEADER;
typedef struct _icmphdr file://定义ICMP首部
{
BYTE i_type; file://8位类型
BYTE i_code; file://8位代码
USHORT i_cksum; file://16位校验和
USHORT i_id; file://识别号(一般用进程号作为识别号)
USHORT i_seq; file://报文序列号
ULONG timestamp; file://时间戳
}ICMP_HEADER;
typedef struct _protomap file://定义子协议映射表
{
int ProtoNum;
char ProtoText[MAX_PROTO_TEXT_LEN];
}PROTOMAP;
PROTOMAP ProtoMap[MAX_PROTO_NUM]={ file://为子协议映射表赋值
{ IPPROTO_IP , "IP " },
{ IPPROTO_ICMP , "ICMP" },
{ IPPROTO_IGMP , "IGMP" },
{ IPPROTO_GGP , "GGP " },
{ IPPROTO_TCP , "TCP " },
{ IPPROTO_PUP , "PUP " },
{ IPPROTO_UDP , "UDP " },
{ IPPROTO_IDP , "IDP " },
{ IPPROTO_ND , "NP " },
{ IPPROTO_RAW , "RAW " },
{ IPPROTO_MAX , "MAX " },
{ NULL , "" } };
SOCKET SockRaw;
char TcpFlag[6]={'F','S','R','P','A','U'}; file://定义TCP标志位<