Ejemplo n.º 1
0
        private void btStartInvalidMacSpoof_Click(object sender, EventArgs e)
        {
            string error_InvalidIP = "Invalid IP Address";
            string error_notIpv4 = "This attack only allow IPv4 addresses";
            string error_macTargetNotFound = "The MAC address of the target has not been found";
            string error_macSpoofedNotFound = "The MAC address has not been found";

            IPAddress target = null;
            PhysicalAddress macTarget = null;
            IPAddress spoofedIp = null;
            PhysicalAddress macSpoofed = null;

            try
            {
                target = IPAddress.Parse(tbTargetSpoofedIpv4.Text);
            }
            catch
            {
                ShowMessage(error_InvalidIP, 1000, FormMessage.IconType.Error);
                return;
            }

            try
            {
                spoofedIp = IPAddress.Parse(tbIpSpoofedIpv4.Text);
            }
            catch
            {
                ShowMessage(error_InvalidIP, 1000, FormMessage.IconType.Error);
                return;
            }

            if ((target.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork) || (spoofedIp.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork))
            {
                ShowMessage(error_notIpv4, 1000, FormMessage.IconType.Error);
                return;
            }

            // Cogemos la mac del target de los vecinos
            macTarget = Program.CurrentProject.data.GetNeighborMAC(target);
            // En caso de que no la tengamos, le hacemos un ARP para coger su MAC
            if (macTarget == null)
            {
                string strMac = Utils.GetMacUsingARP(target.ToString());
                if (string.IsNullOrEmpty(strMac))
                {
                    ShowMessage(error_macTargetNotFound, 1000, FormMessage.IconType.Error);
                    return;
                }

                macTarget = PhysicalAddress.Parse(strMac.ToUpper());
            }

            // Cogemos la mac del target de los vecinos
            macSpoofed = Program.CurrentProject.data.GetNeighborMAC(spoofedIp);
            // En caso de que no la tengamos, le hacemos un ARP para coger su MAC
            if (macTarget == null)
            {
                string strMac = Utils.GetMacUsingARP(spoofedIp.ToString());
                if (string.IsNullOrEmpty(strMac))
                {
                    ShowMessage(error_macSpoofedNotFound, 1000, FormMessage.IconType.Error);
                    return;
                }
                macSpoofed = PhysicalAddress.Parse(strMac.ToUpper());
            }

            Data.InvalidMacSpoofAttackIpv4Attack invalidMacSpoofAttack = new InvalidMacSpoofAttackIpv4Attack(
                                                                            new Target(target, macTarget),
                                                                            new Target(spoofedIp, macSpoofed),
                                                                            AttackType.InvalidMacSpoofIpv4);

            Program.CurrentProject.data.AddAttack(invalidMacSpoofAttack);
            invalidMacSpoofAttack.Start();
            AddAttackToListViewEx(invalidMacSpoofAttack);
            Program.LogThis("Performing a DoS attack to " + invalidMacSpoofAttack.t1.ip.ToString() + " with " + invalidMacSpoofAttack.t2.ip.ToString(), Logs.Log.LogType.DoS);
        }
Ejemplo n.º 2
0
 public void ForceRestore(InvalidMacSpoofAttackIpv4Attack attack)
 {
     EthernetPacket ethernet;
     ethernet = new EthernetPacket(device.Interface.MacAddress, ((InvalidMacSpoofAttackIpv4Attack)attack).t1.mac, EthernetPacketType.Arp);
     ethernet.PayloadPacket = new ARPPacket(ARPOperation.Response, ((InvalidMacSpoofAttackIpv4Attack)attack).t1.mac, ((InvalidMacSpoofAttackIpv4Attack)attack).t1.ip, ((InvalidMacSpoofAttackIpv4Attack)attack).t2.mac, ((InvalidMacSpoofAttackIpv4Attack)attack).t2.ip);
     Program.CurrentProject.data.SendPacket(ethernet);
 }