标题: [网络工具] [分享]windump辅助工具批处理版 [打印本页]
作者: wscript 时间: 2013-12-17 21:41 标题: [分享]windump辅助工具批处理版
有喜欢用tcpdump/windump抓包工具的筒子们吗?其自带的-D参数可列出可用网卡列表,但显示的结果不够友好,不知道与网络连接中的网卡名称、IP地址、MAC地址等如何对应,所以编写了这个辅助脚本。- :: nic.bat by wscript @ www.bathome.net
- @echo off
- setlocal enableDelayedExpansion
- echo Network Interface Card
- echo -------------------------------------------------------------------------------
- for /f "tokens=1,3* delims=.{}" %%a in ('windump -D') do (
- for /f "delims=" %%i in ('
- wmic nicconfig where "SettingID='{%%b}'" get Index^,IPAddress^,MACAddress /value ^| find "="
- ') do set %%i
-
- for /f "delims=" %%i in ('
- wmic nic !Index! get NetConnectionID /value ^| find "="
- ') do set %%i
-
- set Adapter=%%c
- set "Adapter=!Adapter:* =!"
- set "Adapter=!Adapter:~1,-1!"
- echo %%a.!Adapter!
- echo Name = !NetConnectionID!
- echo MACAddress = !MACAddress!
- echo IPAddress = !IPAddress!
- echo;
- )
- endlocal
复制代码
结果对比
# windump -D
1.\Device\NPF_{4C4FE84D-A851-4891-A16B-92F3C94621A7} (Broadcom 802.11n Q?Mh (Mic
rosoft's Packet Scheduler) )
2.\Device\NPF_{A7CAE752-C73F-42E4-9783-83548F12EB17} (MS LoopBack Driver)
3.\Device\NPF_{58F72805-2DD4-4AC2-AECB-481FFF504375} (VMware Virtual Ethernet Ad
apter)
# nic.bat
Network Interface Card
-------------------------------------------------------------------------------
1.Broadcom 802.11n Q?Mh (Microsoft's Packet Scheduler)
Name = 无线网络连接 2
MACAddress = 4C:EDE:90:D6:30
IPAddress = {"192.168.1.11"}
2.MS LoopBack Driver
Name = Microsoft Loopback Adapter
MACAddress = 02:00:4C:4F:4F:50
IPAddress = {"172.16.100.1","172.16.100.11"}
3.VMware Virtual Ethernet Adapter
Name = VMnet1-Host-Only
MACAddress = 00:50:56:C0:00:01
IPAddress = {"192.168.174.1"}
作者: wscript 时间: 2013-12-17 21:53
上面的对比结果中,因为我已经禁用了一个虚拟网卡,所以只显示了一个VMware Virtual Ethernet Adapter,不然有两个,就更不好区分怎么对应了。
作者: wscript 时间: 2013-12-17 22:24
小小抱怨一下,windows脚本的效率真是够低的,感觉和linux脚本相差至少一个数量级,而且很多在linux下非常简单就能做到的,在windows上却要操作几个东西才能实现,比如代码中的nic和nicconfig,要执行两次wmic,更加降低了效率
作者: zqz0012005 时间: 2013-12-17 22:49
欢迎大虾同时也参与到windows脚本阵营!
windows脚本确实不如linux,而且微软还喜欢把脚本技术改来改去,现在又开始宠PowerShell了,大虾有兴趣可以玩玩,不过貌似效率比vbs还低。
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |