网络通信 频道

使用TCT紧急恢复并分析入侵后的系统

 从事系统管理工作,就算你非常小心翼翼地做好了一切防护,还是可能有入侵者能够突破你的防护进入系统,并且更改或者删除一些文件。这里,我们借用honeynet project里面的一些实例,来对一个unix下的实用工具软件tct及其相关辅助软件做简要说明。并且在最后再介绍另外一个比较不错的能恢复ext2文件系统的软件recover。
  
  首先说一下相关的软件:
  
  1、The Coroners Toolkit:也就是我们所说的TCT,想要在国内下载的话,您可以到安全焦点(http://xfocus.org/tool/other/tct-1.07.tar.gz)下载。这是一个unix下的命令行文件系统 工具集,支持FFS及ext2fs,从块及结点处来对数据进行恢复。它能够针对文件的最后修改、访问或者改变(MAC)的时间来进行分析,并且根据数据节点的值提取出文件列表以进行恢复。
  
  2、TCTUTILs:在http://xfocus.org/tool/other/tctutils-1.01.tar.gz可以下载当前最新 版本。它是对TCT的补充,提供了根据文件名对数据进行恢复的命令行工具。这两个工具都需要 使用者对一些底层基本知识比较了解。
  
  3、Autopsy Forensic Browser:可以从http://xfocus.org/tool/other/autopsy-1.01.tar.gz 下载。它提供了一个友好的html界面给tct及tctutils。它能使枯燥的分析工作相对轻松些:)
  
  一、安装:TCT在各种unix平台下都经过了比较好的测试
  现在能够支持FreeBSD、OpenBSD、 SunOS、Linux等平台。TCTUTILs和Autopsy则不一定能跑得起来,我测试的平台是一台默认安装 的Red Hat 6.2系统。
  
  1、tct
  
  # tar zvfx tct-1.07.tar.gz -C /usr/local/tct/; cd /usr/local/tct/tct*; make
  
  这样把tct展开到/usr/local/tct/tct-1.07/的目录下,并且进入,make。这里,如果是make 过之后,需要重新在编译的话,需要运行perl reconfig命令重新配置。
  
  2、tctutils:
  
  # tar zvfx tctutils-1.01.tar.gz -C /usr/local/
  tct;cd /usr/local/tct/tctu*;make
  
  现在tctutils似乎只在OpenBSD 2.8、Debian Linux 2.2、Solaris 2.7下经过详尽测试,而 对FreeBSD还支持不好。通常make不会出现什么问题,如果有,自己改下代码或者Makefile即可。
  3、Autopsy:
  
  解包后运行./configure后,它会自己寻找一些实用工具如grep、strings、md5sum的路径, 并要求确认tct以及tctutils的路径(如果没找到会要求你输入正确路径)。最后要求输入需要检 查的文件系统所在,才生成程序autopsy。
  
  二、honeynet scan15简介:
  关于honeynet project的详情,可以参见安全焦点(http://xfocus.org/honeynet/),他们 现在维护着国外honeynet项目的中文镜像。
  
  scan15是honeynet在2001年3月15日于一台受入侵的Linux机器上搜集到的数据而面临的问题。
  
  入侵者下载了一些rootkit放在根目录下,成功安装后删除了。而honeynet project将当时的原始 数据镜像下来,作为题目出给网络安全爱好者,要求对这一被删除的rootkit进行恢复。
  
  详情可以参见http://xfocus.org/honeynet/scans/。
  
  根据要求,我下载了honeynet.tar.gz的包,约13M,解压后是一个270M左右的文件honeypot.hda8.dd
  
  及一个README文件,README如下:
  
  SUMMARY
  -------
  You have download the / partition of a compromised RH 6.2
  Linux box. Your mission is to recover the deleted rootkit
  from the / partition. Below are a list of all the partitions
  that made up the compromised system.
  
  /dev/hda8 / <----- The partition you downloaded
  /dev/hda1 /boot
  /dev/hda6 /home
  /dev/hda5 /usr
  /dev/hda7 /var
  /dev/hda9 swap
  
  - The Honeynet Project
  http://project.honeynet.org
  
  任务非常明确。
  
  三、操作过程
  1、确认下载数据无误
  
  # md5sum honeynet.tar.gz
  0dff8fb9fe022ea80d8f1a4e4ae33e21 honeynet.tar.gz
  # md5sum honeypot.hda8.dd
  5a8ebf5725b15e563c825be85f2f852e honeypot.hda8.dd
  
  这些md5校验值同honeynet网站上贴出来的一样,说明文件下载无误,未经篡改。
  
  2、将下载下来的镜像挂接到系统上
  
  # mount honeypot.hda8.dd /mnt/ -oloop,ro
  
  3、配置autopsy并运行之(其实在上面autopsy的configure过程中就做这步了)
  
  [root@test autopsy-1.01]# ./configure
  Autopsy Forensic Browser v.1.01 Installation
  MD5 found: /usr/bin/md5sum
  strings found: /usr/bin/strings
  grep found: /bin/grep
  Enter TCT Directory:
  /usr/local/tct
  TCT bin directory was found
  Enter TCTUTILs Directory:
  /usr/local/tctutils
  TCTUTILs bin directory was found
  Enter Morgue Directory:
  /home/inburst
  Enter Default Investigator Name (for the Autopsy Reports):
  inburst
  Settings saved to conf.pl
  [root@test autopsy-1.01]#
  
  然后进入/home/inburst/,你存放honeypot.hda8.dd的地方,编辑文件fsmorgue,使其看来象下面这样:
  
  # fsmorgue file for Autopsy Forensic Browser
  #
  # local_file name can contain letters, digits, ''-'', ''_'', and ''.''
  #
  # local_file mount_point
  honeypot.hda8.dd /mnt/
  
  并且编辑zoneinfo,确定时间信息。
  
  然后可以运行命令:
  
  # ./autopsy 9999 192.168.168.130
  
  这里192.168.168.130是我所用的工作机,9999是端口号,屏幕上会输出:
  
  Autopsy Forensic Browser ver 1.01
  Investigator: inburst
  
  Paste this as your browser URL on 192.168.168.130:
  192.168.168.130:9999/1727589285/autopsy
  
  将192.168.168.130:9999/1727589285/autopsy粘贴到你的浏览器url里,就可以开始进一步的分析了。
  
  4、恢复被删除的rootkit,这里我们先纯用命令行来解决问题,其实利用autopsy可以令这些麻烦事看起来相对直观些。
  
  a、搜集信息
  
  # ils honeypot.hda8.dd > ilsdump.txt
  # cat ilsdump.txt
  class|host|device|start_time
  ils|test.inburst.com.cn|honeypot.hda8.dd|992134159
  st_ino|st_alloc|st_uid|st_gid|st_mtime|st_atime|st_ctime|st_dtime
  |st_mode|st_nlink|st_size|st_block0|st_block1
  23|f|0|0|984706608|984707090|984707105|984707105|100644|0|520333|307|308
  2038|f|1031|100|984707105|984707105|984707105|984707169|40755|0|0|8481|0
  ……
  ……
  ils命令是用来显示inode信息的,它显示了每个被删除的文件节点的原始资料。上面显示的第一个域是结点号。后面数据恢复时需要用到,关于这个输出的详细信息如下:
  
  st_ino:The inode number.
  st_alloc:Allocation status: `a'' for allocated inode, `f'' for free inode.
  st_uid:Owner user ID.
  st_gid:Owner group ID.
  st_mtime:UNIX time (seconds) of last file modification.
  st_atime:UNIX time (seconds) of last file access.
  st_ctime:UNIX time (seconds) of last inode status change.
  st_dtime:UNIX time (seconds) of file deletion (LINUX only).
  st_mode:File type and permissions (octal).
  st_nlink:Number of hard links.
  st_size:File size in bytes.
  st_block0,st_block1:The first two entries in the direct block address list.
  # /usr/local/tct/extras/ils2mac ilsdump.txt > deletedfiles.txt
  # cat deletedfiles.txt
  class|host|device|start_time
  body|test.inburst.com.cn|honeypot.hda8.dd|992134159
  md5|file|st_dev|st_ino|st_mode|st_ls|st_nlink|st_uid|st_gid|st_rdev|st_size
  |st_atime|st_mtime|st_ctime|st_blksize|st_blocks
  |||23|100644|-rw-r--r--|0|0|0||520333|984707090|984706608|984707105||
  |||2038|40755|drwxr-xr-x|0|1031|100||0|984707105|984707105|984707105||
  |||2039|100755|-rwxr-xr-x|0|0|0||611931|984707090|1013173693|984707105||
  |||2040|100644|-rw-r--r--|0|0|0||1|984707090|983201398|984707105||
  ……
  ……
  ils2mac重新排列输出了上面的信息,这在你有多个磁盘分区需要分析时比较有用。
  
  # mactime -p /mnt/etc/passwd -g /mnt/etc/group -b
  deletedfiles.txt 1/1/2001 > mactime.txt
  # cat mactime.txt
  Feb 08 02 21:08:13 611931 m.. -rwxr-xr-x root root
  Jan 27 01 23:11:32 3278 m.. -rw-r--r-- root root
  Jan 27 01 23:11:44 11407 m.. -rw-r--r-- root root
  Feb 26 01 22:46:04 632066 m.. -rwxr-xr-x root root
  Feb 26 01 23:22:55 4060 m.. -rwxr-xr-x root root
  Feb 26 01 23:22:59 8268 m.. -rwx------ root root
  Feb 26 01 23:23:10 4620 m.. -rwxr-xr-x root root

文章转载地址:http://www.cnpaf.net/Class/hack/06101110492239392711.html

0
相关文章