Nothing 2008-1-8 09:53
Ò»¸öLinuxÏÂ×¥°üÈí¼þ(Ô´Âë)
[color=#000000][color=#ff9900]//ÓмǼ¼¸ÖÖ¹¥»÷µÄ¹¦ÄÜ£¬¾ßÌåʲô¹¥»÷¿´Á˳ÌÐò¾ÍÖªµÀÁË¡££º£©
[/color]
[color=#ff9900]//myxray.c V0.2
[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]sys[color=#0000cc]/[/color][color=#ff0000]socket[/color][color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]sys[color=#0000cc]/[/color]types[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]stdio[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color][color=#ff0000]errno[/color][color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]sys[color=#0000cc]/[/color]ioctl[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]net[color=#0000cc]/[/color][color=#0000ff]if[/color][color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color][color=#ff0000]signal[/color][color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]netinet[color=#0000cc]/[/color]ip[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]netinet[color=#0000cc]/[/color]in[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color][color=#ff0000]string[/color][color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]arpa[color=#0000cc]/[/color]inet[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]netinet[color=#0000cc]/[/color]if_ether[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]netinet[color=#0000cc]/[/color]ip_icmp[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color][color=#ff0000]time[/color][color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]netinet[color=#0000cc]/[/color]igmp[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]define[/color] __FAVOR_BSD
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]netinet[color=#0000cc]/[/color]tcp[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]netdb[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]include[/color] [color=#0000cc]<[/color]netinet[color=#0000cc]/[/color]udp[color=#0000cc].[/color]h[color=#0000cc]>[/color]
[color=#0000cc]#[/color][color=#ff0000]define[/color] PACKET_SIZE 4096
[color=#0000cc]#[/color][color=#ff0000]define[/color] ETH_HW_ADDR_LEN 6
[color=#0000cc]#[/color][color=#ff0000]define[/color] IP_ADDR_LEN 4
[color=#0000cc]#[/color][color=#ff0000]define[/color] LOWCOUNTER 10
[color=#0000cc]#[/color][color=#ff0000]define[/color] [color=#ff0000]MAX[/color][color=#0000cc]([/color]a[color=#0000cc],[/color]b[color=#0000cc])[/color] [color=#0000cc]([/color][color=#0000cc]([/color]a[color=#0000cc])[/color][color=#0000cc]>[/color][color=#0000cc]([/color]b[color=#0000cc])[/color][color=#0000cc]?[/color][color=#0000cc]([/color]a[color=#0000cc])[/color][color=#0000cc]:[/color][color=#0000cc]([/color]b[color=#0000cc])[/color][color=#0000cc])[/color]
[color=#0000ff]struct[/color] arp_packet
¡¡¡¡¡¡¡¡[color=#0000cc]{[/color]
¡¡¡¡¡¡¡¡u_char targ_hw_addr[color=#0000cc][[/color]ETH_HW_ADDR_LEN[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_char src_hw_addr[color=#0000cc][[/color]ETH_HW_ADDR_LEN[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_short frame_type[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_short hw_type[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_short prot_type[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_char hw_addr_size[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_char prot_addr_size[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_short op[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_char sndr_hw_addr[color=#0000cc][[/color]ETH_HW_ADDR_LEN[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_char sndr_ip_addr[color=#0000cc][[/color]IP_ADDR_LEN[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_char rcpt_hw_addr[color=#0000cc][[/color]ETH_HW_ADDR_LEN[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_char rcpt_ip_addr[color=#0000cc][[/color]IP_ADDR_LEN[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡u_char padding[color=#0000cc][[/color]18[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡[color=#0000cc]}[/color] [color=#0000cc];[/color]
[color=#0000ff]void[/color] leave[color=#0000cc]([/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color] hwaddr [color=#0000cc]([/color][color=#0000ff]unsigned[/color] char¡¡[color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]void[/color] writearpbuf[color=#0000cc]([/color][color=#ff0000]FILE[/color] [color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]int[/color][color=#0000cc])[/color][color=#0000cc];[/color][color=#ff9900]//дһ¸öarpbufµ½fdÖÐ
[/color]
[color=#0000ff]void[/color] writetcpbuf[color=#0000cc]([/color][color=#ff0000]FILE[/color] [color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]int[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]void[/color] writeudpbuf[color=#0000cc]([/color][color=#ff0000]FILE[/color] [color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]int[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]void[/color] writeigmpbuf[color=#0000cc]([/color][color=#ff0000]FILE[/color] [color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]int[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]void[/color] writeicmpbuf[color=#0000cc]([/color][color=#ff0000]FILE[/color] [color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc],[/color][color=#0000ff]int[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]int[/color] fd_recv [color=#0000cc]=[/color] [color=#0000cc]-[/color]1 [color=#0000cc];[/color]
[color=#ff0000]time_t[/color] one[color=#0000cc],[/color]two[color=#0000cc],[/color]temptime[color=#0000cc];[/color]
[color=#0000ff]char[/color] arpbufone[color=#0000cc][[/color]PACKET_SIZE[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] tcpbufone[color=#0000cc][[/color]PACKET_SIZE[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] udpbufone[color=#0000cc][[/color]PACKET_SIZE[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] igmpbufone[color=#0000cc][[/color]PACKET_SIZE[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] icmpbufone[color=#0000cc][[/color]PACKET_SIZE[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]int[/color] arpcounter[color=#0000cc]=[/color]0[color=#0000cc],[/color]tcpcounter[color=#0000cc]=[/color]0[color=#0000cc],[/color]igmpcounter[color=#0000cc]=[/color]0[color=#0000cc],[/color]icmpcounter[color=#0000cc]=[/color]0[color=#0000cc],[/color]udpcounter[color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#0000ff]char[/color] writebuf[color=#0000cc][[/color]PACKET_SIZE[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#ff0000]FILE[/color] [color=#0000cc]*[/color] waringfd[color=#0000cc];[/color]
[color=#0000ff]unsigned[/color] [color=#0000ff]int[/color] total[color=#0000cc]=[/color]0[color=#0000cc],[/color]totalarp[color=#0000cc]=[/color]0[color=#0000cc],[/color]disarp[color=#0000cc]=[/color]0[color=#0000cc],[/color]totaltcp[color=#0000cc]=[/color]0[color=#0000cc],[/color]distcp[color=#0000cc]=[/color]0[color=#0000cc],[/color]
totaludp[color=#0000cc]=[/color]0[color=#0000cc],[/color]disudp[color=#0000cc]=[/color]0[color=#0000cc],[/color]totalicmp[color=#0000cc]=[/color]0[color=#0000cc],[/color]disicmp[color=#0000cc]=[/color]0[color=#0000cc],[/color]totaligmp[color=#0000cc]=[/color]0[color=#0000cc],[/color]disigmp[color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#0000ff]struct[/color] ifreq ifr[color=#0000cc],[/color]ifr_old[color=#0000cc];[/color]
main[color=#0000cc]([/color][color=#0000ff]int[/color] argc[color=#0000cc],[/color] [color=#0000ff]char[/color] [color=#0000cc]*[/color]argv[color=#0000cc][[/color][color=#0000cc]][/color][color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#0000ff]char[/color] device[color=#0000cc][[/color][color=#0000cc]][/color] [color=#0000cc]=[/color] [color=#ff00ff]"eth0"[/color][color=#0000cc];[/color] [color=#ff9900]// ethernet device name
[/color]
[color=#0000ff]char[/color] protocol[color=#0000cc][[/color]16[color=#0000cc]][/color][color=#0000cc];[/color]
u_char buf_recv[color=#0000cc][[/color]PACKET_SIZE[color=#0000cc]][/color][color=#0000cc];[/color] [color=#ff9900]// buffer for receive
[/color]
[color=#0000ff]int[/color] ihl[color=#0000cc];[/color]
[color=#0000ff]int[/color] ethprotol[color=#0000cc];[/color]
[color=#0000ff]int[/color] ipfragoff[color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc];[/color]
[color=#0000ff]int[/color] protol[color=#0000cc];[/color]
[color=#0000ff]char[/color] buf1[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc],[/color]buf2[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc],[/color]buf3[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc],[/color]buf4[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] strptr[color=#0000cc][[/color]255[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color]srcaddr[color=#0000cc],[/color][color=#0000cc]*[/color]dstaddr[color=#0000cc];[/color]
[color=#0000ff]struct[/color] ethhdr [color=#0000cc]*[/color]eth [color=#0000cc];[/color]
[color=#0000ff]struct[/color] arp_packet [color=#0000cc]*[/color]arphead[color=#0000cc];[/color]
[color=#0000ff]struct[/color] udphdr [color=#0000cc]*[/color]udp[color=#0000cc];[/color]
[color=#0000ff]struct[/color] icmp [color=#0000cc]*[/color]icmphdr[color=#0000cc];[/color]
[color=#0000ff]struct[/color] iphdr [color=#0000cc]*[/color] ip[color=#0000cc];[/color]
[color=#0000ff]struct[/color] tcphdr [color=#0000cc]*[/color] tcp1[color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color]flagsmes[color=#0000cc];[/color]
[color=#0000ff]int[/color] flags[color=#0000cc];[/color]
[color=#0000ff]struct[/color] igmp [color=#0000cc]*[/color] igmp1[color=#0000cc];[/color]
[color=#0000ff]struct[/color] [color=#ff0000]in_addr[/color] in1[color=#0000cc];[/color]
[color=#0000ff]struct[/color] [color=#ff0000]in_addr[/color] in2[color=#0000cc];[/color]
[color=#0000ff]int[/color] from_len[color=#0000cc],[/color] datalen[color=#0000cc];[/color]
[color=#0000ff]struct[/color] [color=#ff0000]sockaddr[/color] from[color=#0000cc];[/color]
[color=#0000ff]int[/color] arpenable[color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#0000ff]int[/color] tcpenable[color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#0000ff]int[/color] icmpenable[color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#0000ff]int[/color] igmpenable[color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#0000ff]int[/color] loenable[color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#0000ff]int[/color] udpenable[color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color]tcpflag[color=#0000cc]=[/color][color=#ff0000]NULL[/color][color=#0000cc];[/color]
[color=#0000ff]int[/color] c[color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color]dstip[color=#0000cc]=[/color][color=#ff0000]NULL[/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color]srcip[color=#0000cc]=[/color][color=#ff0000]NULL[/color][color=#0000cc];[/color]
[color=#0000ff]extern[/color] [color=#0000ff]char[/color] [color=#0000cc]*[/color]optarg[color=#0000cc];[/color]
[color=#0000ff]extern[/color] [color=#0000ff]int[/color] optind[color=#0000cc];[/color]
[color=#0000ff]const[/color] [color=#0000ff]char[/color]
message[color=#0000cc][[/color][color=#0000cc]][/color][color=#0000cc]=[/color]
[color=#ff00ff]"-a
display arp packet
-t
display tcp packet
-f¡¡¡¡¡¡one of RST FIN SYN PUSH ACK URG
display only tcpflag tcp packet
-u
display udp packet
-i
display icmp packet
-g
display igmp packet
-A
display all packet
-l
also display lo layer packet
-s srcip
display srcip packet
-d dstip
display dstip packet
Welcome to use myxray which writed by sztcww Good Luck"[/color][color=#0000cc];[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]argc[color=#0000cc]=[/color][color=#0000cc]=[/color]1[color=#0000cc])[/color] [color=#0000cc]{[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"%s\n"[/color][color=#0000cc],[/color]message[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]exit[/color][color=#0000cc]([/color][color=#0000cc]-[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]while[/color] [color=#0000cc]([/color][color=#0000cc]([/color]c [color=#0000cc]=[/color] getopt[color=#0000cc]([/color]argc[color=#0000cc],[/color] argv[color=#0000cc],[/color] [color=#ff00ff]"Aatugil?s:d:f:"[/color][color=#0000cc])[/color][color=#0000cc])[/color] [color=#0000cc]![/color][color=#0000cc]=[/color] [color=#ff0000]EOF[/color][color=#0000cc])[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000ff]switch[/color] [color=#0000cc]([/color]c[color=#0000cc])[/color] [color=#0000cc]{[/color]
¡¡¡¡¡¡¡¡case [color=#ff00ff]'A'[/color][color=#0000cc]:[/color]
¡¡ tcpenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡ udpenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡ icmpenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡ igmpenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡ arpenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡ [color=#0000ff]break[/color][color=#0000cc];[/color]
[color=#0000ff]case[/color] [color=#ff00ff]'d'[/color][color=#0000cc]:[/color]
¡¡ dstip[color=#0000cc]=[/color]optarg[color=#0000cc];[/color]
[color=#0000ff]break[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡case [color=#ff00ff]'s'[/color][color=#0000cc]:[/color]
srcip[color=#0000cc]=[/color]optarg[color=#0000cc];[/color]
[color=#0000ff]break[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡case [color=#ff00ff]'f'[/color][color=#0000cc]:[/color]
tcpflag[color=#0000cc]=[/color]optarg[color=#0000cc];[/color]
[color=#0000ff]break[/color][color=#0000cc];[/color]
[color=#0000ff]case[/color] [color=#ff00ff]'a'[/color][color=#0000cc]:[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ arpenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000ff]break[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡case [color=#ff00ff]'t'[/color][color=#0000cc]:[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ tcpenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000ff]break[/color][color=#0000cc];[/color]
¡¡¡¡¡¡ [color=#0000ff]case[/color] [color=#ff00ff]'i'[/color][color=#0000cc]:[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ icmpenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000ff]break[/color][color=#0000cc];[/color]
¡¡¡¡¡¡ [color=#0000ff]case[/color] [color=#ff00ff]'g'[/color][color=#0000cc]:[/color]
igmpenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000ff]break[/color][color=#0000cc];[/color]
¡¡¡¡¡¡ [color=#0000ff]case[/color] [color=#ff00ff]'u'[/color][color=#0000cc]:[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ udpenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000ff]break[/color][color=#0000cc];[/color]
¡¡¡¡¡¡ [color=#0000ff]case[/color] [color=#ff00ff]'l'[/color][color=#0000cc]:[/color]
loenable[color=#0000cc]=[/color]1[color=#0000cc];[/color]
[color=#0000ff]break[/color][color=#0000cc];[/color]
¡¡¡¡¡¡ [color=#0000ff]case[/color] [color=#ff00ff]'?'[/color][color=#0000cc]:[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"%s\n"[/color][color=#0000cc],[/color]message[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#ff0000]exit[/color][color=#0000cc]([/color][color=#0000cc]-[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000cc]}[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color] [color=#0000cc]([/color]waringfd[color=#0000cc]=[/color][color=#ff0000]fopen[/color][color=#0000cc]([/color][color=#ff00ff]"myxray.waring"[/color][color=#0000cc],[/color][color=#ff00ff]"a+"[/color][color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc]=[/color][color=#0000cc]=[/color][color=#ff0000]NULL[/color][color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#ff0000]perror[/color][color=#0000cc]([/color][color=#ff00ff]"fopen"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]exit[/color][color=#0000cc]([/color][color=#0000cc]-[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
fd_recv [color=#0000cc]=[/color] [color=#ff0000]socket[/color][color=#0000cc]([/color][color=#ff0000]AF_INET[/color][color=#0000cc],[/color] [color=#ff0000]SOCK_PACKET[/color][color=#0000cc],[/color] [color=#ff0000]htons[/color][color=#0000cc]([/color]0x0003[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]fd_recv [color=#0000cc]<[/color] 0[color=#0000cc])[/color] [color=#0000cc]{[/color] [color=#ff0000]perror[/color][color=#0000cc]([/color] [color=#ff00ff]"packet socket error"[/color][color=#0000cc])[/color][color=#0000cc];[/color] [color=#ff0000]exit[/color][color=#0000cc]([/color][color=#0000cc]-[/color]1[color=#0000cc])[/color][color=#0000cc];[/color] [color=#0000cc]}[/color]
[color=#ff0000]strcpy[/color][color=#0000cc]([/color]ifr[color=#0000cc].[/color]ifr_name[color=#0000cc],[/color] device[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]ioctl[color=#0000cc]([/color]fd_recv[color=#0000cc],[/color] [color=#ff0000]SIOCGIFFLAGS[/color][color=#0000cc],[/color] [color=#0000cc]&[/color]ifr[color=#0000cc])[/color] [color=#0000cc]<[/color] 0 [color=#0000cc])[/color]
[color=#0000cc]{[/color]
¡¡ [color=#ff0000]perror[/color][color=#0000cc]([/color][color=#ff00ff]"ioctl SIOCGIFFLAGS error"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]fd_recv [color=#0000cc]>[/color][color=#0000cc]=[/color] 0[color=#0000cc])[/color] [color=#ff0000]close[/color][color=#0000cc]([/color]fd_recv[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]exit[/color][color=#0000cc]([/color][color=#0000cc]-[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
ifr_old [color=#0000cc]=[/color] ifr[color=#0000cc];[/color]
ifr[color=#0000cc].[/color]ifr_flags [color=#0000cc]|[/color][color=#0000cc]=[/color] IFF_PROMISC[color=#0000cc];[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]ioctl[color=#0000cc]([/color]fd_recv[color=#0000cc],[/color] [color=#ff0000]SIOCSIFFLAGS[/color][color=#0000cc],[/color] [color=#0000cc]&[/color]ifr[color=#0000cc])[/color] [color=#0000cc]<[/color] 0 [color=#0000cc])[/color]
[color=#0000cc]{[/color]
¡¡ [color=#ff0000]perror[/color][color=#0000cc]([/color][color=#ff00ff]"ioctl SIOCSIFFLAGS error"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]fd_recv [color=#0000cc]>[/color][color=#0000cc]=[/color] 0[color=#0000cc])[/color] [color=#ff0000]close[/color][color=#0000cc]([/color]fd_recv[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]exit[/color][color=#0000cc]([/color][color=#0000cc]-[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#ff0000]signal[/color][color=#0000cc]([/color][color=#ff0000]SIGINT[/color][color=#0000cc],[/color] leave[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]signal[/color][color=#0000cc]([/color][color=#ff0000]SIGTERM[/color][color=#0000cc],[/color] leave[color=#0000cc])[/color][color=#0000cc];[/color]
one[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
AGAIN[color=#0000cc]:[/color]
bzero[color=#0000cc]([/color][color=#0000cc]&[/color]from[color=#0000cc],[/color] [color=#0000ff]sizeof[/color][color=#0000cc]([/color]from[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
from_len [color=#0000cc]=[/color] [color=#0000ff]sizeof[/color][color=#0000cc]([/color]from[color=#0000cc])[/color][color=#0000cc];[/color]
bzero[color=#0000cc]([/color]buf_recv[color=#0000cc],[/color] PACKET_SIZE[color=#0000cc])[/color][color=#0000cc];[/color]
datalen [color=#0000cc]=[/color] [color=#ff0000]recvfrom[/color][color=#0000cc]([/color]fd_recv[color=#0000cc],[/color] [color=#0000cc]([/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc])[/color]buf_recv[color=#0000cc],[/color] 4096[color=#0000cc],[/color] 0[color=#0000cc],[/color][color=#0000cc]&[/color]from[color=#0000cc],[/color] [color=#0000cc]&[/color]from_len[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]datalen [color=#0000cc]<[/color] 0[color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#ff0000]perror[/color][color=#0000cc]([/color][color=#ff00ff]"recvfrom error"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]exit[/color][color=#0000cc]([/color][color=#0000cc]-[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
total[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
buf_recv[color=#0000cc][[/color]datalen[color=#0000cc]][/color] [color=#0000cc]=[/color] [color=#ff00ff]'\0'[/color][color=#0000cc];[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]loenable[color=#0000cc]=[/color][color=#0000cc]=[/color]0[color=#0000cc])[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color][color=#ff0000]strcmp[/color][color=#0000cc]([/color]device[color=#0000cc],[/color] from[color=#0000cc].[/color]sa_data[color=#0000cc])[/color] [color=#0000cc]![/color][color=#0000cc]=[/color] 0[color=#0000cc])[/color] [color=#0000ff]goto[/color] AGAIN[color=#0000cc];[/color]
eth[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] ethhdr [color=#0000cc]*[/color][color=#0000cc])[/color]buf_recv[color=#0000cc];[/color]
ethprotol[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_proto[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]ethprotol[color=#0000cc]=[/color][color=#0000cc]=[/color]0x0806[color=#0000cc])[/color]
[color=#0000cc]{[/color]
arphead[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] arp_packet [color=#0000cc]*[/color][color=#0000cc])[/color]buf_recv[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡memcpy[color=#0000cc]([/color][color=#0000cc]&[/color]in1[color=#0000cc],[/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]sndr_ip_addr[color=#0000cc],[/color] IP_ADDR_LEN[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡memcpy[color=#0000cc]([/color][color=#0000cc]&[/color]in2[color=#0000cc],[/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]rcpt_ip_addr[color=#0000cc],[/color] IP_ADDR_LEN[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡srcaddr[color=#0000cc]=[/color]inet_ntoa[color=#0000cc]([/color]in1[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡dstaddr[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]char[/color][color=#0000cc]*[/color][color=#0000cc])[/color]inet_ntop[color=#0000cc]([/color][color=#ff0000]AF_INET[/color][color=#0000cc],[/color][color=#0000cc]&[/color]in2[color=#0000cc],[/color]strptr[color=#0000cc],[/color][color=#0000ff]sizeof[/color][color=#0000cc]([/color]strptr[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
totalarp[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
¡¡¡¡¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color] [color=#0000cc]([/color][color=#0000cc]![/color][color=#ff0000]memcmp[/color][color=#0000cc]([/color]srcaddr[color=#0000cc],[/color]dstaddr[color=#0000cc],[/color][color=#ff0000]MAX[/color][color=#0000cc]([/color][color=#ff0000]strlen[/color][color=#0000cc]([/color]srcaddr[color=#0000cc])[/color][color=#0000cc],[/color][color=#ff0000]strlen[/color][color=#0000cc]([/color]dstaddr[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc]&[/color][color=#0000cc]&[/color]
[color=#0000cc]([/color][color=#ff0000]memcmp[/color][color=#0000cc]([/color]hwaddr[color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]rcpt_hw_addr[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color][color=#ff00ff]"00:00:00:00:00:00"[/color][color=#0000cc],[/color]17[color=#0000cc])[/color][color=#0000cc])[/color] [color=#0000cc])[/color]
¡¡writearpbuf[color=#0000cc]([/color]waringfd[color=#0000cc],[/color]buf_recv[color=#0000cc],[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff9900]/*¼Í¼arp°üÖÐsrcaddr,dstaddrÏàͬµÄÊý¾Ý°ü*/[/color]
[color=#0000ff]else[/color]
[color=#0000cc]{[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color] [color=#ff0000]memcmp[/color][color=#0000cc]([/color]buf_recv[color=#0000cc],[/color]arpbufone[color=#0000cc],[/color]datalen[color=#0000cc])[/color][color=#0000cc]=[/color][color=#0000cc]=[/color]0 [color=#0000cc])[/color] arpcounter[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
[color=#0000ff]else[/color]
[color=#0000cc]{[/color]
if¡¡[color=#0000cc]([/color]arpcounter[color=#0000cc]>[/color]LOWCOUNTER[color=#0000cc])[/color]
[color=#ff9900]/*¼Í¼Á¬Ðø×¥µ½µÄ,arpcounter>LOWCOUNTERµÄarp°ü */[/color]
¡¡ [color=#0000cc]{[/color]
writearpbuf[color=#0000cc]([/color]waringfd[color=#0000cc],[/color]arpbufone[color=#0000cc],[/color]arpcounter[color=#0000cc]+[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#ff0000]memcpy[/color][color=#0000cc]([/color]arpbufone[color=#0000cc],[/color]buf_recv[color=#0000cc],[/color]datalen[color=#0000cc])[/color][color=#0000cc];[/color]
arpcounter[color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#0000cc]}[/color][color=#ff9900]//end else
[/color]
[color=#0000cc]}[/color][color=#ff9900]//end else
[/color]
[color=#0000cc]}[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000cc]([/color]ethprotol[color=#0000cc]=[/color][color=#0000cc]=[/color]0x0806[color=#0000cc])[/color][color=#0000cc]&[/color][color=#0000cc]&[/color][color=#0000cc]([/color]arpenable[color=#0000cc])[/color][color=#0000cc])[/color]
[color=#0000cc]{[/color][color=#ff9900]//arp
[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color] [color=#0000cc]([/color] [color=#0000cc]([/color]dstip[color=#0000cc]=[/color][color=#0000cc]=[/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc]|[/color][color=#0000cc]|[/color][color=#0000cc]([/color][color=#ff0000]strcmp[/color][color=#0000cc]([/color]dstaddr[color=#0000cc],[/color]dstip[color=#0000cc])[/color][color=#0000cc]=[/color][color=#0000cc]=[/color]0[color=#0000cc])[/color] [color=#0000cc])[/color][color=#0000cc]&[/color][color=#0000cc]&[/color]
[color=#0000cc]([/color][color=#0000cc]([/color]srcip[color=#0000cc]=[/color][color=#0000cc]=[/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc]|[/color][color=#0000cc]|[/color][color=#0000cc]([/color][color=#ff0000]strcmp[/color][color=#0000cc]([/color]srcaddr[color=#0000cc],[/color]srcip[color=#0000cc])[/color][color=#0000cc]=[/color][color=#0000cc]=[/color]0[color=#0000cc])[/color] [color=#0000cc])[/color] [color=#0000cc])[/color]
¡¡¡¡¡¡ [color=#0000cc]{[/color]
temptime[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"Recorded %sethhdr\nsrchw:%s--->dsthw:%s proto:%xH\n"[/color][color=#0000cc],[/color]
¡¡ [color=#ff0000]ctime[/color][color=#0000cc]([/color][color=#0000cc]&[/color]temptime[color=#0000cc])[/color][color=#0000cc],[/color]hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_source[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color]hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_dest[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]ethprotol[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"arphdr\nhwtype:%d protol:%xH hw_size:%d pro_size:%d op:%d\ns_ha:% s s_ip:%s\nd_ha:%s d_ip:%s\n"[/color][color=#0000cc],[/color]
[color=#ff0000]ntohs[/color][color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]hw_type[color=#0000cc])[/color][color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]prot_type[color=#0000cc])[/color][color=#0000cc],[/color]
arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]hw_addr_size[color=#0000cc],[/color] arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]prot_addr_size[color=#0000cc],[/color]
[color=#ff0000]ntohs[/color][color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]op[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]sndr_hw_addr[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color]
srcaddr[color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]rcpt_hw_addr[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]dstaddr[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"-----------------------------------------------------------\n"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
disarp[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
¡¡ [color=#0000cc]}[/color]
¡¡ [color=#0000ff]goto[/color] AGAIN[color=#0000cc];[/color]
[color=#0000cc]}[/color][color=#ff9900]//end arp
[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]ethprotol[color=#0000cc]=[/color][color=#0000cc]=[/color]0x0800[color=#0000cc])[/color]
[color=#0000cc]{[/color][color=#ff9900]//ip
[/color]
ip [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]struct[/color] iphdr [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]&[/color]buf_recv[color=#0000cc][[/color]14[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡ ihl [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]int[/color][color=#0000cc])[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl [color=#0000cc]<[/color][color=#0000cc]<[/color] 2[color=#0000cc];[/color]
in1[color=#0000cc].[/color]s_addr [color=#0000cc]=[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]saddr[color=#0000cc];[/color]
¡¡ in2[color=#0000cc].[/color]s_addr [color=#0000cc]=[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]daddr[color=#0000cc];[/color]
¡¡ srcaddr[color=#0000cc]=[/color]inet_ntoa[color=#0000cc]([/color]in1[color=#0000cc])[/color][color=#0000cc];[/color]
dstaddr[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc])[/color]inet_ntop[color=#0000cc]([/color][color=#ff0000]AF_INET[/color][color=#0000cc],[/color][color=#0000cc]&[/color]in2[color=#0000cc],[/color]strptr[color=#0000cc],[/color][color=#0000ff]sizeof[/color][color=#0000cc]([/color]strptr[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff9900]//iphdr
[/color]
¡¡ protol[color=#0000cc]=[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]protocol[color=#0000cc];[/color]
¡¡ ipfragoff[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]frag_off[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ df[color=#0000cc]=[/color]ipfragoff[color=#0000cc]&[/color]IP_DF[color=#0000cc];[/color]
¡¡ mf[color=#0000cc]=[/color]ipfragoff[color=#0000cc]&[/color]IP_MF[color=#0000cc];[/color]
¡¡¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]df!=0[color=#0000cc])[/color] df[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]mf!=0[color=#0000cc])[/color] mf[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡ protol[color=#0000cc]=[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]protocol[color=#0000cc];[/color]
[color=#0000ff]switch[/color] [color=#0000cc]([/color]protol[color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#0000ff]case[/color] 6 [color=#0000cc]:[/color]totaltcp[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
¡¡ tcp1 [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]struct[/color] tcphdr [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]&[/color]buf_recv[color=#0000cc][[/color]14 [color=#0000cc]+[/color] ihl[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡ flags[color=#0000cc]=[/color] tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_flags[color=#0000cc];[/color]
¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_PUSH[color=#0000cc])[/color] flagsmes[color=#0000cc]=[/color][color=#ff00ff]"PUSH"[/color][color=#0000cc];[/color]
¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_ACK[color=#0000cc])[/color] flagsmes[color=#0000cc]=[/color][color=#ff00ff]"ACK"[/color][color=#0000cc];[/color]
¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_URG[color=#0000cc])[/color] flagsmes[color=#0000cc]=[/color][color=#ff00ff]"URG"[/color][color=#0000cc];[/color]
¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_FIN[color=#0000cc])[/color] flagsmes[color=#0000cc]=[/color][color=#ff00ff]"FIN"[/color][color=#0000cc];[/color]
¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_SYN[color=#0000cc])[/color] flagsmes[color=#0000cc]=[/color][color=#ff00ff]"SYN"[/color][color=#0000cc];[/color]
¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_RST[color=#0000cc])[/color] flagsmes[color=#0000cc]=[/color][color=#ff00ff]"RST"[/color][color=#0000cc];[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color] [color=#0000cc]![/color][color=#ff0000]memcmp[/color][color=#0000cc]([/color]buf_recv[color=#0000cc],[/color]tcpbufone[color=#0000cc],[/color]datalen[color=#0000cc])[/color][color=#0000cc])[/color]
tcpcounter[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
[color=#0000ff]else[/color]
[color=#0000cc]{[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]tcpcounter[color=#0000cc]>[/color]LOWCOUNTER[color=#0000cc])[/color]
[color=#0000cc]{[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ writetcpbuf[color=#0000cc]([/color]waringfd[color=#0000cc],[/color]tcpbufone[color=#0000cc],[/color]tcpcounter[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
tcpcounter[color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#ff0000]memcpy[/color][color=#0000cc]([/color]tcpbufone[color=#0000cc],[/color]buf_recv[color=#0000cc],[/color]datalen[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡ [color=#0000cc]}[/color]
[color=#0000ff]break[/color][color=#0000cc];[/color]
[color=#0000ff]case[/color] 1 [color=#0000cc]:[/color] totalicmp[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
¡¡¡¡ icmphdr[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] icmp [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]&[/color]buf_recv[color=#0000cc][[/color]14 [color=#0000cc]+[/color] ihl[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000cc]![/color][color=#ff0000]memcmp[/color][color=#0000cc]([/color]buf_recv[color=#0000cc],[/color]icmpbufone[color=#0000cc],[/color]datalen[color=#0000cc])[/color][color=#0000cc])[/color]
icmpcounter[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
[color=#0000ff]else[/color]
[color=#0000cc]{[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]icmpcounter[color=#0000cc]>[/color]LOWCOUNTER[color=#0000cc])[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ¡¡¡¡¡¡¡¡[color=#0000cc]{[/color]
writeicmpbuf[color=#0000cc]([/color]waringfd[color=#0000cc],[/color]icmpbufone[color=#0000cc],[/color]icmpcounter[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000cc]}[/color]
icmpcounter[color=#0000cc]=[/color]0[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#ff0000]memcpy[/color][color=#0000cc]([/color]icmpbufone[color=#0000cc],[/color]buf_recv[color=#0000cc],[/color]datalen[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]break[/color][color=#0000cc];[/color]
[color=#0000ff]case[/color] 17[color=#0000cc]:[/color]totaludp[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
¡¡ udp[color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]struct[/color] udphdr [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]&[/color]buf_recv[color=#0000cc][[/color]14 [color=#0000cc]+[/color] ihl[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color] [color=#0000cc]![/color][color=#ff0000]memcmp[/color][color=#0000cc]([/color]buf_recv[color=#0000cc],[/color]udpbufone[color=#0000cc],[/color]datalen[color=#0000cc])[/color][color=#0000cc])[/color]
udpcounter[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
[color=#0000ff]else[/color]
[color=#0000cc]{[/color]
¡¡¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]udpcounter[color=#0000cc]>[/color]LOWCOUNTER[color=#0000cc])[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000cc]{[/color]
¡¡¡¡¡¡¡¡¡¡writeudpbuf[color=#0000cc]([/color]waringfd[color=#0000cc],[/color]udpbufone[color=#0000cc],[/color]udpcounter[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡[color=#0000cc]}[/color]
¡¡¡¡ udpcounter[color=#0000cc]=[/color]0[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#ff0000]memcpy[/color][color=#0000cc]([/color]udpbufone[color=#0000cc],[/color]buf_recv[color=#0000cc],[/color]datalen[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]break[/color][color=#0000cc];[/color]
[color=#0000ff]case[/color] 2 [color=#0000cc]:[/color]totaligmp[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
¡¡ ¡¡¡¡¡¡ igmp1[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] igmp [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]&[/color]buf_recv[color=#0000cc][[/color]14[color=#0000cc]+[/color]ihl[color=#0000cc]][/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000cc]![/color][color=#ff0000]memcmp[/color][color=#0000cc]([/color]inet_ntoa[color=#0000cc]([/color]igmp1[color=#0000cc]-[/color][color=#0000cc]>[/color]igmp_group[color=#0000cc])[/color][color=#0000cc],[/color][color=#ff00ff]"0.0.0.0"[/color][color=#0000cc],[/color]7[color=#0000cc])[/color][color=#0000cc])[/color]
writeigmpbuf[color=#0000cc]([/color]waringfd[color=#0000cc],[/color]buf_recv[color=#0000cc],[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]else[/color]
[color=#0000cc]{[/color]
¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000cc]![/color][color=#ff0000]memcmp[/color][color=#0000cc]([/color]buf_recv[color=#0000cc],[/color]igmpbufone[color=#0000cc],[/color]datalen[color=#0000cc])[/color][color=#0000cc])[/color]
igmpcounter[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
¡¡ [color=#0000ff]else[/color]
¡¡ [color=#0000cc]{[/color]
¡¡¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]igmpcounter[color=#0000cc]>[/color]LOWCOUNTER[color=#0000cc])[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#0000cc]{[/color]
writeigmpbuf[color=#0000cc]([/color]waringfd[color=#0000cc],[/color]igmpbufone[color=#0000cc],[/color]igmpcounter[color=#0000cc])[/color][color=#0000cc];[/color] [color=#0000cc]}[/color]
¡¡¡¡¡¡igmpcounter[color=#0000cc]=[/color]0[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡memcpy[color=#0000cc]([/color]igmpbufone[color=#0000cc],[/color]buf_recv[color=#0000cc],[/color]datalen[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#0000cc]}[/color]
[color=#0000cc]}[/color]
[color=#0000ff]break[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000cc]([/color][color=#0000cc]([/color]dstip[color=#0000cc]=[/color][color=#0000cc]=[/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc]|[/color][color=#0000cc]|[/color][color=#0000cc]([/color][color=#ff0000]strcmp[/color][color=#0000cc]([/color]dstaddr[color=#0000cc],[/color]dstip[color=#0000cc])[/color][color=#0000cc]=[/color][color=#0000cc]=[/color]0[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc]&[/color][color=#0000cc]&[/color]
[color=#0000cc]([/color][color=#0000cc]([/color]srcip[color=#0000cc]=[/color][color=#0000cc]=[/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc]|[/color][color=#0000cc]|[/color][color=#0000cc]([/color][color=#ff0000]strcmp[/color][color=#0000cc]([/color]srcaddr[color=#0000cc],[/color]srcip[color=#0000cc])[/color][color=#0000cc]=[/color][color=#0000cc]=[/color]0[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000cc]([/color]protol[color=#0000cc]=[/color][color=#0000cc]=[/color]6[color=#0000cc])[/color][color=#0000cc]&[/color][color=#0000cc]&[/color][color=#0000cc]([/color]tcpenable[color=#0000cc])[/color][color=#0000cc])[/color]
[color=#0000cc]{[/color][color=#ff9900]//tcp
[/color]
¡¡¡¡ [color=#0000ff]if[/color] [color=#0000cc]([/color]tcpflag!=NULL[color=#0000cc])[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color][color=#ff0000]strcmp[/color][color=#0000cc]([/color]tcpflag[color=#0000cc],[/color]flagsmes[color=#0000cc])[/color][color=#0000cc])[/color] [color=#0000ff]goto[/color] AGAIN[color=#0000cc];[/color]
¡¡ [color=#ff9900]//do with ethhdr data
[/color]
temptime[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"Recorded %sethhdr\nsrchw:%s--->dsthw:%s proto:%xH\n"[/color][color=#0000cc],[/color]
[color=#ff0000]ctime[/color][color=#0000cc]([/color][color=#0000cc]&[/color]temptime[color=#0000cc])[/color][color=#0000cc],[/color]hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_source[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_dest[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]
ethprotol[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff9900]//iphdr
[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"iphdr\nver:%d ihl:%d tos:%d tot_len:%d id:%d df:%d mf:%d fragoff:%d TTL:%d proto:%d\nsrcaddr:%s dstaddr:%s\n"[/color][color=#0000cc],[/color]
ip[color=#0000cc]-[/color][color=#0000cc]>[/color]version[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl[color=#0000cc],[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tos[color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tot_len[color=#0000cc])[/color][color=#0000cc],[/color]
[color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]id[color=#0000cc])[/color][color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]ipfragoff[color=#0000cc]&[/color]IP_OFFMASK[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ttl[color=#0000cc],[/color]
protol[color=#0000cc],[/color]srcaddr[color=#0000cc],[/color]dstaddr[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff9900]//tcphdr
[/color]
¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"tcphdr\nsrcport:%d dstport:%d seq:%u ack:%u off:%d flag:%s win:%d\n"[/color][color=#0000cc],[/color]
[color=#ff0000]ntohs[/color][color=#0000cc]([/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_sport[color=#0000cc])[/color][color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_dport[color=#0000cc])[/color][color=#0000cc],[/color]
[color=#ff0000]ntohl[/color][color=#0000cc]([/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_seq[color=#0000cc])[/color][color=#0000cc],[/color][color=#ff0000]ntohl[/color][color=#0000cc]([/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_ack[color=#0000cc])[/color][color=#0000cc],[/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_off[color=#0000cc],[/color]
flagsmes[color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_win[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"-----------------------------------------------------------\n"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
distcp[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
¡¡ [color=#0000cc]}[/color][color=#ff9900]//end tcp
[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000cc]([/color]protol[color=#0000cc]=[/color][color=#0000cc]=[/color]1[color=#0000cc])[/color][color=#0000cc]&[/color][color=#0000cc]&[/color][color=#0000cc]([/color]icmpenable[color=#0000cc])[/color][color=#0000cc])[/color]
[color=#0000cc]{[/color][color=#ff9900]//icmp
[/color]
temptime[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"Recorded %sethhdr\nsrchw:%s--->dsthw:%s proto:%xH\n"[/color][color=#0000cc],[/color]
[color=#ff0000]ctime[/color][color=#0000cc]([/color][color=#0000cc]&[/color]temptime[color=#0000cc])[/color][color=#0000cc],[/color]hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_source[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_dest[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]
ethprotol[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"iphdr\nver:%d ihl:%d tos:%d tot_len:%d id:%d df:%d mf:%d fragoff:%d TTL:%d proto:%d\nsrcaddr:%s dstaddr:%s\n"[/color][color=#0000cc],[/color]
ip[color=#0000cc]-[/color][color=#0000cc]>[/color]version[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl[color=#0000cc],[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tos[color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tot_len[color=#0000cc])[/color][color=#0000cc],[/color]
[color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]id[color=#0000cc])[/color][color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]ipfragoff[color=#0000cc]&[/color]IP_OFFMASK[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ttl[color=#0000cc],[/color]
protol[color=#0000cc],[/color]srcaddr[color=#0000cc],[/color]dstaddr[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"icmp\ntype:%d code:%d\n"[/color][color=#0000cc],[/color]icmphdr[color=#0000cc]-[/color][color=#0000cc]>[/color]icmp_type[color=#0000cc],[/color]
icmphdr[color=#0000cc]-[/color][color=#0000cc]>[/color]icmp_code[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"-----------------------------------------------------------\n"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
disicmp[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
¡¡ [color=#0000cc]}[/color][color=#ff9900]//end icmp
[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000cc]([/color]protol[color=#0000cc]=[/color][color=#0000cc]=[/color]17[color=#0000cc])[/color][color=#0000cc]&[/color][color=#0000cc]&[/color][color=#0000cc]([/color]udpenable[color=#0000cc])[/color][color=#0000cc])[/color]
[color=#0000cc]{[/color][color=#ff9900]//udphdr
[/color]
temptime[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"Recored %sethhdr\nsrchw:%s--->dsthw:%s proto:%xH\n"[/color][color=#0000cc],[/color]
[color=#ff0000]ctime[/color][color=#0000cc]([/color][color=#0000cc]&[/color]temptime[color=#0000cc])[/color][color=#0000cc],[/color]hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_source[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_dest[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]
ethprotol[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"iphdr\nver:%d ihl:%d tos:%d tot_len:%d id:%d df:%d mf:%d fragoff:%d TTL:%d proto:%d\nsrcaddr:%s dstaddr:%s\n"[/color][color=#0000cc],[/color]
ip[color=#0000cc]-[/color][color=#0000cc]>[/color]version[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl[color=#0000cc],[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tos[color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tot_len[color=#0000cc])[/color][color=#0000cc],[/color]
[color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]id[color=#0000cc])[/color][color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]ipfragoff[color=#0000cc]&[/color]IP_OFFMASK[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ttl[color=#0000cc],[/color]
protol[color=#0000cc],[/color]srcaddr[color=#0000cc],[/color]dstaddr[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"udphdr\nsport:%d dsport:%d len:%d\n"[/color][color=#0000cc],[/color]
[color=#ff0000]ntohs[/color][color=#0000cc]([/color]udp[color=#0000cc]-[/color][color=#0000cc]>[/color]uh_sport[color=#0000cc])[/color][color=#0000cc],[/color] [color=#ff0000]ntohs[/color][color=#0000cc]([/color]udp[color=#0000cc]-[/color][color=#0000cc]>[/color]uh_dport[color=#0000cc])[/color][color=#0000cc],[/color]
[color=#ff0000]ntohs[/color][color=#0000cc]([/color]udp[color=#0000cc]-[/color][color=#0000cc]>[/color]uh_ulen[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"-----------------------------------------------------------\n"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
disudp[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
¡¡ [color=#0000cc]}[/color][color=#ff9900]//end udp
[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000cc]([/color]protol[color=#0000cc]=[/color][color=#0000cc]=[/color]2[color=#0000cc])[/color][color=#0000cc]&[/color][color=#0000cc]&[/color][color=#0000cc]([/color]igmpenable[color=#0000cc])[/color][color=#0000cc])[/color]
[color=#0000cc]{[/color][color=#ff9900]//igmp
[/color]
temptime[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"Recored %sethhdr\nsrchw:%s--->dsthw:%s proto:%xH\n"[/color][color=#0000cc],[/color]
[color=#ff0000]ctime[/color][color=#0000cc]([/color][color=#0000cc]&[/color]temptime[color=#0000cc])[/color][color=#0000cc],[/color]hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_source[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_dest[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]
ethprotol[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"iphdr\nver:%d ihl:%d tos:%d tot_len:%d id:%d df:%d mf:%d fragoff:%d TTL:%d proto:%d\nsrcaddr:%s dstaddr:%s\n"[/color][color=#0000cc],[/color]
ip[color=#0000cc]-[/color][color=#0000cc]>[/color]version[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl[color=#0000cc],[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tos[color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tot_len[color=#0000cc])[/color][color=#0000cc],[/color]
[color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]id[color=#0000cc])[/color][color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]ipfragoff[color=#0000cc]&[/color]IP_OFFMASK[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ttl[color=#0000cc],[/color]
protol[color=#0000cc],[/color]srcaddr[color=#0000cc],[/color]dstaddr[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡ [color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"igmphdr\ntype:%d code:%d group_addr:%s\n"[/color][color=#0000cc],[/color]
igmp1[color=#0000cc]-[/color][color=#0000cc]>[/color]igmp_type[color=#0000cc],[/color]igmp1[color=#0000cc]-[/color][color=#0000cc]>[/color]igmp_code[color=#0000cc],[/color]
inet_ntoa[color=#0000cc]([/color]igmp1[color=#0000cc]-[/color][color=#0000cc]>[/color]igmp_group[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"-----------------------------------------------------------\n"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
disigmp[color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color][color=#ff9900]//end igmp
[/color]
¡¡
[color=#ff0000]fflush[/color][color=#0000cc]([/color][color=#ff0000]stdout[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color] [color=#ff9900]//endif strcmp
[/color]
[color=#0000cc]}[/color][color=#ff9900]//endif ip
[/color]
¡¡goto AGAIN[color=#0000cc];[/color]
[color=#0000cc]}[/color][color=#ff9900]//end main
[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color]
hwaddr [color=#0000cc]([/color][color=#0000ff]unsigned[/color] [color=#0000ff]char[/color] [color=#0000cc]*[/color] s[color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color]d[color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#ff0000]sprintf[/color] [color=#0000cc]([/color]d[color=#0000cc],[/color] [color=#ff00ff]"%02X:%02X:%02X:%02X:%02X:%02X"[/color][color=#0000cc],[/color] s[color=#0000cc][[/color]0[color=#0000cc]][/color][color=#0000cc],[/color] s[color=#0000cc][[/color]1[color=#0000cc]][/color][color=#0000cc],[/color] s[color=#0000cc][[/color]2[color=#0000cc]][/color][color=#0000cc],[/color] s[color=#0000cc][[/color]3[color=#0000cc]][/color][color=#0000cc],[/color]
s[color=#0000cc][[/color]4[color=#0000cc]][/color][color=#0000cc],[/color] s[color=#0000cc][[/color]5[color=#0000cc]][/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]return[/color] d[color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]void[/color] leave[color=#0000cc]([/color][color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]ioctl[color=#0000cc]([/color]fd_recv[color=#0000cc],[/color] [color=#ff0000]SIOCSIFFLAGS[/color][color=#0000cc],[/color] [color=#0000cc]&[/color]ifr_old[color=#0000cc])[/color] [color=#0000cc]<[/color] 0[color=#0000cc])[/color] [color=#0000cc]{[/color]
[color=#ff0000]perror[/color][color=#0000cc]([/color][color=#ff00ff]"ioctl SIOCSIFFLAGS error"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]if[/color] [color=#0000cc]([/color]fd_recv [color=#0000cc]>[/color] 0[color=#0000cc])[/color] [color=#ff0000]close[/color][color=#0000cc]([/color]fd_recv[color=#0000cc])[/color][color=#0000cc];[/color]
two[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]fclose[/color][color=#0000cc]([/color]waringfd[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"total received %u packets\n"[/color][color=#0000cc],[/color]total[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"tcp¡¡packets %u, display %u, speed is %u /second\n"[/color][color=#0000cc],[/color]totaltcp[color=#0000cc],[/color]distcp[color=#0000cc],[/color]totaltcp[color=#0000cc]/[/color][color=#0000cc]([/color]two[color=#0000cc]-[/color]one[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"udp¡¡packets %u, display %u, speed is %u /second\n"[/color][color=#0000cc],[/color]totaludp[color=#0000cc],[/color]disudp[color=#0000cc],[/color]totaludp[color=#0000cc]/[/color][color=#0000cc]([/color]two[color=#0000cc]-[/color]one[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"arp¡¡packets %u, display %u, speed is %u /second\n"[/color][color=#0000cc],[/color]totalarp[color=#0000cc],[/color]disarp[color=#0000cc],[/color]totalarp[color=#0000cc]/[/color][color=#0000cc]([/color]two[color=#0000cc]-[/color]one[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"icmp packets %u, display %u, speed is %u /second\n"[/color][color=#0000cc],[/color]totalicmp[color=#0000cc],[/color]disicmp[color=#0000cc],[/color]totalicmp[color=#0000cc]/[/color][color=#0000cc]([/color]two[color=#0000cc]-[/color]one[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"igmp packets %u, display %u, speed is %u /second\n"[/color][color=#0000cc],[/color]totaligmp[color=#0000cc],[/color]disigmp[color=#0000cc],[/color]totaligmp[color=#0000cc]/[/color][color=#0000cc]([/color]two[color=#0000cc]-[/color]one[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]printf[/color][color=#0000cc]([/color][color=#ff00ff]"process terminamted.\n"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]exit[/color][color=#0000cc]([/color]0[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]void[/color] writearpbuf[color=#0000cc]([/color][color=#ff0000]FILE[/color] [color=#0000cc]*[/color] fd[color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color]p[color=#0000cc],[/color][color=#0000ff]int[/color] counter[color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#0000ff]struct[/color] arp_packet [color=#0000cc]*[/color]arphead[color=#0000cc];[/color]
[color=#0000ff]struct[/color] [color=#ff0000]in_addr[/color] in2[color=#0000cc],[/color]in1[color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color]srcaddr[color=#0000cc],[/color][color=#0000cc]*[/color]dstaddr[color=#0000cc];[/color]
[color=#ff0000]time_t[/color] temptime[color=#0000cc];[/color]
[color=#0000ff]char[/color] strptr[color=#0000cc][[/color]255[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] buf1[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc],[/color]buf2[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc],[/color]buf3[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc],[/color]buf4[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]int[/color] ethprotol[color=#0000cc];[/color]
temptime[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡arphead[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] arp_packet [color=#0000cc]*[/color][color=#0000cc])[/color]p[color=#0000cc];[/color]
ethprotol[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]frame_type[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡memcpy[color=#0000cc]([/color][color=#0000cc]&[/color]in1[color=#0000cc],[/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]sndr_ip_addr[color=#0000cc],[/color] IP_ADDR_LEN[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡memcpy[color=#0000cc]([/color][color=#0000cc]&[/color]in2[color=#0000cc],[/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]rcpt_ip_addr[color=#0000cc],[/color] IP_ADDR_LEN[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡srcaddr[color=#0000cc]=[/color]inet_ntoa[color=#0000cc]([/color]in1[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡dstaddr[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]char[/color][color=#0000cc]*[/color][color=#0000cc])[/color]inet_ntop[color=#0000cc]([/color][color=#ff0000]AF_INET[/color][color=#0000cc],[/color][color=#0000cc]&[/color]in2[color=#0000cc],[/color]strptr[color=#0000cc],[/color][color=#0000ff]sizeof[/color][color=#0000cc]([/color]strptr[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡snprintf[color=#0000cc]([/color]writebuf[color=#0000cc],[/color]PACKET_SIZE[color=#0000cc],[/color][color=#ff00ff]"This arp packet catch %d times continuous\nrecorded %sethhdr\nsrchw:%s--->dsthw:%s proto:%xH
arphdr\nhwtype:%d protol:%xH hw_size:%d pro_size:%d op:%d\ns_ha:% s s_ip:%s\nd_ha:%s d_ip:%s
-----------------------------------------------------------\n"[/color][color=#0000cc],[/color]counter[color=#0000cc],[/color][color=#ff0000]ctime[/color][color=#0000cc]([/color][color=#0000cc]&[/color]temptime[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]src_hw_addr[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color]hwaddr[color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]targ_hw_addr[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]ethprotol[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ntohs[color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]hw_type[color=#0000cc])[/color][color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]prot_type[color=#0000cc])[/color][color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]hw_addr_size[color=#0000cc],[/color] arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]prot_addr_size[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#ff0000]ntohs[/color][color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]op[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]sndr_hw_addr[color=#0000cc],[/color]buf3[color=#0000cc])[/color][color=#0000cc],[/color]¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡srcaddr[color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]arphead[color=#0000cc]-[/color][color=#0000cc]>[/color]rcpt_hw_addr[color=#0000cc],[/color]buf4[color=#0000cc])[/color][color=#0000cc],[/color]dstaddr[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fwrite[color=#0000cc]([/color]writebuf[color=#0000cc],[/color][color=#ff0000]strlen[/color][color=#0000cc]([/color]writebuf[color=#0000cc])[/color][color=#0000cc],[/color]1[color=#0000cc],[/color]fd[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]void[/color] writetcpbuf[color=#0000cc]([/color][color=#ff0000]FILE[/color] [color=#0000cc]*[/color] fd[color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color]p[color=#0000cc],[/color][color=#0000ff]int[/color] counter[color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#0000ff]struct[/color] ethhdr [color=#0000cc]*[/color]eth [color=#0000cc];[/color]
[color=#0000ff]struct[/color] iphdr [color=#0000cc]*[/color] ip[color=#0000cc];[/color]
[color=#0000ff]struct[/color] tcphdr [color=#0000cc]*[/color] tcp1[color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color]flagsmes[color=#0000cc];[/color]
[color=#0000ff]int[/color] flags[color=#0000cc];[/color]
[color=#0000ff]struct[/color] [color=#ff0000]in_addr[/color] in1[color=#0000cc],[/color]in2[color=#0000cc];[/color]
[color=#0000ff]int[/color] ethprotol[color=#0000cc];[/color]
[color=#0000ff]int[/color] ihl[color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]ipfragoff[color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color] srcaddr[color=#0000cc],[/color][color=#0000cc]*[/color]dstaddr[color=#0000cc];[/color]
[color=#0000ff]int[/color] protol[color=#0000cc];[/color]
[color=#0000ff]char[/color] strptr[color=#0000cc][[/color]255[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] buf1[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc],[/color]buf2[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc];[/color]
eth[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] ethhdr [color=#0000cc]*[/color][color=#0000cc])[/color]p[color=#0000cc];[/color]
ethprotol[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_proto[color=#0000cc])[/color][color=#0000cc];[/color]
ip [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]struct[/color] iphdr [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]([/color]p[color=#0000cc]+[/color]14[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡ ihl [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]int[/color][color=#0000cc])[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl [color=#0000cc]<[/color][color=#0000cc]<[/color] 2[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡ in1[color=#0000cc].[/color]s_addr [color=#0000cc]=[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]saddr[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡ in2[color=#0000cc].[/color]s_addr [color=#0000cc]=[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]daddr[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡ srcaddr[color=#0000cc]=[/color]inet_ntoa[color=#0000cc]([/color]in1[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡ dstaddr[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc])[/color]inet_ntop[color=#0000cc]([/color][color=#ff0000]AF_INET[/color][color=#0000cc],[/color][color=#0000cc]&[/color]in2[color=#0000cc],[/color]strptr[color=#0000cc],[/color][color=#0000ff]sizeof[/color][color=#0000cc]([/color]strptr[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡[color=#ff9900]//iphdr
[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡protol[color=#0000cc]=[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]protocol[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ipfragoff[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]frag_off[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡df[color=#0000cc]=[/color]ipfragoff[color=#0000cc]&[/color]IP_DF[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mf[color=#0000cc]=[/color]ipfragoff[color=#0000cc]&[/color]IP_MF[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]df!=0[color=#0000cc])[/color] df[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]mf!=0[color=#0000cc])[/color] mf[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡ protol[color=#0000cc]=[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]protocol[color=#0000cc];[/color]
tcp1 [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]struct[/color] tcphdr [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]([/color]p[color=#0000cc]+[/color]14 [color=#0000cc]+[/color] ihl[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡flags[color=#0000cc]=[/color] tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_flags[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_PUSH[color=#0000cc])[/color]¡¡¡¡¡¡flagsmes[color=#0000cc]=[/color][color=#ff00ff]"PUSH"[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_ACK[color=#0000cc])[/color]¡¡¡¡¡¡ flagsmes[color=#0000cc]=[/color][color=#ff00ff]"ACK"[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_URG[color=#0000cc])[/color]¡¡¡¡¡¡ flagsmes[color=#0000cc]=[/color][color=#ff00ff]"URG"[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_FIN[color=#0000cc])[/color]¡¡¡¡¡¡ flagsmes[color=#0000cc]=[/color][color=#ff00ff]"FIN"[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_SYN[color=#0000cc])[/color]¡¡¡¡¡¡ flagsmes[color=#0000cc]=[/color][color=#ff00ff]"SYN"[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]flags[color=#0000cc]&[/color]TH_RST[color=#0000cc])[/color]¡¡¡¡¡¡ flagsmes[color=#0000cc]=[/color][color=#ff00ff]"RST"[/color][color=#0000cc];[/color]
temptime[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡snprintf[color=#0000cc]([/color]writebuf[color=#0000cc],[/color]PACKET_SIZE[color=#0000cc],[/color][color=#ff00ff]"This tcp packet catch %d times continuous\nrecorded %sethhdr\nsrchw:%s--->dsthw:%s proto:%xH
iphdr\nver:%d ihl:%d tos:%d tot_len:%d id:%d df:%d mf:%d fragoff:%d TTL:%d proto:%d\nsrcaddr:%s dstaddr:%s
tcphdr\nsrcport:%d dstport:%d seq:%u ack:%u off:%d flag:%s win:%d
-----------------------------------------------------------\n"[/color][color=#0000cc],[/color]counter[color=#0000cc]+[/color]1[color=#0000cc],[/color][color=#ff0000]ctime[/color][color=#0000cc]([/color][color=#0000cc]&[/color]temptime[color=#0000cc])[/color][color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_source[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_dest[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ethprotol[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]version[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tos[color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tot_len[color=#0000cc])[/color][color=#0000cc],[/color] [color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]id[color=#0000cc])[/color][color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ipfragoff[color=#0000cc]&[/color]IP_OFFMASK[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ttl[color=#0000cc],[/color]protol[color=#0000cc],[/color]srcaddr[color=#0000cc],[/color]dstaddr[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#ff0000]ntohs[/color][color=#0000cc]([/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_sport[color=#0000cc])[/color][color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_dport[color=#0000cc])[/color][color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#ff0000]ntohl[/color][color=#0000cc]([/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_seq[color=#0000cc])[/color][color=#0000cc],[/color][color=#ff0000]ntohl[/color][color=#0000cc]([/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_ack[color=#0000cc])[/color][color=#0000cc],[/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_off[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ flagsmes[color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]tcp1[color=#0000cc]-[/color][color=#0000cc]>[/color]th_win[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
[color=#ff0000]fwrite[/color][color=#0000cc]([/color]writebuf[color=#0000cc],[/color][color=#ff0000]strlen[/color][color=#0000cc]([/color]writebuf[color=#0000cc])[/color][color=#0000cc],[/color]1[color=#0000cc],[/color]fd[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]void[/color] writeigmpbuf[color=#0000cc]([/color][color=#ff0000]FILE[/color] [color=#0000cc]*[/color]fd[color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color]p[color=#0000cc],[/color][color=#0000ff]int[/color] counter[color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#0000ff]struct[/color] ethhdr [color=#0000cc]*[/color]eth [color=#0000cc];[/color]
[color=#0000ff]struct[/color] iphdr [color=#0000cc]*[/color] ip[color=#0000cc];[/color]
[color=#0000ff]struct[/color] [color=#ff0000]in_addr[/color] in1[color=#0000cc],[/color]in2[color=#0000cc];[/color]
[color=#0000ff]int[/color] ethprotol[color=#0000cc];[/color]
[color=#0000ff]int[/color] ihl[color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]ipfragoff[color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color] srcaddr[color=#0000cc],[/color][color=#0000cc]*[/color]dstaddr[color=#0000cc];[/color]
[color=#0000ff]int[/color] protol[color=#0000cc];[/color]
[color=#0000ff]char[/color] strptr[color=#0000cc][[/color]255[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] buf1[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc],[/color]buf2[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]struct[/color] igmp [color=#0000cc]*[/color] igmp1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡eth[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] ethhdr [color=#0000cc]*[/color][color=#0000cc])[/color]p[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ethprotol[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_proto[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ip [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]struct[/color] iphdr [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]([/color]p[color=#0000cc]+[/color]14[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ihl [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]int[/color][color=#0000cc])[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl [color=#0000cc]<[/color][color=#0000cc]<[/color] 2[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡in1[color=#0000cc].[/color]s_addr [color=#0000cc]=[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]saddr[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡in2[color=#0000cc].[/color]s_addr [color=#0000cc]=[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]daddr[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡srcaddr[color=#0000cc]=[/color]inet_ntoa[color=#0000cc]([/color]in1[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡dstaddr[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc])[/color]inet_ntop[color=#0000cc]([/color][color=#ff0000]AF_INET[/color][color=#0000cc],[/color][color=#0000cc]&[/color]in2[color=#0000cc],[/color]strptr[color=#0000cc],[/color][color=#0000ff]sizeof[/color][color=#0000cc]([/color]strptr[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡[color=#ff9900]//iphdr
[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡protol[color=#0000cc]=[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]protocol[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ipfragoff[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]frag_off[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡df[color=#0000cc]=[/color]ipfragoff[color=#0000cc]&[/color]IP_DF[color=#0000cc];[/color]
mf[color=#0000cc]=[/color]ipfragoff[color=#0000cc]&[/color]IP_MF[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]df!=0[color=#0000cc])[/color] df[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]mf!=0[color=#0000cc])[/color] mf[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡protol[color=#0000cc]=[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]protocol[color=#0000cc];[/color]
igmp1[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] igmp [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]([/color]p[color=#0000cc]+[/color]14[color=#0000cc]+[/color]ihl[color=#0000cc])[/color][color=#0000cc];[/color]
temptime[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡snprintf[color=#0000cc]([/color]writebuf[color=#0000cc],[/color]PACKET_SIZE[color=#0000cc],[/color][color=#ff00ff]"This packet catch %d times continuous\nrecorded %sethhdr\nsrchw:%s--->dsthw:%s proto:%xH
iphdr\nver:%d ihl:%d tos:%d tot_len:%d id:%d df:%d mf:%d fragoff:%d TTL:%d proto:%d\nsrcaddr:%s dstaddr:%s
igmphdr\ntype:%d code:%d group_addr:%s
-----------------------------------------------------------\n"[/color][color=#0000cc],[/color]counter[color=#0000cc]+[/color]1[color=#0000cc],[/color][color=#ff0000]ctime[/color][color=#0000cc]([/color][color=#0000cc]&[/color]temptime[color=#0000cc])[/color][color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_source[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_dest[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ethprotol[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]version[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tos[color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tot_len[color=#0000cc])[/color][color=#0000cc],[/color] [color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]id[color=#0000cc])[/color][color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ipfragoff[color=#0000cc]&[/color]IP_OFFMASK[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ttl[color=#0000cc],[/color]protol[color=#0000cc],[/color]srcaddr[color=#0000cc],[/color]dstaddr[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡igmp1[color=#0000cc]-[/color][color=#0000cc]>[/color]igmp_type[color=#0000cc],[/color]igmp1[color=#0000cc]-[/color][color=#0000cc]>[/color]igmp_code[color=#0000cc],[/color]inet_ntoa[color=#0000cc]([/color]igmp1[color=#0000cc]-[/color][color=#0000cc]>[/color]igmp_group[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ [color=#ff0000]fwrite[/color][color=#0000cc]([/color]writebuf[color=#0000cc],[/color][color=#ff0000]strlen[/color][color=#0000cc]([/color]writebuf[color=#0000cc])[/color][color=#0000cc],[/color]1[color=#0000cc],[/color]fd[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]void[/color] writeudpbuf[color=#0000cc]([/color][color=#ff0000]FILE[/color] [color=#0000cc]*[/color] fd[color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color]p[color=#0000cc],[/color][color=#0000ff]int[/color] counter[color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#0000ff]struct[/color] ethhdr [color=#0000cc]*[/color]eth [color=#0000cc];[/color]
[color=#0000ff]struct[/color] iphdr [color=#0000cc]*[/color] ip[color=#0000cc];[/color]
[color=#0000ff]struct[/color] [color=#ff0000]in_addr[/color] in1[color=#0000cc],[/color]in2[color=#0000cc];[/color]
[color=#0000ff]int[/color] ethprotol[color=#0000cc];[/color]
[color=#0000ff]int[/color] ihl[color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]ipfragoff[color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color] srcaddr[color=#0000cc],[/color][color=#0000cc]*[/color]dstaddr[color=#0000cc];[/color]
[color=#0000ff]int[/color] protol[color=#0000cc];[/color]
[color=#0000ff]char[/color] strptr[color=#0000cc][[/color]255[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] buf1[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc],[/color]buf2[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]struct[/color] udphdr [color=#0000cc]*[/color]udp[color=#0000cc];[/color]
eth[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] ethhdr [color=#0000cc]*[/color][color=#0000cc])[/color]p[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ethprotol[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_proto[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ip [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]struct[/color] iphdr [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]([/color]p[color=#0000cc]+[/color]14[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ihl [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]int[/color][color=#0000cc])[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl [color=#0000cc]<[/color][color=#0000cc]<[/color] 2[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡in1[color=#0000cc].[/color]s_addr [color=#0000cc]=[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]saddr[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡in2[color=#0000cc].[/color]s_addr [color=#0000cc]=[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]daddr[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡srcaddr[color=#0000cc]=[/color]inet_ntoa[color=#0000cc]([/color]in1[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡dstaddr[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc])[/color]inet_ntop[color=#0000cc]([/color][color=#ff0000]AF_INET[/color][color=#0000cc],[/color][color=#0000cc]&[/color]in2[color=#0000cc],[/color]strptr[color=#0000cc],[/color][color=#0000ff]sizeof[/color][color=#0000cc]([/color]strptr[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡[color=#ff9900]//iphdr
[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡protol[color=#0000cc]=[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]protocol[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ipfragoff[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]frag_off[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡df[color=#0000cc]=[/color]ipfragoff[color=#0000cc]&[/color]IP_DF[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mf[color=#0000cc]=[/color]ipfragoff[color=#0000cc]&[/color]IP_MF[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]df!=0[color=#0000cc])[/color] df[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]mf!=0[color=#0000cc])[/color] mf[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡protol[color=#0000cc]=[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]protocol[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡udp[color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]struct[/color] udphdr [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]([/color]p[color=#0000cc]+[/color]14 [color=#0000cc]+[/color] ihl[color=#0000cc])[/color][color=#0000cc];[/color]
temptime[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡snprintf[color=#0000cc]([/color]writebuf[color=#0000cc],[/color]PACKET_SIZE[color=#0000cc],[/color][color=#ff00ff]"This udp packet catch %d times continuous\nrecorded %sethhdr\nsrchw:%s--->dsthw:%s proto:%xH
iphdr\nver:%d ihl:%d tos:%d tot_len:%d id:%d df:%d mf:%d fragoff:%d TTL:%d proto:%d\nsrcaddr:%s dstaddr:%s
udphdr\nsport:%d dsport:%d len:%d
-----------------------------------------------------------\n"[/color][color=#0000cc],[/color]counter[color=#0000cc]+[/color]1[color=#0000cc],[/color][color=#ff0000]ctime[/color][color=#0000cc]([/color][color=#0000cc]&[/color]temptime[color=#0000cc])[/color][color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_source[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_dest[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ethprotol[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]version[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tos[color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tot_len[color=#0000cc])[/color][color=#0000cc],[/color] [color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]id[color=#0000cc])[/color][color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ipfragoff[color=#0000cc]&[/color]IP_OFFMASK[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ttl[color=#0000cc],[/color]protol[color=#0000cc],[/color]srcaddr[color=#0000cc],[/color]dstaddr[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ntohs[color=#0000cc]([/color]udp[color=#0000cc]-[/color][color=#0000cc]>[/color]uh_sport[color=#0000cc])[/color][color=#0000cc],[/color] [color=#ff0000]ntohs[/color][color=#0000cc]([/color]udp[color=#0000cc]-[/color][color=#0000cc]>[/color]uh_dport[color=#0000cc])[/color][color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]udp[color=#0000cc]-[/color][color=#0000cc]>[/color]uh_ulen[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡
[color=#ff0000]fwrite[/color][color=#0000cc]([/color]writebuf[color=#0000cc],[/color][color=#ff0000]strlen[/color][color=#0000cc]([/color]writebuf[color=#0000cc])[/color][color=#0000cc],[/color]1[color=#0000cc],[/color]fd[color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]void[/color] writeicmpbuf[color=#0000cc]([/color][color=#ff0000]FILE[/color] [color=#0000cc]*[/color] fd[color=#0000cc],[/color][color=#0000ff]char[/color] [color=#0000cc]*[/color]p[color=#0000cc],[/color][color=#0000ff]int[/color] counter[color=#0000cc])[/color]
[color=#0000cc]{[/color]
[color=#0000ff]struct[/color] ethhdr [color=#0000cc]*[/color]eth [color=#0000cc];[/color]
[color=#0000ff]struct[/color] iphdr [color=#0000cc]*[/color] ip[color=#0000cc];[/color]
[color=#0000ff]struct[/color] [color=#ff0000]in_addr[/color] in1[color=#0000cc],[/color]in2[color=#0000cc];[/color]
[color=#0000ff]int[/color] ethprotol[color=#0000cc];[/color]
[color=#0000ff]int[/color] ihl[color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]ipfragoff[color=#0000cc];[/color]
[color=#0000ff]char[/color] [color=#0000cc]*[/color] srcaddr[color=#0000cc],[/color][color=#0000cc]*[/color]dstaddr[color=#0000cc];[/color]
[color=#0000ff]int[/color] protol[color=#0000cc];[/color]
[color=#0000ff]char[/color] strptr[color=#0000cc][[/color]255[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]char[/color] buf1[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc],[/color]buf2[color=#0000cc][[/color]20[color=#0000cc]][/color][color=#0000cc];[/color]
[color=#0000ff]struct[/color] icmp [color=#0000cc]*[/color]icmphdr[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡eth[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] ethhdr [color=#0000cc]*[/color][color=#0000cc])[/color]p[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ethprotol[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_proto[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ip [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]struct[/color] iphdr [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]([/color]p[color=#0000cc]+[/color]14[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ihl [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#0000ff]int[/color][color=#0000cc])[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl [color=#0000cc]<[/color][color=#0000cc]<[/color] 2[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡in1[color=#0000cc].[/color]s_addr [color=#0000cc]=[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]saddr[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡in2[color=#0000cc].[/color]s_addr [color=#0000cc]=[/color] ip[color=#0000cc]-[/color][color=#0000cc]>[/color]daddr[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡srcaddr[color=#0000cc]=[/color]inet_ntoa[color=#0000cc]([/color]in1[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡dstaddr[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]char[/color] [color=#0000cc]*[/color][color=#0000cc])[/color]inet_ntop[color=#0000cc]([/color][color=#ff0000]AF_INET[/color][color=#0000cc],[/color][color=#0000cc]&[/color]in2[color=#0000cc],[/color]strptr[color=#0000cc],[/color][color=#0000ff]sizeof[/color][color=#0000cc]([/color]strptr[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡[color=#ff9900]//iphdr
[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡protol[color=#0000cc]=[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]protocol[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ipfragoff[color=#0000cc]=[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]frag_off[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡df[color=#0000cc]=[/color]ipfragoff[color=#0000cc]&[/color]IP_DF[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡mf[color=#0000cc]=[/color]ipfragoff[color=#0000cc]&[/color]IP_MF[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]df!=0[color=#0000cc])[/color] df[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡if [color=#0000cc]([/color]mf!=0[color=#0000cc])[/color] mf[color=#0000cc]=[/color]1[color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡protol[color=#0000cc]=[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]protocol[color=#0000cc];[/color]
icmphdr[color=#0000cc]=[/color][color=#0000cc]([/color][color=#0000ff]struct[/color] icmp [color=#0000cc]*[/color][color=#0000cc])[/color][color=#0000cc]([/color]p[color=#0000cc]+[/color]14 [color=#0000cc]+[/color] ihl[color=#0000cc])[/color][color=#0000cc];[/color]
temptime[color=#0000cc]=[/color][color=#ff0000]time[/color][color=#0000cc]([/color][color=#ff0000]NULL[/color][color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡snprintf[color=#0000cc]([/color]writebuf[color=#0000cc],[/color]PACKET_SIZE[color=#0000cc],[/color][color=#ff00ff]"This icmp packet catch %d times continuous\nrecorded %sethhdr\nsrchw:%s--->dsthw:%s proto:%xH
iphdr\nver:%d ihl:%d tos:%d tot_len:%d id:%d df:%d mf:%d fragoff:%d TTL:%d proto:%d\nsrcaddr:%s dstaddr:%s
icmp\ntype:%d code:%d
-----------------------------------------------------------\n"[/color][color=#0000cc],[/color]counter[color=#0000cc]+[/color]1[color=#0000cc],[/color][color=#ff0000]ctime[/color][color=#0000cc]([/color][color=#0000cc]&[/color]temptime[color=#0000cc])[/color][color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_source[color=#0000cc],[/color]buf1[color=#0000cc])[/color][color=#0000cc],[/color] hwaddr[color=#0000cc]([/color]eth[color=#0000cc]-[/color][color=#0000cc]>[/color]h_dest[color=#0000cc],[/color]buf2[color=#0000cc])[/color][color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ethprotol[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]version[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ihl[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tos[color=#0000cc],[/color][color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]tot_len[color=#0000cc])[/color][color=#0000cc],[/color] [color=#ff0000]ntohs[/color][color=#0000cc]([/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]id[color=#0000cc])[/color][color=#0000cc],[/color]df[color=#0000cc],[/color]mf[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ipfragoff[color=#0000cc]&[/color]IP_OFFMASK[color=#0000cc],[/color]ip[color=#0000cc]-[/color][color=#0000cc]>[/color]ttl[color=#0000cc],[/color]protol[color=#0000cc],[/color]srcaddr[color=#0000cc],[/color]dstaddr[color=#0000cc],[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡icmphdr[color=#0000cc]-[/color][color=#0000cc]>[/color]icmp_type[color=#0000cc],[/color]icmphdr[color=#0000cc]-[/color][color=#0000cc]>[/color]icmp_code[color=#0000cc])[/color][color=#0000cc];[/color]
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡fwrite[color=#0000cc]([/color]writebuf[color=#0000cc],[/color][color=#ff0000]strlen[/color][color=#0000cc]([/color]writebuf[color=#0000cc])[/color][color=#0000cc],[/color]1[color=#0000cc],[/color]fd[color=#0000cc])[/color][color=#0000cc];[/color]
[/color]