获得shell之后需要枚举出系统项决定从哪里入手开始提权,当不清楚原理时很容易遗漏关键信息。

Linux提权原理篇

手工枚举流程:

查看用户信息:

//查看当前用户
whoami
id

//查看其他用户信息
id username
//username是你知晓的用户名例如root

//查看当前登录用户
who
w

//查看登录记录
last

查看内核信息:

//查看内核版本
uname -a
lsb_release -a
cat /proc/version
cat /etc/issue
hostnamectl

查看ip地址:

ip addr
ifconfig(过时)
ip a
//如果有多张网卡,有可能会获取更多内网信息 

//查看路由表信息
ip route

//查看网络连接
ip neigh
arp -a

查看机器信息:

//查看机器名称
hostname
hostnamectl

当前用户能执行的root文件(重要!):

sudo -l

capabilities利用(在linux提权原理中有提到):

getcap -r / 2>/dev/null

列出文件和目录以及他们对应的权限:

ls -liah 

列出历史记录:

history

查看passwd文件:

cat /etc/passwd

查看自动任务:

cat /etc/crontab

查看环境变量:

echo $PATH
env

查看进程:

ps -ef
ps axjf
ps aux
top -n 1

网络统计:

netstat -a
netstat -l

有s位的可执行文件:

find / -perm -u=s -type f 2>/dev/null

查看能利用的工具:

which awk perl python ruby gcc vi vim nmap find netcat nc wget tftp ftp tmux screen 2>/dev/null

检测未挂载文件:

cat /etc/fstab
//备份和快照时会用到临时磁盘,临时磁盘一般不会挂载

自动化枚举:

自动化枚举要依靠工具,搬运时会产生流量,返回结果长,也可能会遗漏关键项。

常用枚举工具:

linpeass

linEnum

linux-smart-enumeration

linux-exploit-suggester

linuxprivchecker.py

unix-privesc-check

以linpeass为例,使用它有三个方式:

1,wget下载到靶机运行

2,curl+sh在线运行脚本

3,在攻击机中用python自带httpserver,靶机从攻击机开放端口中下载

posted on 2026-11-30 16:40  Redeyes  阅读(4)  评论(0)    收藏  举报