内网渗透——域内信息收集
拿到机器权限后,第一步就是收集域内信息
常规信息收集
ipconfig /all 查询本机IP段,所在域等
ipconfig /displaydns --------查看dns缓存
net user ------ 本机用户列表
net localhroup administrators ------ 本机管理员[通常含有域用户]
net user /domain ------ 查询域用户
net group /domain ------ 查询域里面的工作组
net group "domain admins" /domain ------ 查询域管理员用户组
net group "enterprise admins" /domain ------获得企业管理员列表
net group "domain computers" /domain -------查询加入域内的机器
net group "domain controllers" /domain ------ 查看域控制器
nltest /domain_trusts ----------------查询域信任关系
net localgroup administrators /domain ------ 登录本机的域管理员
net localgroup administrators workgroup user001 /add ------域用户添加到本机
net time /domain ------ 判断主域,主域服务器都做时间服务器
net config workstation ------ 当前登录域
net session ------ 查看当前会话
net use \\ip\ipc$ pawword /user:username ------ 建立IPC会话[空连接-***]
net share ------ 查看SMB指向的路径[即共享]
net view ------ 查询同一域内机器列表
net view \\ip ------ 查询某IP共享
net view /domain ------ 查询域列表
net view /domain:domainname ------ 查看workgroup域中计算机列表
net start ------ 查看当前运行的服务
net accounts ------ 查看本地密码策略
net accounts /domain ------ 查看域密码策略
nbtstat –A ip ------netbios 查询
netstat -nao ------ 网络连接查询
route print ------ 路由表
arp -a -------查看arp记录
dsquery computer ----- finds computers in the directory.
dsquery contact ----- finds contacts in thedirectory.
dsquery subnet ----- finds subnets in thedirectory.
dsquery group ----- finds groups in thedirectory.
dsquery ou ----- finds organizationalunits in the directory.
dsquery site ----- finds sites in thedirectory.
dsquery server ----- finds domain controllers inthe directory.
dsquery user ----- finds users in thedirectory.
dsquery quota ----- finds quota specificationsin the directory.
dsquery partition ----- finds partitions in thedirectory.
dsquery * ----- finds any object inthe directory by using a generic LDAP query.
dsquery server –domain Yahoo.com | dsget server–dnsname –site —搜索域内域控制器的DNS主机名和站点名
dsquery computer domainroot –name -xp –limit 10----- 搜索域内以-xp结尾的机器10台
dsquery user domainroot –name admin -limit ---- 搜索域内以admin开头的用户10个
tasklist /V ----- 查看进程[显示对应用户]
tasklist /S ip /U domain\username /P /V ----- 查看远程计算机进程列表
qprocess * ----- 类似tasklist
qprocess /SERVER:IP ----- 远程查看计算机进程列表
nslookup –qt-MX Yahoo.com ----- 查看邮件服务器
nslookup -type=all _ldap._tcp.dc._msdcs.jumbolab.com
whoami /all ----- 查询当前用户权限等
set ----- 查看系统环境变量
ver ------查看系统版本
systeminfo ----- 查看系统信息
qwinsta ----- 查看登录情况
qwinsta /SERVER:IP ----- 查看远程登录情况
fsutil fsinfo drives ----- 查看所有盘符
gpupdate /force ----- 更新域策略
wmic bios ----- 查看bios信息
wmic qfe ----- 查看补丁信息
wmic qfe get hotfixid ----- 查看补丁-Patch号
wmic startup ----- 查看启动项
wmic service ----- 查看服务
wmic os ----- 查看OS信息
wmic process get caption,executablepath,commandline
wmic process call create “process_name” (executes a program)
wmic process where name=”process_name” call terminate (terminates program)
wmic logicaldisk where drivetype=3 get name, freespace, systemname, filesystem, size,volumeserialnumber (hard drive information)
wmic useraccount (usernames, sid, and various security related goodies)
wmic useraccount get /ALL
wmic share get /ALL (you can use ? for gets help ! )
wmic startup list full (this can be a huge list!!!)
wmic /node:“hostname” bios get serialnumber (this can be great for finding warranty info about target)
SPN
SPN:服务主体名称。使用Kerberos须为服务器注册SPN,因此可以在内网中扫描SPN,快速寻找内网中注册的服务,SPN扫描可以规避像端口扫描的不确定性探测动作。主要利用工具有:setspn、GetUserSPNs.vbs和Rubeus。
1.利用Windows自带的setspn工具,普通域用户权限执行即可:
setspn -T domain.com -Q */*
SPN可以扫描出DCServer机器上运行了dns服务。内网mssql
2.利用GetUserSPNs.vbs也可以获取spn结果:
3.Rubeus工具是Harmj0y开发用于测试Kerberos的利用工具。
域传送
当存在域传送漏洞时,可以获取域名解析记录。有些子域名在内网什么位置一目了然。提高对网络环境的进一步认知。
windows:
nslookup -type=ns domain.com nslookup sserver dns.domain.com ls domain.com
linux:
dig @dns.domain.com axfr domain.com
GPP
当分发组策略时,会在域的SYSVOL目录下生成一个gpp配置的xml文件,如果在配置组策略时填入了密码,则其中会存在加密过的账号密码。这些密码,往往都是管理员的密码。
其中xml中的密码是aes加密的,密钥已被微软公开:
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-gppref/2c15cbf0-f086-4c74-8b70-1f2fa45dd4be?redirectedfrom=MSDN
可以使用相关脚本进行解密,如:
https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Exfiltration/Get-GPPPassword.ps1
域用户登录脚本存在目录也会存在敏感文件:
\domain\Netlogon
Exchange
exchange一般都在域内的核心位置上,包括甚至安装在域控服务器上,因此我们需要多多关注exchange的相关漏洞,如果拿下exchange机器,则域控也不远了。
exp,只要知道任意用户名密码,即可rce
powershell收集域内信息
PowerView拖域内信息:
https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Recon/PowerView.ps1
powershell.exe -Command "& {Import-Module c:\users\admin\PowerView.ps1 ; Get-NetUser }" >> c:\users\admin\get_netuser.txt
powershell.exe -Command "& {Import-Module c:\users\admin\PowerView.ps1 ; Get-NetComputer }" >> c:\users\admin\get_netcomputer.txt
域登录日志&远程登录日志
域日志位置
C:\Windows\System32\winevt\Logs\Security.evtx 服务器登录日志 登录事件ID 4624,可判别出登录域控制器的机器
C:\windows\system32\winevt\logs\*.remote* 远程登录日志
主机远程登录日志
HKCU\Software\Microsoft\Terminal Server Client\Servers
HKCU\Software\Microsoft\Terminal Server Client\Default

浙公网安备 33010602011771号