<form id="hz9zz"></form>
  • <form id="hz9zz"></form>

      <nobr id="hz9zz"></nobr>

      <form id="hz9zz"></form>

    1. 明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

      使用arp欺騙來完成計費技巧

      [摘要]早些時候收到了項目的要求, 任何局域網絡內的一臺計算機上安裝一套計費軟件, 其他客戶不必安裝任何軟件, 只要客戶接入線路將能夠發揮的帳單。 以前接觸到的計費軟件是安裝在網關, 或安裝客戶端軟件, ...
      早些時候收到了項目的要求, 任何局域網絡內的一臺計算機上安裝一套計費軟件, 其他客戶不必安裝任何軟件, 只要客戶接入線路將能夠發揮的帳單。 以前接觸到的計費軟件是安裝在網關, 或安裝客戶端軟件, 如何實現這樣的功能?有關研究發現, 使用欺騙ARP協議的原則才能實現的結算職能, 原則上是不公開上網功能的客戶端插件線網絡, 第一個禁止在計算機局域網絡內的互聯網, 如客戶要求管理員, 以開放的互聯網功能后, 取消對客戶停止并開始計費。 ARP協議欺騙人民不認為奇怪, 有很多網上介紹ARP協議欺騙的文章, 有很多ARP協議欺騙病毒不會在這里重復的原則, 欺騙ARP協議。

             如何防止局部地區指定的客戶端互聯網?

      阿爾普偽造的要求, 設置包的機器停止對ARP表, 這樣的觀點, 網關MAC地址并不存在作為一個MAC地址, 這樣你就可以阻止機器上網。

      假設要阻止的計算機是A, 安裝計費軟件的計算機是B,網關是C

      A機器  MAC:AA-AA-AA-AA-AA-AA  IP地址:192.168.1.1

      B機器  MAC:BB-BB-BB-BB-BB-BB  IP地址:192.168.1.2

      C網關  MAC:CC-CC-CC-CC-CC-CC  IP地址:192.168.1.253

      在網上有好多arp例子都是c的, 我用delphi和Winpcap實現代碼如下:

       

      安裝Winpcap, 引用:winsock, Packet32, shellapi單元

      類型和常量定義:

      type

        TMacAddr = array [0..5] of byte ;

        TEHHDR=packed record

           Ether_Dest: TMacAddr ;  {目的地址 }

           Ether_Src: TMacAddr ;   {源地址 }

           Ether_Type:Word;        {類型 }

        end;

        PEHHDR=^TEHHDR;

        TEtherData=packed record      {Ethernet packet data}

         Ether_hrd:WORD;       {hardware address }

         Ether_pro:WORD; {format of protocol address }

         Ether_hln: byte; {byte length of each hardware address }

         Ether_pln: byte; {byte length of each protocol address}

          Ether_op:WORD; { ARP or RARP }

           Ether_sha:TMacAddr; {hardware address of sender}

           Ether_spa:LongWord; {protocol address of sender}

           Ether_tha:TMacAddr; {hardware address of target}

           Ether_tpa:LongWord;   {protocol address of target}

        end;

        PARPHDR=^TEtherData;

        TARPPACKET=packed record

            EHHDR:Tehhdr;

            EtherData:TEtherData;

         end ;

       PARPPACKET=^TARPPACKET;

      const

       INADDR_NONE = $FFFFFFFF;

       EPT_IP  = $0800;

       EPT_ARP = $0806 ;

       EPT_RARP =$8035 ;

       ARP_REPLY =$0002 ;

       ARP_REQUEST =  $0001 ;

       ARP_HARDWARE =$0001 ;

       function inet_addr(const cp: PChar): DWord; stdcall; external 'WS2_32.DLL' name 'inet_addr';

      //別人的代碼

      function     HexStrtoInt(var   Buf:   string):   dword;

        //將十六進制的字符串轉成整型

            //判斷是否是十六進制數

            function   IsHexChar(Chr:   char):   boolean;

            begin

                Result   :=   (Chr   in   ['0'..'9'])   or   (Chr   in   ['A'..'F']);

            end;

            //將一個十六進制字符轉換成數

            function   HexChrtoInt(Chr:   char):   byte;

            begin

                Result   :=   0;

                case   Chr   of

                    '0'..'9'   :   Result   :=   Strtoint(Chr);

                    'A'             :   Result   :=   10;

                    'B'             :   Result   :=   11;

                    'C'             :   Result   :=   12;

                    'D'             :   Result   :=   13;

                    'E'             :   Result   :=   14;

                    'F'             :   Result   :=   15;

                end;

            end;

        var

            BufLength:   dword;

            TempBuf:   string;  

            Count0:   dword;  

        begin

            Result   :=   0;  

            BufLength   :=   Length(Buf);

            TempBuf   :=   '';  

            if   BufLength   >   0   then   begin

                Buf   :=   Uppercase(Buf);  

        //         for   Count0   :=   1   to   BufLength  

                if   BufLength   mod   2   =   1   then   begin  

                    Buf   :=   '0'   +   Buf;  

                    BufLength   :=   Length(Buf);

                end;

                for   Count0   :=   1   to   BufLength   div   2   do  

                    if   IsHexChar(Buf[Count0   *   2   -   1])   then   begin  

                        if   IsHexChar(Buf[Count0   *   2])   then   begin  

                            TempBuf   :=   TempBuf   +   inttostr(HexChrtoInt(Buf[Count0   *   2   -   1])

        *   16   +   HexChrtoInt(Buf[Count0   *   2]));

                        end   else   begin

                            Result   :=   Count0   *   2;  

                            Break;  

                        end;  

                    end   else   begin

                        Result   :=   Count0   *   2   -   1;  

                        Break;  

                    end;

                if   Result   =   0   then   Buf   :=   TempBuf;

            end;

        end;

      //MAC轉換

      procedure GetMac(s : string;var Mac : TMacAddr);

        var

        hs : string;

        p : integer;

        i,j:integer;

      begin

       FillChar (Mac, SizeOf (Mac), 0) ;

        i:=0;

        if Length(s)=0 then

          Exit;

        p:=Pos('-',s);

        while P<>0 do

        begin

          hs:=Copy(s,1,p-1);

          HexStrtoInt(hs);

          Mac[i]:=  strtoint(hs) ;

          Delete(s,1,p);

          p:=Pos('-',s);

          i:=i+1;

        end;

        if Length(s)>0 then

        begin

           HexStrtoInt(s);

           Mac[i]:=strtoint(s);

        end;

      end;

       

      {禁止上網, 發送arp請求包,這里的C_mac為偽造的C的mac地址}

      procedure SendArp(A_ip:string;A_mac:string;B_ip:string;B_mac:string;C_IP:string;C_mac:string);

      var

      ulMACAddr: TMacAddr;

      EHHDR:TEHHDR;

      EtherData:TEtherData;

      pp:pPacket;

      lpAdapter:Padapter;

      BUF:Array [0..512] of char ;

      begin

          //以太網包首部

          GetMac(A_mac,ulMACAddr);

          Move(ulMACAddr , EHHDR.Ether_Dest,6);//目的地址-A計算機的地址

          GetMac(C_mac,ulMACAddr);

          Move(ulMACAddr , EHHDR.Ether_Src,6);//偽造的源地址-C計算機的地址

          EHHDR.Ether_Type  := htons(EPT_ARP);//arp包

         

          //構造以太網包數據

          EtherData.Ether_hrd := htons(ARP_HARDWARE);

          EtherData.Ether_pro := htons(EPT_IP);

          EtherData.Ether_hln := 6;

          EtherData.Ether_pln := 4;

          EtherData.Ether_op  := htons(ARP_REQUEST);//arp請求包

          GetMac(C_mac,ulMACAddr);

          Move(ulMACAddr , EtherData.Ether_sha,6);

          EtherData.Ether_spa := inet_addr(Pchar(B_IP));  

          GetMac(B_mac,ulMACAddr);

          Move(ulMACAddr , EtherData.Ether_tha,6);

          EtherData.Ether_tpa := inet_addr(Pchar(B_ip));  

           lpAdapter := PacketOpenAdapter('\Device\NPF_{E00872C1-37C0-47CE-8472-313A5A23F896}');  // 根據

      你網卡名字打開網卡, 這是我網卡的設備名

           fillchar(BUF,sizeof(BUF),0);

           CopyMemory(@BUF,@EHHDR,SIZEOF(EHHDR));

           CopyMemory(Pointer(LongWord(@BUF)+SIZEOF(EHHDR)),@EtherData,SIZEOF(EtherData));

             // 分配內存

           pp := PacketAllocatePacket();            

           //初始化結構指針

           PacketInitPacket(pp, @BUF,512);

           //發arp應答包

           PacketSendPacket(lpAdapter, pp, true);

           

           // 釋放內存

           PacketFreePacket(pp);

           PacketCloseAdapter(lpAdapter);

      end;

      //調用示例

        SendArp('192.168.1.1','AA-AA-AA-AA-AA-AA','192.168.1.2','BB-BB-BB-BB-BB-BB','192.168.1.253','00-00-00-00-00-00');

      {解除阻止, 發送arp應答包,這里的C_mac為真實的C的mac地址}

      procedure SendArpReply(A_ip:string;A_mac:string;C_ip:string;C_mac:string;B_mac:string);

      var

      ulMACAddr: TMacAddr;

      EHHDR:TEHHDR;

      EtherData:TEtherData;

      pp:pPacket;

      lpAdapter:Padapter;

      BUF:Array [0..512] of char ;

      begin

          GetMac(A_mac,ulMACAddr);

          Move(ulMACAddr , EHHDR.Ether_Dest,6);

          GetMac(B_mac,ulMACAddr);

          Move(ulMACAddr , EHHDR.Ether_Src,6);

          EHHDR.Ether_Type  := htons(EPT_ARP);

          EtherData.Ether_hrd := htons(ARP_HARDWARE);

          EtherData.Ether_pro := htons(EPT_IP);

          EtherData.Ether_hln := 6;

          EtherData.Ether_pln := 4;

          EtherData.Ether_op  := htons(ARP_REPLY);//arp應答包

          GetMac(C_mac,ulMACAddr);

          Move(ulMACAddr , EtherData.Ether_sha,6);

          EtherData.Ether_spa := inet_addr(Pchar(C_ip));  

          GetMac(A_mac,ulMACAddr);

          Move(ulMACAddr , EtherData.Ether_tha,6);

          EtherData.Ether_tpa := inet_addr(Pchar(A_ip));  

           // 根據自己網卡的設備名打開網卡

           lpAdapter := PacketOpenAdapter('\Device\NPF_{E00872C1-37C0-47CE-8472-313A5A23F896}');

         

           fillchar(BUF,sizeof(BUF),0);

           CopyMemory(@BUF,@EHHDR,SIZEOF(EHHDR));

           CopyMemory(Pointer(LongWord(@BUF)+SIZEOF(EHHDR)),@EtherData,SIZEOF(EtherData));

           // 分配內存

           pp := PacketAllocatePacket();            

           //初始化結構指針

           PacketInitPacket(pp, @BUF,512);

           //發arp應答包

           PacketSendPacket(lpAdapter, pp, true);

           

           // 釋放內存

           PacketFreePacket(pp);

           PacketCloseAdapter(lpAdapter);

      end;

      //調用示例

       SendArpReply('192.168.1.1','AA-AA-AA-AA-AA-AA','192.168.1.253','CC-CC-CC-CC-CC-CC','BB-BB-BB-BB-BB-BB');

      需要注意的是, 發出偽造的arp請求包過一段時間后會被刷新為正確的, 所以每隔一段時間要向被阻止的機器發送一個arp包, 這樣才能達到阻止上網的目的。


      上面是電腦上網安全的一些基礎常識,學習了安全知識,幾乎可以讓你免費電腦中毒的煩擾。




      日韩精品一区二区三区高清