安全中国首页 > 文章中心 > ARP技术文章
 
安全中国网友投稿专用上传FTP空间:
Ftp服务器:download.anqn.com
Ftp端口:21
用户名:anqn
密 码:anqn.com
 

利用四种自制批处理文件防御ARP攻击

更新时间:2007-9-10 4:54:57
责任编辑:池天
热 点:
通过伪造IP地址和MAC地址实现ARP欺骗,能够在网络中产生大量的ARP通信量使网络阻塞,攻击者只要持续不断的发出伪造的ARP响应包就能更改目标主机ARP缓存中的IP-MAC条目,造成网络中断或中间人攻击。 本文介绍了四种利用自制批处理文件来防御ARP攻击的方法。

  一、把下面语句编成BAT处理文件就可以搞定
@echo off

::读取本机Mac地址

if exist ipconfig.txt del ipconfig.txt

ipconfig /all >ipconfig.txt

if exist phyaddr.txt del phyaddr.txt

find "Physical Address" ipconfig.txt >phyaddr.txt

for /f "skip=2 tokens=12" %%M in (phyaddr.txt) do set Mac=%%M

::读取本机ip地址

if exist IPAddr.txt del IPaddr.txt

find "IP Address" ipconfig.txt >IPAddr.txt

for /f "skip=2 tokens=15" %%I in (IPAddr.txt) do set IP=%%I

::绑定本机IP地址和MAC地址

arp -s %IP% %Mac%

::读取网关地址

if exist GateIP.txt del GateIP.txt

find "Default Gateway" ipconfig.txt >GateIP.txt

for /f "skip=2 tokens=13" %%G in (GateIP.txt) do set GateIP=%%G

::读取网关Mac地址

if exist GateMac.txt del GateMac.txt

arp -a %GateIP% >GateMac.txt

for /f "skip=3 tokens=2" %%H in (GateMac.txt) do set GateMac=%%H

::绑定网关Mac和IP

arp -s %GateIP% %GateMac%

arp -s 网关IP 网关MAC

exit

  这个批处理要查询本机的ARP 缓存表,看里面是不是有网关的IP和MAC,有则能成功

  绑定,但是没有的话就绑不定了!!!不过可以改进一下,达到双绑的目的,比如

  加上arp -s 网关IP 网关MAC一行就可以了。。。

  二、这个也不能实现真正意义的双绑,只能绑定本机IP和MAC

@echo off

for /f "delims=: tokens=2" %%a in (ipconfig /all^|find "Physical Address") do set local_mac=%%a

for /f "delims=: tokens=2" %%a in (ipconfig /all^|find "IP Address") do set local_ip=%%a

for /f "delims=: tokens=2" %%a in (ipconfig /all^|find "Default Gateway") do set gate_ip=%%a

fo* /* %%* in (getmac /nh /s %local_ip%) do set gate_mac=%%a

arp -s %local_ip% %local_mac%

arp -s %gate_ip% %gate_mac% (这个地方有问题,改进中……)

 经测试,此批处理不能绑定网关IP和MAC,只能绑定本机IP和MAC

  三、这个还不是很清楚,我要测试才行的,目前所知也能绑定本机IP和MAC

1 2 下一页

 
相关文章
一日一文章
 
一日一软件
一日一动画