📄 427.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>CTerm非常精华下载</title>
</head>
<body bgcolor="#FFFFFF">
<table border="0" width="100%" cellspacing="0" cellpadding="0" height="577">
<tr><td width="32%" rowspan="3" height="123"><img src="DDl_back.jpg" width="300" height="129" alt="DDl_back.jpg"></td><td width="30%" background="DDl_back2.jpg" height="35"><p align="center"><a href="http://apue.dhs.org"><font face="黑体"><big><big>apue</big></big></font></a></td></tr>
<tr>
<td width="68%" background="DDl_back2.jpg" height="44"><big><big><font face="黑体"><p align="center"> ● UNIX网络编程 (BM: clown) </font></big></big></td></tr>
<tr>
<td width="68%" height="44" bgcolor="#000000"><font face="黑体"><big><big><p align="center"></big></big><a href="http://cterm.163.net"><img src="banner.gif" width="400" height="60" alt="banner.gif"border="0"></a></font></td>
</tr>
<tr><td width="100%" colspan="2" height="100" align="center" valign="top"><br><p align="center">[<a href="index.htm">回到开始</a>][<a href="317.htm">上一层</a>][<a href="428.htm">下一篇</a>]
<hr><p align="left"><small>发信人: AngelFalls (Happiness Forever), 信区: Security <br>
标 题: 窥视器程序 <br>
发信站: 武汉白云黄鹤站 (Wed Mar 29 18:18:11 2000), 站内信件 <br>
#include <netdb.h> <br>
#include <stdio.h> <br>
#include <sys/types.h> <br>
#include <sys/socket.h> <br>
#include <net/if_packet.h> <br>
#include <sys/ioctl.h> <br>
#include <net/if.h> <br>
#include <signal.h> <br>
#include <netinet/in.h> <br>
#include <netinet/ip.h> <br>
#include <netinet/if_ether.h> <br>
#include <string.h> <br>
#include <arpa/inet.h> <br>
#include <net/if_arp.h> <br>
#include <netinet/ip_icmp.h> <br>
#include <netinet/tcp.h> <br>
#include <netinet/udp.h> <br>
#include <unistd.h> <br>
#define ETH_H_LEN 6 <br>
#define IP_HLEN 4 <br>
struct arp_hdr{ <br>
u_char dst_addr[ETH_H_LEN]; <br>
u_char src_addr[ETH_H_LEN]; <br>
u_short frame_type; <br>
u_short hw_type; <br>
u_short proto_type; <br>
u_char hw_addr_len; <br>
u_char proto_addr_len; <br>
u_short op; <br>
u_char snd_hw_addr[ETH_H_LEN]; <br>
u_char snd_ip_addr[IP_HLEN]; <br>
u_char rcv_hw_addr[ETH_H_LEN]; <br>
u_char rcv_ip_addr[IP_HLEN]; <br>
}; <br>
struct icmp_hdr{ <br>
u_int8_t type; <br>
u_int8_t code; <br>
u_int16_t checksum; <br>
u_int16_t id; <br>
u_int16_t sequence; <br>
}; <br>
int sock_pak; <br>
int sock_pak; <br>
struct ifreq ifr_old; <br>
char *hw_addr(u_char str_hw[ETH_H_LEN], char *result) <br>
{ <br>
sprintf(result, "%.2x:%.2x:%.2x:%.2x:%.2x:%.2x", str_hw[0], str_hw[1 <br>
], <br>
str_hw[2], str_hw[3], str_hw[4], str_hw[5]); <br>
return result; <br>
} <br>
char *ip_flag(u_int16_t flag, char *str_frag) <br>
{ <br>
char dont_frag[5], more_frag[5]; <br>
flag = ntohs(flag); <br>
if( IP_DF & flag ) <br>
strcpy(dont_frag, "Yes"); <br>
else <br>
strcpy(dont_frag, "No"); <br>
if( IP_MF & flag ) <br>
strcpy(more_frag, "Yes"); <br>
else <br>
strcpy(more_frag, "No"); <br>
sprintf(str_frag, "Don't frag : %s, More frag : %s", dont_frag, <br>
more_frag); <br>
return str_frag; <br>
} <br>
char *ip_proto(u_int8_t proto, char *str_proto) <br>
{ <br>
switch( proto ) <br>
{ <br>
case 1: <br>
strcpy(str_proto, "ICMP"); <br>
break; <br>
case 2: <br>
strcpy(str_proto, "IGMP"); <br>
break; <br>
case 6: <br>
strcpy(str_proto, "TCP"); <br>
break; <br>
case 17: <br>
strcpy(str_proto, "UDP"); <br>
break; <br>
default: <br>
sprintf(str_proto, "%.2x", proto); <br>
break; <br>
} <br>
} <br>
return str_proto; <br>
} <br>
void dealICMP(u_char *pack, int n) <br>
{ <br>
struct icmp_hdr *icmp; <br>
icmp = (struct icmp_hdr*)(pack + sizeof(struct ethhdr) + sizeof(stru <br>
ct i <br>
phdr)); <br>
printf("\nICMP Header Analysis:\n"); <br>
switch(icmp->type) <br>
{ <br>
case ICMP_ECHOREPLY: <br>
printf("type : ICMP_ECHOREPLY, "); <br>
break; <br>
case ICMP_DEST_UNREACH: <br>
printf("type : ICMP_DEST_UNREACH, "); <br>
break; <br>
case ICMP_SOURCE_QUENCH: <br>
printf("type : ICMP_SOURCE_QUENCH, "); <br>
break; <br>
case ICMP_REDIRECT: <br>
printf("type : ICMP_REDIRECT, "); <br>
break; <br>
case ICMP_ECHO: <br>
printf("type : ICMP_ECHO, "); <br>
break; <br>
case ICMP_TIME_EXCEEDED: <br>
printf("type : ICMP_TIME_EXCEEDED, "); <br>
break; <br>
case ICMP_PARAMETERPROB: <br>
printf("type : ICMP_PARAMETERPROB, "); <br>
break; <br>
case ICMP_TIMESTAMP: <br>
printf("type : ICMP_TIMESTAMP, "); <br>
break; <br>
case ICMP_TIMESTAMPREPLY: <br>
printf("type : ICMP_TIMESTAMPREPLY, "); <br>
break; <br>
case ICMP_INFO_REQUEST: <br>
printf("type : ICMP_INFO_REQUEST, "); <br>
break; <br>
case ICMP_INFO_REPLY: <br>
printf("type : ICMP_INFO_REPLY, "); <br>
break; <br>
case ICMP_ADDRESS: <br>
printf("type : ICMP_ADDRESS, "); <br>
break; <br>
case ICMP_ADDRESSREPLY: <br>
printf("type : ICMP_ADDRESSREPLY, "); <br>
break; <br>
default: <br>
printf("type : %.2x, ", icmp->type); <br>
break; <br>
} <br>
printf("Code : %d, Id : %d, Sequence : %d\n", icmp->code, ntohs(icmp <br>
->id <br>
), <br>
ntohs(icmp->sequence)); <br>
} <br>
void dealIGMP(u_char *pack, int n) <br>
{ <br>
} <br>
void dealTCP(u_char *pack, int n) <br>
{ <br>
struct tcphdr *thdr; <br>
thdr = (struct tcphdr*)(pack + sizeof(struct ethhdr) + sizeof(struct <br>
iph <br>
dr)); <br>
printf("\nTCP Header Analysis:\n"); <br>
printf("Src Port : %d, Dst Port : %d, Seq : %d, ACK_Seq : %d\n", <br>
ntohs(thdr->source), ntohs(thdr->dest), <br>
ntohl(thdr->seq), ntohl(thdr->ack_seq)); <br>
printf("HLen : %d, Fin : %d, SYN : %d, RST : %d, PSH : %d, ACK : %d, <br>
URG <br>
: %d\n", <br>
thdr->doff, thdr->fin, thdr->syn, thdr->rst, <br>
thdr->psh, thdr->ack, thdr->urg); <br>
} <br>
void dealUDP(u_char *pack, int n) <br>
{ <br>
struct udphdr *uhdr; <br>
printf("\nUDP Header Analysis:\n"); <br>
uhdr = (struct udphdr*)(pack + sizeof(struct ethhdr) + sizeof(struct <br>
iph <br>
dr)); <br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -