如何预防arp欺骗以及c#如何自动绑定网关的mac地址?

来源:互联网 发布:淘宝网与易趣网异同 编辑:程序博客网 时间:2024/05/02 01:21

关于arp协议的一些原理什么的,就不啰嗦了,大家可以在网上搜索出一大堆。
如今Arp的病毒已经是鸡犬不宁,都是各大idc的服务器商头疼的事情,没有办法杜绝,但是可以找一些有效的方式来预防。

第一、比如写一个批处理文件

arp -d
arp -s 网关IP 网关mac地址
后在计算机加一个计划任务,每隔多长时间重新设置下网关的ip 和mac地址。

第二、c#如何自动邦网关的mac地址

首先我们新建一个windows控制台程序,代码如下

using System;
using System.Timers;
using System.Threading;
using System.Diagnostics;

namespace ConsoleApplication1
{
    
/// <summary>
    
/// Class1 的摘要说明。
    
/// </summary>
    
/// 
    class Class1
    {
        
static string strip = System.Configuration.ConfigurationSettings.AppSettings["getwayIP"];
        
static string strmac = System.Configuration.ConfigurationSettings.AppSettings["getwaymac"];
        
/// <summary>
        
/// 应用程序的主入口点。
        
/// </summary>
        [STAThread]
        
static void Main(string[] args)
        {
            
// 定时器
            
// TODO: 在此处添加代码以启动应用程序

            

            System.Timers.Timer aTimer 
= new System.Timers.Timer(10000); //每10秒执行网关mac绑定

            aTimer.Elapsed
+=new ElapsedEventHandler(OnTimedEvent);

            aTimer.AutoReset 
= true;
            aTimer.Enabled 
= true;

            Console.WriteLine(
"Press 'q' to quit Exit.");
            
while(Console.Read()!='q');

        }
        
private static void OnTimedEvent(object source, ElapsedEventArgs e) 
        {
            Console.WriteLine(
"ARP set getway mac");
            Process p 
= new Process();            
            p.StartInfo.FileName 
= "cmd.exe";
            p.StartInfo.UseShellExecute 
= false;
            p.StartInfo.RedirectStandardInput 
= true;
            p.StartInfo.RedirectStandardOutput 
= true;
            p.StartInfo.RedirectStandardError 
= true;
            p.StartInfo.CreateNoWindow 
= true;
            p.Start();


            p.StandardInput.WriteLine(
"arp -d");

            p.StandardInput.WriteLine(
"arp -s "+strip+" "+strmac);
            p.StandardInput.WriteLine(
"exit"); 

            Console.WriteLine(p.StandardOutput.ReadToEnd());
        }
        

    }
}

 

app。config 如下

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
    
<add key="getwayIP" value="192.168.0.1"></add>
    
<add key="getwaymac" value="00-18-39-8E-9F-1C"></add>
  
</appSettings> 
</configuration>

把产生的exe加到服务中就可以了,设置开机启动,就可以定时设置网关的mac地址。

第三、安装一些arp的防火墙,比如金山毒霸的arp的防火墙。下载地址

http://kad.www.duba.net/kas/KAntiarp.exe

以下是金山公司自己对于金山ARP防火墙的主要功能和特色的介绍:
    金山ARP防火墙能够双向拦截ARP欺骗攻击包,监测锁定攻击源,时刻保护局域网用户PC的正常上网数据流向,是一款是适于个人用户的反ARP欺骗保护工具。
    网关动态探测+识别——识破伪造的网关地址
    动态获取、并分析判断后为受保护PC绑定正确的网关地址,从而时刻保障保护本机上网数据的正确流向。同时也支持用户手动设置绑定网关地址。
    网关动态通知——受到ARP欺骗攻击时主动向网关发送数据包,表明合法身份。
    双向拦截ARP攻击
    拦截来自外部接受或是由本机发出的ARP攻击数据包并提醒用户,保障本机及其它PC的网络通畅。
    拦截IP冲突攻击,保护本机不受IP冲突攻击的影响
    攻击源追踪锁定——拦截到ARP攻击包后立即追踪攻击源,找出安全威胁源头。
    安全模式——让受保护PC在局域网隐身,攻击源无法察觉


 

原创粉丝点击