[ 永远的UNIX::UNIX技术资料的宝库 ]

首页 > 网络安全 > b7 > 正文

族群式DDOS(Tribe Flood Network)攻击

来源:不详 (2001-05-19 07:00:00)


David Dittrich 
University of Washington
Copyright 1999. All rights reserved.
October 21, 1999 

翻译:snowblue
您可以在http://staff.washington.edu/dittrich/misc/tfn.analysis 得到原文 

介绍:
以下是关于族群式拒绝服务攻击(Tribe Flood Network),简称TFN,的分析。TFN何另一种DDOS攻击工具trinoo已在相当数量的Unix系统上获得实现。关于trinoo的分析可以参见另一篇文章。
TFN由客户机(client)和端口监控程序(daemon)构成,可用来实现分布式拒绝服务攻击,这种攻击可以是基于ICMP,SYN,UDP,或者是Smurf风格的,并提供一个绑定在TCP端口上的即时响应的命令管理器。
TFN的端口监控程序(daemon)最初以二进制的形式在相当数量的Solaris 2.x系统上被发现,被证明可以利用RPC服务"statd","cmsd"和 "ttdbserverd"的缓冲溢出漏洞。在CERT的Note 99-04种有这种攻击的描述:
http://www.cert.org/incident_notes/IN-99-04.html
这些端口监控器原来被认为是某种形式的远程嗅探器或访问控制器的命令解释器,可能是用来和嗅探器进行联系以自动恢复嗅探纪录的。
在相关入侵的调查中,我们发现了一起使用trinoo network(另一种DDOS攻击工具,在另一篇文章中有介绍)的DDOS攻击,并且我们得到了trinoo和TFN的源代码。一下的分析是基于这份源代码("version 1.3 build 0053")和对较新的端口监控程序的编译版本的观察而得到的。
对这份原代码的改动将导致以下分析细节的改变,如提示符,密码,命令,TCP/UDP端口号,或者所提供的进攻手段,特征和功能。
端口监控端和客户端是在Red Hat Linux 6.0系统上被编译和运行的。
如果想要对系统的初始入侵和网络的设置过程,可以参见对trinoo网络的分析。(您可以在网络论坛www.s8s8.net 得到他,我把它贴在了高级版) 

网络:
attacker(s)-->client(s)-->daemon(s)-->victim(s) 

FTN网络是由tribe的客户端程序(tribe.c)和tribe的端口监控端(td.c)组成的。一个TFN网络看起来应当是这样的: 


+----------+ +----------+
| attacker | | attacker |
+----------+ +----------+
| |
. . . --+------+---------------+------+----------------+-- . . .
| | |
| | |
+----------+ +----------+ +----------+
| client | | client | | client |
+----------+ +----------+ +----------+
| | |
| | |
. . . ---+------+-----+------------+---+--------+------------+-+-- . . .
| | | | |
| | | | |
+--------+ +--------+ +--------+ +--------+ +--------+
| daemon | | daemon | | daemon | | daemon | | daemon |
+--------+ +--------+ +--------+ +--------+ +--------+
攻击者控制一个或多个客户端,每一个客户端能够控制许多端口监控程序。端口监控端可以接受客户端的指示对目标系统进行基于信息包的进攻。 

通讯:
TFN网络的远程控制是通过客户端程序的命令行方式来执行的,连接可以有许多方法(例如,将shell绑定于TCP端口,基于UDP的客户/服务器的shell,基于ICMP的客户服务器的shell如LOKI,SSH终端会话工具,或者就是普通的telnet的TCP终端会话。)
运行客户端是不需要密码的,尽管你必须有一个所有的端口监控程序的IP列表文件。
TFN的客户端和端口监控端之间的通讯是通过ICMP_ECHOREPLY包来完成的。在客户端和端口监控端之间根本就没有基于TCP或UDP的通讯。(一些网络监视工具不显示ICMP包的数据部分,或者不去分析所有大量的ICMP数据,所以实际监控客户端和端口监控端之间的通讯或许是困难的。参见附录A关于Sniffit version 0.3.7.beta的补丁,使它可以显示ICMP的数据段,和附录B关于tcpshow.c 1.0的补丁,使它可以显示ICMP_ECHO 和 ICMP_ECHOREPLY id和顺序号。
如果运行程序时不带任何选项和参数,你将会得到帮助,这将告诉你TFN所支持的命令:
[tribe flood network] (c) 1999 by Mixter 

usage: ./tfn   [ip] [port]
 contains a list of numerical hosts that are ready to flood
 -1 for spoofmask type (specify 0-3), -2 for packet size,
is 0 for stop/status, 1 for udp, 2 for syn, 3 for icmp,
4 to bind a rootshell (specify port)
5 to smurf, first ip is target, further ips are broadcasts
[ip] target ip[s], separated by @ if more than one
[port] must be given for a syn flood, 0 = RANDOM 

密码保护
客户端是不受密码保护的,每一条被发向端口监控端的命令都是以16比特二进制数的形式被存放于ICMP_ECHOREPLY包的id字段。(顺序字段是一个0x0000的常量,这是他看起来像是由ping命令发出的初始信息包。)
这些数字所表示的值是由”config.h”文件所定义的:
#ifndef _CONFIG_H 

/* user defined values for the teletubby flood network */ 

#define HIDEME "tfn-daemon"
#define HIDEKIDS "tfn-child"
#define CHLD_MAX 50 

/* #define ATTACKLOG "attack.log" keep a log of attacks/victims on all
hosts running td for debugging etc. (hint: bad idea) */ 

/* These are like passwords, you might want to change them */ 

#define ID_ACK 123 /* for replies to the client */
#define ID_SHELL 456 /* to bind a rootshell, optional */
#define ID_PSIZE 789 /* to change size of udp/icmp packets */
#define ID_SWITCH 234 /* to switch spoofing mode */
#define ID_STOPIT 567 /* to stop flooding */
#define ID_SENDUDP 890 /* to udp flood */
#define ID_SENDSYN 345 /* to syn flood */
#define ID_SYNPORT 678 /* to set port */
#define ID_ICMP 901 /* to icmp flood */
#define ID_SMURF 666 /* haps! haps! */ 

#define _CONFIG_H
#endif 

正如你所看到的,建议最好改变上面的值,这样可以防止偶然发现端口监控端的人执行命令。 

痕迹:
就像trinoo一样,用来安装客户端/监控端的方法就和在Unix系统上安装其他程序的方法一样。
客户端和监控端都必须以管理员的身份来运行,这样他们才能在SOCK_RAW模式下打开AF_INET接口。
客户端程序需要被提供一张ip列表,所以发现一个客户端就可以得到监控端的列表(原文这里是说得到客户端的列表,怀疑是笔误 ^_^)。最近对TFN监控端的安装指出作者以对IP列表文件进行了Blowfish编码。这就使得到端口监控端位置的工作变得难了。
一下是嵌入到TFN监控端二进制文件中的字串(已被编辑和重新整理,右端为注释):
blowfish_init
blowfish_encipher
blowfish_decipher 使用Blowfish 进行编码
encrypt_string
decrypt_string 

serverworks
readmservers
addnewmserver 客户/服务器的高级功能
delmserver
servcounti 

icmp2
udppsize
icmpsize
spoofing
spooftest
commence_icmp 进攻的标记
commence_udp
commence_syn
floodtime
floodruns 

bind
setsockopt 远程管理功能
listensocket 

k00lip
fw00ding
k00lntoa
tc: unknown host
rm -rf %s
ttymon
rcp %s@%s:sol.bin %s 嵌入的命令用来上传文件,
nohup ./%s 删除文件,和一个特别的IP相联系
130.243.70.20 (可能是客户端,或者某个文件的位置)
127.0.0.1
lpsched
sicken
in.telne 

如果”lsof”别用来检查运行中的监控程序,他只会显示一个未详细说明协议的开放接口:
td 5931 root cwd DIR 3,5 1024 240721
/usr/lib/libx/...
td 5931 root rtd DIR 3,1 1024 2 /
td 5931 root txt REG 3,5 297508 240734
/usr/lib/libx/.../td
td 5931 root 3u sock 0,0 92814 can't
identify protocol 

如果远程的shell已经启动,监控程序将会分支并显示出一个新的进程正在监听TCP端口:
td 5970 root cwd DIR 3,5 1024 240721
/usr/lib/libx/...
td 5970 root rtd DIR 3,1 1024 2 /
td 5970 root txt REG 3,5 297508 240734
/usr/lib/libx/.../td (deleted)
td 5970 root 0u inet 92909 TCP
*:12345 (LISTEN)
td 5970 root 3u sock 0,0 92814 can't
identify protocol 

使用"sniffit"监视网络通话(附录A中修改过的),并且运行"ping -c 3 10.0.0.1"(发送三个ICMP_ECHO包,等待ICMP_ECHOREPLY包的返回,并退出)看起来像这样(为了更明确的表示,删除了IP头):
# sniffit -d -a -x -b -s @ -Picmp
Supported Network device found. (eth0)
Sniffit.0.3.7 Beta is up and running.... (192.168.0.1) 

ICMP message id: 192.168.0.1 > 10.0.0.1
ICMP type: Echo request
.. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
.. . .. . .. . .. . 08 . 00 . 2B + 51 Q 98 . 04 . 00 . 00 . 37 7 FC . 0D . 38 8
02 . 73 s 02 . 00 . 08 . 09 . 0A . 0B . 0C . 0D . 0E . 0F . 10 . 11 . 12 . 13 .
14 . 15 . 16 . 17 . 18 . 19 . 1A . 1B . 1C . 1D . 1E . 1F . 20 21 ! 22 " 23 #
24 $ 25 % 26 & 27 ' 28 ( 29 ) 2A * 2B + 2C , 2D - 2E . 2F / 30 0 31 1 32 2 33 3
34 4 35 5 36 6 37 7 

ICMP message id: 10.0.0.1 > 192.168.0.1
ICMP type: Echo reply
.. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
.. . .. . .. . .. . 00 . 00 . 33 3 51 Q 98 . 04 . 00 . 00 . 37 7 FC . 0D . 38 8
02 . 73 s 02 . 00 . 08 . 09 . 0A . 0B . 0C . 0D . 0E . 0F . 10 . 11 . 12 . 13 .
14 . 15 . 16 . 17 . 18 . 19 . 1A . 1B . 1C . 1D . 1E . 1F . 20 21 ! 22 " 23 #
24 $ 25 % 26 & 27 ' 28 ( 29 ) 2A * 2B + 2C , 2D - 2E . 2F / 30 0 31 1 32 2 33 3
34 4 35 5 36 6 37 7 

ICMP message id: 192.168.0.1 > 10.0.0.1
ICMP type: Echo request
.. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
.. . .. . .. . .. . 08 . 00 . 58 X 61 a 98 . 04 . 01 . 00 . 38 8 FC . 0D . 38 8
D3 . 62 b 02 . 00 . 08 . 09 . 0A . 0B . 0C . 0D . 0E . 0F . 10 . 11 . 12 . 13 .
14 . 15 . 16 . 17 . 18 . 19 . 1A . 1B . 1C . 1D . 1E . 1F . 20 21 ! 22 " 23 #
24 $ 25 % 26 & 27 ' 28 ( 29 ) 2A * 2B + 2C , 2D - 2E . 2F / 30 0 31 1 32 2 33 3
34 4 35 5 36 6 37 7 

ICMP message id: 10.0.0.1 > 192.168.0.1
ICMP type: Echo reply
.. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
.. . .. . .. . .. . 00 . 00 . 60 ` 61 a 98 . 04 . 01 . 00 . 38 8 FC . 0D . 38 8
D3 . 62 b 02 . 00 . 08 . 09 . 0A . 0B . 0C . 0D . 0E . 0F . 10 . 11 . 12 . 13 .
14 . 15 . 16 . 17 . 18 . 19 . 1A . 1B . 1C . 1D . 1E . 1F . 20 21 ! 22 " 23 #
24 $ 25 % 26 & 27 ' 28 ( 29 ) 2A * 2B + 2C , 2D - 2E . 2F / 30 0 31 1 32 2 33 3
34 4 35 5 36 6 37 7 

ICMP message id: 192.168.0.1 > 10.0.0.1
ICMP type: Echo request
.. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
.. . .. . .. . .. . 08 . 00 . 70 p 61 a 98 . 04 . 02 . 00 . 39 9 FC . 0D . 38 8
B9 . 62 b 02 . 00 . 08 . 09 . 0A . 0B . 0C . 0D . 0E . 0F . 10 . 11 . 12 . 13 .
14 . 15 . 16 . 17 . 18 . 19 . 1A . 1B . 1C . 1D . 1E . 1F . 20 21 ! 22 " 23 #
24 $ 25 % 26 & 27 ' 28 ( 29 ) 2A * 2B + 2C , 2D - 2E . 2F / 30 0 31 1 32 2 33 3
34 4 35 5 36 6 37 7 

ICMP message id: 10.0.0.1 > 192.168.0.1
ICMP type: Echo reply
.. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
.. . .. . .. . .. . 00 . 00 . 78 x 61 a 98 . 04 . 02 . 00 . 39 9 FC . 0D . 38 8
B9 . 62 b 02 . 00 . 08 . 09 . 0A . 0B . 0C . 0D . 0E . 0F . 10 . 11 . 12 . 13 .
14 . 15 . 16 . 17 . 18 . 19 . 1A . 1B . 1C . 1D . 1E . 1F . 20 21 ! 22 " 23 #
24 $ 25 % 26 & 27 ' 28 ( 29 ) 2A * 2B + 2C , 2D - 2E . 2F / 30 0 31 1 32 2 33 3
34 4 35 5 36 6 37 7 

正如你所看到的,一个固定的有效负载(第17字节)被ICMP_ECHO包送往目标机,同样的有效负载被ICMP_ECHOREPLY包返回。初始的包有一个顺序号0(在ICMP包的第7和第8字节),每发送一个包便加一。
通过tcpdump/tcpshow(附录B中修改过的)可以看到,三个由”ping”发出的信息流应当是这样:
# tcpdump -lenx -s 1518 icmp | tcpshow -noip -nolink -cooked
tcpdump: listening on eth0
# tcpdump -lenx -s 1518 icmp | tcpshow -noip -nolink -cooked
tcpdump: listening on eth0
Packet 1
ICMP Header
Type: echo-request
Checksum: 0x9B2A
Id: 0x6E03
Sequence: 0x0000
ICMP Data
q..8x.
..
..................... !"#$%&'()*+,-./01234567
-----------------------------------------------------------------
Packet 2
ICMP Header
Type: echo-reply
Checksum: 0xA32A
Id: 0x6E03
Sequence: 0x0000
ICMP Data
q..8x.
..
..................... !"#$%&'()*+,-./01234567
-----------------------------------------------------------------
Packet 3
ICMP Header
Type: echo-request
Checksum: 0x623A
Id: 0x6E03
Sequence: 0x0001
ICMP Data
r..8..
..
..................... !"#$%&'()*+,-./01234567
-----------------------------------------------------------------
Packet 4
ICMP Header
Type: echo-reply
Checksum: 0x6A3A
Id: 0x6E03
Sequence: 0x0001
ICMP Data
r..8..
..
..................... !"#$%&'()*+,-./01234567
-----------------------------------------------------------------
Packet 5
ICMP Header
Type: echo-request
Checksum: 0x5A3A
Id: 0x6E03
Sequence: 0x0002
ICMP Data
s..8..
..
..................... !"#$%&'()*+,-./01234567
-----------------------------------------------------------------
Packet 6
ICMP Header
Type: echo-reply
Checksum: 0x623A
Id: 0x6E03
Sequence: 0x0002
ICMP Data
s..8..
..
..................... !"#$%&'()*+,-./01234567
-----------------------------------------------------------------
TFN客户端,另一方面,使用ICMP_ECHOREPLY包替代ICMP_ECHO来向端口监控端发送命令。这是为了防止监控端的系统返回一个ICMP_ECHOREPLY包。端口监控端然后回应(如果必须)客户端,也是使用ICMP_ECHOREPLY包。有效负载和TFN不同,由于这是用来发送命令参数和进行应答的。
ICMP_ECHOREPLY包的id端包含有要执行的命令(16比特)参数以明文ASCII码的形式放在包的数据段中。
这是一个攻击者在执行一个命令时可以看到的,这个命令用来在12345端口上监听:
# ./tfn iplist 4 12345
[tribe flood network] (c) 1999 by Mixter 

[request: bind shell to port 12345]
192.168.0.1: shell bound to port 12345


这是用"sniffit"看到的当这条命令在网络上传播时的情况(IP头以被删除):
ICMP message id: 10.0.0.1 > 192.168.0.1
ICMP type: Echo reply
.. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
.. . .. . .. . .. . 00 . 00 . 64 d D1 . 01 . C8 . 00 . 00 . 31 1 32 2 33 3 34 4
35 5 00 . 

ICMP message id: 192.168.0.1 > 10.0.0.1
ICMP type: Echo reply
.. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. . .. .
.. . .. . .. . .. . 00 . 00 . 6C l AE . 00 . 7B { 00 . 00 . 73 s 68 h 65 e 6C l
6C l 20 62 b 6F o 75 u 6E n 64 d 20 74 t 6F o 20 70 p 6F o 72 r 74 t 20
31 1 32 2 33 3 34 4 35 5 0A . 00 . 

使用tcpdump单独查看,应当是这样(IP头已删除):
# tcpdump -lnx -s 1518 icmp
tcpdump: listening on eth0
05:51:32.706829 10.0.0.1 > 192.168.0.1: icmp: echo reply
.... .... .... .... .... .... .... ....
.... .... 0000 64d1 01c8 0000 3132 3334
3500
05:51:32.741556 192.168.0.1 > 10.0.0.1: icmp: echo reply
.... .... .... .... .... .... .... ....
.... .... 0000 6cae 007b 0000 7368 656c
6c20 626f 756e 6420 746f 2070 6f72 7420
3132 3334 350a 00 

将tcpdump和tcpshow组合使用,更容易看到数据有效负载:
Packet 1
ICMP Header
Type: echo-reply
Checksum: 0x64D1
Id: 0x01C8
Sequence: 0x0000
ICMP Data
12345
-----------------------------------------------------------------
Packet 2
ICMP Header
Type: echo-reply
Checksum: 0x6CAE
Id: 0x007B
Sequence: 0x0000
ICMP Data
shell bound to port 12345
----------------------------------------------------------------------------
正如所看到的,客户端发送命令0x01c8(十进制456)包含于id段,随后是一个顺序号0x0000(在代码中始终是0),随后是ASCII字串12345(定义的端口号),被发送到端口监控程序。
端口监控端用包含于id段的命令0x007B(十进制123)回应,随后是顺序号0x0000,随后是ASCII字串"shell bound to port 12345\n"。这条字串随后被客户端同监控端的IP地址一起发送给shell。 

防御:
由于程序使用ICMP_ECHOREPLY包来通讯,想要防止它而又不影响其他依赖ICMP的程序是非常困难的。唯一可行的阻止通讯的方法是拒绝想要进入你网络中的所有ICMP_ECHO通信。
如果不能拒绝这种通讯,那就必须区分出普通使用ICMP_ECHO和由ping这样的程序使用的ICMP_ECHOREPLY包之间的区别。这将不是一件简单的工作,尤其是在大型的网络上。(详细情况参见LOKI paper) 

弱点:
如果代码没有被改动,你可以通过观察下面的字串来识别TFN的客户端和端口监控端,这些字串是嵌在程序中的:
# strings - td
. . .
%d.%d.%d.%d
/bin/sh
tfn-daemon
already %s flooding
multiple targets
ICMP flood: %s
tfn-child
SMURF (target@bcast@...): %s
UDP flood: %s
SYN flood: port %d, multiple targets
SYN flood: port %d, %s
ready - size: %d spoof: %d
%s flood terminated
packet size: %d bytes
spoof mask: *.*.*.* (%s)
spoof mask: 1.*.*.* (%s)
spoof mask: 1.1.*.* (%s)
spoof mask: 1.1.1.* (%s)
spoof test: %s
shell bound to port %s
. . .
[0;35m[tribe flood network]
(c) 1999 by
[5mMixter
ICMP
SMURF
. . . 

# strings - tfn
. . .
%d.%d.%d.%d
ERROR reading IP list
[1;37m
[request: change packet size]
[request: change spoofmask]
[request: stop and display status]
[request: udp flood %s]
[request: syn flood [port: %s] %s]
[request: icmp flood %s]
[request: bind shell to port %s]
[request: smurf (target@bcast@...) %s]
[0;0m
[0m%s:
[0;31m
[0;34mtimeout
[1;34m
usage: %s   [ip] [port]
 contains a list of numerical hosts that are ready to flood
 -1 for spoofmask type (specify 0-3), -2 for packet size,
is 0 for stop/status, 1 for udp, 2 for syn, 3 for icmp,
4 to bind a rootshell (specify port)
5 to smurf, first ip is target, further ips are broadcasts
[ip] target ip[s], separated by %s if more than one
[port] must be given for a syn flood, 0 = RANDOM
skipping
[0;35m[tribe flood network]
(c) 1999 by
[5mMixter
. . . 

一些近期版本的程序中包含的字串表明新的代码有了multi-master(替代了单独的客户端)的能力,比如trinoo,和对ip列表文件的编码(推测),masters的列表,甚至有可能对ICMP包的数据部分进行编码。
较新的版本使用了Berkeley "rcp"命令。在你的网络上监视”rcp”连接,这些连接应当是快速而连续的,同时是指向网络外的一个IP地址,将是一个好方法。
由于TFN使用了ICMP数据包,要检测出它是相当困难的,并且这些包可以穿透大多数的防火墙。像"ngrep"这样的程序不检测ICMP数据包,所以你不可能简单的在ICMP的数据段中搜寻字串。
TFN的一个弱点是他不对源ICMP包进行验证(至少在这次分析的代码中没有)。如果命令值仍然是默认值,只需一个信息包就可以关闭一个端口监控程序。(一个叫"civilize"的使用Net::RawIP的Perl脚本可以用来完成这项工作。参见附录C)。
如果命令的值已经被修改,你仍然可以强制发送所有命令的组合(id段是16比特,所以确切的大小应该是64K)。这足以构成一次ICMP淹没攻击(ICMP flood attack),但这仍然是一个可以被利用的潜在的弱点。 

演化及发展:
关于DDOS工具的演化,参见对于trinoo的分析。
--
David Dittrich  http://staff.washington.edu/dittrich/ 

附录A:sniffit v. 0.3.7.beta的补丁,可以显示ICMP的数据负载
------------------------------------------------------------------------- 

------------------------------- cut here -----------------------------------
diff -c sniffit.0.3.7.beta.orig/sn_defines.h sniffit.0.3.7.beta/sn_defines.h
*** sniffit.0.3.7.beta.orig/sn_defines.h Wed Aug 26 12:21:23 1998
--- sniffit.0.3.7.beta/sn_defines.h Wed Oct 20 10:15:41 1999
***************
*** 126,132 ****
#define ICMP_TYPE_3 "Destination unreachable"
#define ICMP_TYPE_4 "Source quench"
#define ICMP_TYPE_5 "Redirect"
! #define ICMP_TYPE_8 "Echo"
#define ICMP_TYPE_11 "Time exceeded"
#define ICMP_TYPE_12 "Parameter problem"
#define ICMP_TYPE_13 "Timestamp"
--- 126,132 ----
#define ICMP_TYPE_3 "Destination unreachable"
#define ICMP_TYPE_4 "Source quench"
#define ICMP_TYPE_5 "Redirect"
! #define ICMP_TYPE_8 "Echo request"
#define ICMP_TYPE_11 "Time exceeded"
#define ICMP_TYPE_12 "Parameter problem"
#define ICMP_TYPE_13 "Timestamp"
***************
*** 134,140 ****
#define ICMP_TYPE_15 "Information request"
#define ICMP_TYPE_16 "Information reply"
#define ICMP_TYPE_17 "Address mask request"
! #define ICMP_TYPE_18 "Adress mask reply"

/*** Services (standardised) *******************************************/
#define FTP_DATA_1 20
--- 134,140 ----
#define ICMP_TYPE_15 "Information request"
#define ICMP_TYPE_16 "Information reply"
#define ICMP_TYPE_17 "Address mask request"
! #define ICMP_TYPE_18 "Address mask reply"

/*** Services (standardised) *******************************************/
#define FTP_DATA_1 20
diff -c sniffit.0.3.7.beta.orig/sniffit.0.3.7.c sniffit.0.3.7.beta/sniffit.0.3.7.c
*** sniffit.0.3.7.beta.orig/sniffit.0.3.7.c Wed Aug 26 12:21:25 1998
--- sniffit.0.3.7.beta/sniffit.0.3.7.c Wed Oct 20 10:15:49 1999
***************
*** 1333,1339 ****
printf ("Unknown ICMP type!\n");
break;
}
! printf ("\n");
return;
}
if (finish < 30) /* nothing yet */
--- 1333,1351 ----
printf ("Unknown ICMP type!\n");
break;
}
! total_length = info.IP_len + info.ICMP_len + info.DATA_len;
! n = 0;
! for (i = 0; i < total_length; i++)
! {
! unsigned char c = sp[PROTO_HEAD + i];
! if (n > 75)
! n = 0, printf ("\n");
! if (DUMPMODE & 1)
! n += printf (" %02X", c);
! if (DUMPMODE & 2)
! n += printf (" %c", isprint (c) ? c : '.');
! }
! printf ("\n\n");
return;
}
if (finish < 30) /* nothing yet */
------------------------------- cut here ----------------------------------- 

附录B:tcpshow 1.0的补丁,显示CMP ECHO id/seq
---------------------------------------------------------------------- 

------------------------------- cut here -----------------------------------
diff -c tcpshow.c.orig tcpshow.c
*** tcpshow.c.orig Thu Oct 21 14:12:19 1999
--- tcpshow.c Thu Oct 21 14:22:34 1999
***************
*** 1081,1086 ****
--- 1081,1088 ----
uint2 nskipped;
uint1 type;
char *why;
+ uint2 echo_id;
+ uint2 echo_seq;


type = getbyte(&pkt); nskipped = sizeof(type);
***************
*** 1091,1096 ****
--- 1093,1103 ----
/* Must calculate it from the size of the IP datagram - the IP header. */
datalen -= ICMPHDRLEN;

+ if (type == ECHO_REQ || type == ECHO_REPLY) {
+ echo_id = getword(&pkt); nskipped += sizeof(cksum);
+ echo_seq = getword(&pkt); nskipped += sizeof(cksum);
+ }
+
why = icmpcode(type, code);
if (dataflag) {
printf(
***************
*** 1113,1118 ****
--- 1120,1129 ----
icmptype(type), why? "\n\tBecause:\t\t\t": "", why? why: ""
);
printf("\tChecksum:\t\t\t0x%04X\n", cksum);
+ if (type == ECHO_REQ || type == ECHO_REPLY) {
+ printf("\tId:\t\t\t\t0x%04X\n", echo_id);
+ printf("\tSequence:\t\t\t0x%04X\n", ntohs(echo_seq));
+ }
}

return pkt;
------------------------------- cut here ----------------------------------- 

附录C:控制TFN端口监控端的Perl脚本"civilize"
---------------------------------------------------------- 

------------------------------- cut here -----------------------------------
#!/usr/bin/perl
#
# civilize v. 1.0
# By Dave Dittrich 
#
# Send commands to TFN daemon(s), causing them to do things like
# spawn shells, stop floods and report status, etc. Using this program
# (and knowledge of the proper daemon "passwords"), you can affect TFN
# daemons externally and monitor packets to verify if a daemon is
# running, etc. You can also brute force attack the "passwords" by
# sending packets until you get the desired reply (or give up.)
#
# Needs Net::RawIP (http://quake.skif.net/RawIP)
# Requires libpcap (ftp://ftp.ee.lbl.gov/libpcap.tar.Z)
#
# Example: ./civilize [options] host1 [host2 [...]]
#
# (This code was hacked from the "macof" program, written by
# Ian Vitek 

require 'getopts.pl';
use Net::RawIP;
require 'netinet/in.ph'; 

$a = new Net::RawIP({icmp => {}});
chop($hostname = `hostname`); 

Getopts('a:c:f:i:vh');
die "usage: $0 [options] iplist\
\t-a arg\t\tSend command argument 'arg' (default \"12345\")\
\t-c val\t\tSend command value 'val' (default 456 - spawn a shell)\
\t-f from_host\t\t(default:$hostname)\
\t-i interface \t\tSet sending interface (default:eth0)\
\t-v\t\t\tVerbose\
\t-h This help\n" unless ( !$opt_h ); 

# set default values
$opt_i = ($opt_i) ? $opt_i : "eth0";
$opt_a = ($opt_a) ? $opt_a : "12345";
$opt_c = ($opt_c) ? $opt_c : "456"; 

# choose network card
if($opt_e) {
$a->ethnew($opt_i, dest => $opt_e);
} else {
$a->ethnew($opt_i);


$s_host = ($opt_h) ? $opt_h : $hostname; 

if ($ARGV[0]) {
open(I,"<$ARGV[0]") || die "could not open file: '$ARGV[0]'";
while () {
chop;
push(@list,$_);
}
close(I);


(http://www.fanqiang.com)



 
 相关文章

★  感谢所有的作者为我们学习技术知识提供了一条捷径  ★
www.fanqiang.com