Windows Information Gathering
Active Directory¶
域环境判断¶
# 查看当前⽹卡和IP信息
ipconfig /all
# 查看系统详细信息
systeminfo
# 查看当前登录域及域用户
net config workstation
# 查看域内时间
net time /domain
域内信息¶
# 获取域SID
whoami /all
# 查询域列表
net view /domain
# 查看主域控制器
netdom query pdc
# 查看所有域控制器列表
net group "Domain Controllers" /domain
# ping -n 1 <Domain Controllers> 来确定域控制器的IP
# 查询域信任信息
nltest /domain_trusts
# 查询域密码信息
net accounts /domain
# 查看指定域中的机器列表
net view /domain:<domain name>
# 导出域详细信息
# WinServer 2008 内置工具,安装了AD DS或者Active Directory轻型目录服务服务器角色则此功能可用
csvde -setspn <domain name> -f C:\windows\temp\xxx.csv
域用户信息¶
# 查询域内用户
net user /domain
# 查看域用户的详细信息
net user <username> /domain
# 查询域管理员列表
net group "domain admins" /domain
# 查看登陆本机的域管理员
net localgroup administrators /domain
# 查看域内所有用户组列表
net group /domain
# 查看域用户详细信息
wmic useraccount get /all
定位域控¶
# 查看域内时间
net time /domain
# 查看主域控制器
netdom query pdc
# DNS记录
# 若当前主机的dns为域内dns,可通过查询dns解析记录定位域控
nslookup -type=all _ldap._tcp.dc._msdcs.rootkit.org
# SPN扫描
setspn -T <domain name> -Q */*
# 查询信任域
nltest /domain_trusts /all_trusts /v /server:<domain ip>
# 查询域详细信息
nltest /dsgetdc:<domain name> /server:<domain ip>
# 查询域机器
net group "domain computers" /domain
WorkGroup¶
系统信息¶
# 获取本机⽹络配置信息
ipconfig /all
# 查询操作系统和版本信息
# 英⽂版系统
systeminfo | findstr /B /C:"OS Nmae" /C:"OS Version"
# 中⽂版系统
systeminfo | findstr /B /C:"OS 名称" /C:"OS 版本"
# 查看系统体系结构
echo %PROCESSOR_ARCHITECTURE%
# 查看安装的软件及版本、路径
wmic product get name,version
# 查询本机服务信息
wmic service list brief
# 查看计划任务
schtasks /query /fo LIST /v
# 查看主机开机时间
net statistics workstation
# 查询补丁信息
systeminfo
# 查询补丁详情
wmic qfe get Caption,Description,HotFixID,InstalledOn
进程信息¶
# 列出所有进程
tasklist
# 详细视图(含用户名、CPU 时间、内存)
tasklist /v
# 显示进程关联的服务
tasklist /svc
# 过滤指定 PID 的进程
tasklist /fi "PID eq 1234"
# 查询远程计算机上的进程信息
tasklist /S <远程主机> /U <用户名> /P <密码>
# 列出所有进程简要信息
wmic process list
# 获取指定字段
wmic process get name,processid,workingsetsize
# 过滤并显示所有属性
wmic process where "name='explorer.exe'" get *
# 导出为 CSV
wmic /output:process.csv process get name,processid
# WMI 查询远程主机的进程列表
wmic /node:"<远程主机>" /user:"<用户名>" /password:"<密码>" process list
# PowerShell(1.0/2.0)
# 列出所有进程
Get-Process
# 通过 PowerShell 调用 WMI 查询进程
Get-WmiObject Win32_Process
# PowerShell(3.0)
Get-CimInstance Win32_Process
Get-CimInstance -ClassName Win32_Process -Filter "Name='explorer.exe'"
Get-CimInstance -ClassName Win32_Process -Filter "Name like 'P%'"
程序信息¶
# 查看启动程序信息
wmic startup get command,caption
# 使用 WMI 查询通过 Windows Installer(MSI)安装的程序列表
wmic product list brief
# 获取更详细的已安装程序信息,包括安装日期(格式为 YYYYMMDD)
wmic product get Name,Version,Vendor,InstallDate
# powershell
Get-WmiObject -Class Win32_Product
Get-CimInstance -ClassName Win32_Product
查看目标主机上安装的杀毒软件
wmic /namespace:\\root\securitycenter2 path antivirusproduct GET displayName,productState, pathToSignedProductExe
用户信息¶
# 查看有哪些用户
net user
wmic useraccount
# 查看当前在线用户
query user || qwinsta
# 获取本地管理员(通常含有域用户)信息
net localgroup administrators
# powershell
Get-LocalUser
Get-WmiObject Win32_UserAccount
Get-CimInstance Win32_UserAccount
网络信息¶
查看本机端口开放情况
查询路由表及所有可⽤接⼝的ARP缓冲表
查看防⽕墙配置
# 弃用命令
netsh firewall show config
# Windows 10/11 命令
netsh advfirewall /?
netsh advfirewall show allprofiles
# 防火墙放行3389端口
netsh advfirewall firewall add rule name="Remote Desktop" dir=in protocol=TCP localport=3389 action=allow
# 直接开启3389端口
netsh advfirewall firewall add rule name="Open RDP" dir=in protocol=TCP localport=3389 action=allow
# 查看防火墙策略
netsh advfirewall firewall show rule name="Remote Desktop"
# 兼容所有 Windows 版本
netsh advfirewall set allprofiles state off
# 使用 PowerShell
Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled False
开启远程桌面
# 连接端口为0xd3d,转换后为3389
REG QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /V PortNumber
# 远程桌面连接服务的状态
sc query termservice
sc start termservice
sc config termservice start= auto
# 在 Windows Server 2003 中开启 3389 端口
wmic path win32_terminalservicesetting where (__CLASS !="") call setallowtsconnections 1
# 在 Windows Server 2008 和 Windows Server 2012 中开启 3389 端口
wmic /namespace:\\root\cimv2\terminalservices path win32_terminalservicesetting where (__CLASS !="") call setallowtsconnections 1
# 在 Windows 7 中开启 3389 端口
reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
# 返回 0x0 表示已启用
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections
探测内网中的存活机器
for /l %i in (1,1,255) do @ping 192.168.0.%i -w 1 -n 1 | find /i "ttl="
# Usages:
for /l %i in (1,1,255) do @ping 192.168.52.%i -w 1 -n 1 | find /i "ttl="
定位程序开放端口
凭证信息¶
WiFi密码
密码文件搜集¶
低权限下搜集当前机器各类密码文件
在当前目录及其子目录中搜索指定文件
dir:表示目录列表命令
-
/b:表示以简洁方式(不包括文件详细信息)列出文件和目录 -
/s:表示包括指定目录下的所有子目录
dir /b /s user.*,pass.*,config.*,username.*,password.*
dir /a /s /b "D:\*.txt"
dir /a /s /b "D:\*pass*"
dir /a /s /b "D:\*login*
dir /a /s /b "D:\*user*
dir /a /s /b D:\\password.txt
dir /a /s /b "D:\*.conf" "D:\*.ini" "D:\*.inc" "D:\*.config"
dir /a /s /b "C:\*.txt" "C:\*.xls*" "C:\*.xlsx*" "C:\*.docx" | findstr "拓扑"
/C 参数来指定要查找的字符串
dir /a /s /b "C:\*.conf" "C:\*.ini*" "C:\*.inc*" "C:\*.config" | findstr /C:"运维"
dir /a /s /b "D:\*.txt" "D:\*.xls*" "D:\*.xlsx*" "D:\*.docx" | findstr /C:"密码"
编写bat
@echo off
set "drive=D:"
dir /a /s /b "%drive%\*.txt" >> result.txt
dir /a /s /b "%drive%\*pass*" >> result.txt
dir /a /s /b "%drive%\*login* >> result.txt
dir /a /s /b "%drive%\*user* >> result.txt
dir /a /s /b "%drive%\password.txt" >> result.txt
dir /a /s /b "%drive%\*.conf" "%drive%\*.ini" "%drive%\*.inc" "%drive%\*.config" >> result.txt
dir /a /s /b "%drive%\*.txt" "%drive%\*.xls*" "%drive%\*.xlsx*" "%drive%\*.docx" | findstr "拓扑" >> result.txt
dir /a /s /b "%drive%\*.conf" "%drive%\*.ini*" "%drive%\*.inc*" "%drive%\*.config" | findstr /C:"运维" >> result.txt
dir /a /s /b "%drive%\*.txt" "%drive%\*.xls*" "%drive%\*.xlsx*" "%drive%\*.docx" | findstr /C:"密码" >> result.txt
echo "find success"
循环搜集当前机器各类敏感密码配置文件
findstr 查找某个文件的某个字段
findstr:表示字符串查找命令
/c:"user":表示指定要搜索的第一个字符串 "user"/c:"pass":表示指定要搜索的第二个字符串 "pass"/si:表示在文件中搜索时,忽略大小写*.txt:表示要搜索的文件名模式,这里使用通配符*匹配任意字符,而.txt表示文件扩展名为 .txt 的文本文件。