Board logo

标题: 帮帮手ARP的绑定批处理 [打印本页]

作者: yinyunping     时间: 2007-11-6 20:06    标题: 帮帮手ARP的绑定批处理

我的网吧常有ARP病毒,我在论坛中搞了几个批处理都有一个问题,就是批处理完了网卡都还没有打开,我用ARP -A去测它,只能绑定本机,没有绑定网关,请各位高手想想办法,谢谢!

作者: luckboy45     时间: 2007-11-6 20:16
通过ping网关三次得到了网关的MAC其实以上的批都可以通过这个来搞定网关的IP和MAC,但是如果开机的时候正在发生ARP欺骗的话 这样你绑的IP和MAC就是错的,不能上网了。 @echo off   :::::::::::::清除所有的ARP缓存   arp -d   :::::::::::::读取本地连接配置   ipconfig /all>ipconfig.txt   :::::::::::::读取内网网关的IP   for /f "tokens=13" %%I in (find "Default Gateway" ipconfig.txt) do set GatewayIP=%%I   ::::::::::::ING三次内网网关   ping %GatewayIP% -n 3   :::::::::::::读取与网关arp缓存   arp -a|find "%GatewayIP%">arp.txt   :::::::::::::读取网关MAC并绑定   for /f "tokens=1,2" %%I in (find "%GatewayIP%" arp.txt) do if %%I==%GatewayIP% arp -s %%I %%J   :::::::::::::读取本机的 IP+MAC   for /f "tokens=15" %%i in (find "IP Address" ipconfig.txt) do set ip=%%i   for /f "tokens=12" %%i in (find "Physical Address" ipconfig.txt) do set mac=%%i   :::::::::::::绑定本机的 IP+MAC   arp -s %ip% %mac%   :::::::::::::删除所有的临时文件   del ipconfig.txt   del arp.txt   exit

作者: yinyunping     时间: 2007-11-6 21:00
不行啊大哥

作者: hongyu1068     时间: 2007-11-6 21:55
你能加上个延时的批处理,看看行不行呀

作者: yinyunping     时间: 2007-11-6 22:28
延时的批处理怎样啊,我好菜

作者: everest79     时间: 2007-11-7 00:27
更改注册表的权限为只读就可以了,不过这样会影响一些软件运行

作者: shtcool     时间: 2007-11-7 10:45
自己写的: @ECHO OFF title=绑定本机-网关MAC地址自动运行版,BY Shtcool color 0b mode con cols=30 lines=5 echo. echo %date% arp -d >nul 2>nul echo 正在绑定本机MAC地址,请稍后.... for /f "tokens=2 delims=:" %%a in ('ipconfig /all ^| find "IP Address"') do set IP=%%a for /f "tokens=2 delims=:" %%b in ('ipconfig /all ^| find "Physical Address"') do set MAC=%%b arp -s %IP% %MAC% cls echo. echo %date% echo 本机MAC地址绑定成功..... ping 127.0.0.1 -n 2 >nul cls echo. echo %date% echo 正在绑定网关MAC地址,请稍后.... for /f "tokens=2 delims=:" %%C in ('ipconfig/all ^|find "Default Gateway"') do set getwayaddr_ip=%%C ping -n 2 %getwayaddr_ip% >NUL for /f "tokens=2 delims= " %%D in ('arp -a ^|find "%getwayaddr_ip% "') do set getwayaddr_mac=%%D arp -s %getwayaddr_ip% %getwayaddr_mac% cls echo. echo %date% echo 网关MAC地址绑定成功..... ping 127.0.0.1 -n 2 >nul goto :eof [ Last edited by shtcool on 2007-11-9 at 09:47 AM ]