Understanding Fork Bombs in 5 Minutes or Less

  Рет қаралды 149,834

Engineer Man

Engineer Man

5 ай бұрын

You've probably seen a fork bomb before, but do you understand how it works? In this video you'll find out.
Hope you enjoyed the video!
Check out some code on my GitHub:
github.com/realtux
github.com/engineer-man/youtube
Other Social:
/ engineerman
/ _engineerman
/ discord

Пікірлер: 129
@EngineerMan
@EngineerMan 5 ай бұрын
Warning: Don't run this on your own system. If you want to test it, create a VM like I did.
@VRixxo123
@VRixxo123 5 ай бұрын
Why not. Does it not go away ?
@acu01136
@acu01136 5 ай бұрын
Surely hard rebooting the system stops the issue though? With all the normal problems with hard reboots ofcourse.
@benargee
@benargee 5 ай бұрын
He probably means that it's the easiest environment to test in and as a general disclaimer to not mess up a system critical machine. At the end of the day you can do whatever you want with your own hardware, just that he's not endorsing it.
@daidaloscz
@daidaloscz 5 ай бұрын
Nobody can stop me from running this on our production cluster. (I have sudo)
@iuhere
@iuhere 5 ай бұрын
Someone (YKIYK) said - Why are the warnings at the end of the book 😉
@lillii9119
@lillii9119 5 ай бұрын
Short version: it creates a function called : that calls itself infinitely Also it calls 2 functions for each function which run at the same time so each step the number of functions is doubled
@glukogen5674
@glukogen5674 5 ай бұрын
*Force Multiplication*
@demipy
@demipy 5 ай бұрын
I know this classic for over a decade now, but this was such a great video explaining it in detail! Thats the content i love this channel for. No BS straight to the point. ❤
@flipperiflop
@flipperiflop 5 ай бұрын
Great explanation! The expanded version really made it go from black magic to "oh it's that simple"
@tc2241
@tc2241 5 ай бұрын
I love videos like these. Straight to the point, clearly explained with concise examples and demonstrations
@paulm3702
@paulm3702 5 ай бұрын
Wow that's interesting! Love the breakdown of how that code actually worked
@alicefraser5799
@alicefraser5799 5 ай бұрын
That's why I love your content EM. Learning so much from you. Keep them coming :)
@revx144
@revx144 3 ай бұрын
I actually did this in my phone, good thing I did some buttons and it restarted. I was so scared but I was relieved when it restarted successfully.
@comosaycomosah
@comosaycomosah 5 ай бұрын
dude idk how i havent came across your content yet but i dig it.
@alexanderaphonin7850
@alexanderaphonin7850 5 ай бұрын
Great video, great explanation! Thank you for putting in the effort each time!
@EngineerMan
@EngineerMan 5 ай бұрын
Thanks for the kind words.
@rogo7330
@rogo7330 5 ай бұрын
Pipe is not the real issue here that causes program to explode. When you running a function, shell executes whatever command you gave it (and forks itself to execute external programs), but ampersand makes shell not to wait for a job to complete and then return but instead put that job in a background and let user to cleanup it with a wait command manualy. What is a job? Job is basically a group of processes with the same Process group ID (read manpage 7 credentials to learn more). Shell, when you launch several command with a pipe between them, first calls fork, then in a child assigns the same PGID as it's PID to itself, then it calls more forks which will inherit the same PGID (despite having new PIDs) with their stdins and stdouts connected one to another, and then each of that child executes whatever command you gave it to execute. Why PGID needed? To call kill command on the whole group of processes with the same PGID instead of calling kill to each one of them, or even lose control when initial child died and replaced itself with a new process with new PID. Since PGID is inherited by the child, and if child does not changes it explicitly by calling setpgid, you can just `kill -- -${child_pid}` (notice the minus before the process id and double-minus to make kill take that negative pid not as another option but as a pid value). This is how shell kills the whole pipe sequence at once. And yes, if child changes its PGID, its becoming immune to group kill (the game was rigged from the start), which does makes sence, but its hard to work around this if you really want to end all child and grandchildren processes, if at all possible. Try to write cron yourself, you will spend on it at least a hour or two of experimenting with what works and what not if you start from scratch knowing nothing about jobs, PGID, SID, what kill and wait calls allow you to do and what permissions you have to play with for changing processes credentials.
@YammoYammamoto
@YammoYammamoto 4 ай бұрын
The colon being a valid function name was what blew my mind. :D
@n8style
@n8style 5 ай бұрын
Fantastic explanation, quality video
@HadToChangeMyName_YoutubeSucks
@HadToChangeMyName_YoutubeSucks 5 ай бұрын
I've seen it a number of times recently. Used to be kind of common, then it seemed to get old and I didn't see it so much, now it seems to be common again.
@yousefm.b4260
@yousefm.b4260 5 ай бұрын
Wow!! this guy actually explained it very well.. I like it
@penguinpatroller
@penguinpatroller 5 ай бұрын
great video. concise and informative
@matejhurta5626
@matejhurta5626 5 ай бұрын
I kinda accidentally let it loose on the uni network and it crashed the network for a few days and I got failed :(
@h3dzer
@h3dzer 5 ай бұрын
I love this new series
@loverboykimi
@loverboykimi 5 ай бұрын
Great education. Appreciated.
@lancemarchetti8673
@lancemarchetti8673 4 ай бұрын
Cool! I've created a jpeg bomb of 530 bytes that renders 4 billion pixels to the screen when opened. It freezes my laptop.. lol. I achieved this neat trick in Notepad ++ by accident when editing the Hex values in the dimensions sector of the code....
@jackflowt
@jackflowt 5 ай бұрын
Great explanation!
@BradenJohnYoung
@BradenJohnYoung 5 ай бұрын
Great explanation
@Evercreeper
@Evercreeper 5 ай бұрын
Excellent video
@headlights-go-up
@headlights-go-up 5 ай бұрын
great explanation!
@prinnydadnope5768
@prinnydadnope5768 5 ай бұрын
Very clear, thank you again
@nnutipa
@nnutipa 5 ай бұрын
Thanks. But the most interesting part with pipe and fork itself were not covered:( You said pipe is what actually creates a fork bomb, but why?
@patocarrasco6266
@patocarrasco6266 5 ай бұрын
yeah, I also missed that. In my head, the second argument is waiting for the given input by the first one, so it should remain inactive. The only thing that I know is that the prior is wrong xD
@prontomatias3081
@prontomatias3081 5 ай бұрын
look at @rogo7330 comments
@DerMigi
@DerMigi 5 ай бұрын
@@patocarrasco6266this is the exact same question I have. Does anyone have an answer?
@Turalcar
@Turalcar 4 ай бұрын
Piped processes are launched by bash in parallel
@VivekYadav-ds8oz
@VivekYadav-ds8oz 5 ай бұрын
Cant you do the same thing without the pipe? It feels like f(){f&}; f should do the same job. If you want to increase the forks exponentially, just have each function run two other ones like so: f(){f&; f&}; f
@ktheveg
@ktheveg 5 ай бұрын
Might be written with a pipe to make things neater or smaller
@prontomatias3081
@prontomatias3081 5 ай бұрын
look at @rogo7330 comments
@chawrx3
@chawrx3 5 ай бұрын
keep it up brother, have a nice day everyone
@okunamayanad
@okunamayanad 5 ай бұрын
i understood the fork bomb at 1:00 great title
@ABaumstumpf
@ABaumstumpf 5 ай бұрын
You can do the same on Windows, but normally the system does not outright crash and you can recover from that (with taskmanager).
@warchild3948
@warchild3948 5 ай бұрын
" this is the initial call to fork me" How did you say that with a straight face.. Cuz I am rolling 😂 😂
@takuya.yagami.
@takuya.yagami. 5 ай бұрын
Great video
@iskuben88
@iskuben88 5 ай бұрын
great video! Brings back memories of crashing uni sun-ray clients ;)
@SomeGuyInSandy
@SomeGuyInSandy 5 ай бұрын
You have to love it!
@mrdzha9519
@mrdzha9519 4 ай бұрын
thanks, it was interesting!
@Apersonl0l
@Apersonl0l 5 ай бұрын
so it's basically how all my recursion functions go? :))))
@Baltr
@Baltr 5 ай бұрын
are you able to pipe it multiple times inside the same command to make it crash the system faster?
@alexholker1309
@alexholker1309 5 ай бұрын
I don't think it would make a meaningful difference. You'd crash the system in fewer generations, but it would take longer to resolve each instance of the process.
@cepi24
@cepi24 5 ай бұрын
How did you replace semicolons with text?
@iangraham6730
@iangraham6730 5 ай бұрын
Noice 👌 Thanks for sharing 👍
@davidserrano2091
@davidserrano2091 5 ай бұрын
Time to run it on my system
@SoreBrain
@SoreBrain 5 ай бұрын
It's tempting
@connorallen162
@connorallen162 5 ай бұрын
Oh THAT's why you don't want everything to be run by the root user
@macethorns1168
@macethorns1168 5 ай бұрын
The only reason I was confused when I first saw this was that I didn't know you could use a colon as a function name. It makes much more sense as f(){f|f&};f It seems many modern 'nux systems default to limiting the number of forks a process can start now.
@saptamdutta
@saptamdutta 4 күн бұрын
hey guys i want to know what other pranks have u done like this?
@repairstudio4940
@repairstudio4940 5 ай бұрын
Awesomeness 🎉
@joey3070
@joey3070 4 ай бұрын
Delightful
@willmckeand
@willmckeand 5 ай бұрын
Pipe bomb would've been a great name for this
@garrysingh4484
@garrysingh4484 5 ай бұрын
Awesome 👍
@richarduton
@richarduton 5 ай бұрын
This isn't a fork bomb it's a picture of a cat.
@victorsubbiah6077
@victorsubbiah6077 4 ай бұрын
shouldn't proliferating dummy processes just hang the system forever? why would it crash the system anyway?
@tobiashelbing1233
@tobiashelbing1233 5 ай бұрын
Great!
@L-Coder
@L-Coder 5 ай бұрын
type the command 'gnome-terminal' (or any other command that opens a bash shell) in the end of the .bashrc file and save it and then see the magic when you open a terminal.😂 You might to do it in the .zshrc file depending on the type of shell you are using (bash or zsh = Bourne Again Shell or Z shell).
@GeorgeAlexanderTrebek
@GeorgeAlexanderTrebek 5 ай бұрын
Spoon Nuke next plz
@bashisobsolete.pythonismyn6321
@bashisobsolete.pythonismyn6321 5 ай бұрын
when you use fish shell for several good reasons and the "expert professionals" roll their eyes at you.
@EnglishRain
@EnglishRain 5 ай бұрын
Nice didn't know you could limit number of processes for a user
@sam_ldm
@sam_ldm 5 ай бұрын
what if i write this in my bashrc ?
@Alex-cb5go
@Alex-cb5go 22 күн бұрын
do you need the &?
@mynameismynameis666
@mynameismynameis666 5 ай бұрын
forbidden emojis are teh most powahful
@DUMBDUDEGAMER
@DUMBDUDEGAMER 5 ай бұрын
I wonder how this does on WSL
@docker31c
@docker31c 5 ай бұрын
So i got trolled in a stackoverflow question...
@hkkis7836
@hkkis7836 5 ай бұрын
Could you please show your hotkeys for the editor?
@Drogobo
@Drogobo 5 ай бұрын
what do you mean by "friends on linux"?
@m3sm4r2010
@m3sm4r2010 5 ай бұрын
fyi: i have tested this code on my android phone and it works 😂
@RlainTheFirst
@RlainTheFirst 5 ай бұрын
What about :(){:&;:&);: Also exponential or linear?
@patfre
@patfre 5 ай бұрын
It will do the same as at 4:25
@louisdrouard9211
@louisdrouard9211 5 ай бұрын
Does not :(){:&;:&} do the same thing (without pipe) ?
@shahfaisal3923
@shahfaisal3923 5 ай бұрын
you won a subscriber
@adrianbool4568
@adrianbool4568 5 ай бұрын
Fork me, that was a good video! ;-)
@devviz
@devviz 5 ай бұрын
if you set the video playing speed fast enough you can almost hear "fork me" to another very similar term
@HiddenTreasure-xj7yt
@HiddenTreasure-xj7yt 5 ай бұрын
I made a batch bomb in the 90s.
@Cassandra_Johnson
@Cassandra_Johnson 5 ай бұрын
ah yes, for(;;){fork();} good times...
@cni_povkit
@cni_povkit 5 ай бұрын
"Fork me". That's what she said.
@KangJangkrik
@KangJangkrik 5 ай бұрын
Ran this on production server for fun, bos didn't seem really enjoy it
@The_Pariah
@The_Pariah 5 ай бұрын
So you watched Dave's Garage and made your own fork bomb video. K.
@philipzhu5194
@philipzhu5194 5 ай бұрын
What happens if instead of piping, you start 2 background processes each time? like :(){:&:&};:
@rebel478
@rebel478 5 ай бұрын
Oh no I'm wrong, your right eyebrow is still always higher than the other one
@mikerope5785
@mikerope5785 5 ай бұрын
i was sad when browsers started detecting and halting infinite javascript recursions
@kiyasuihito
@kiyasuihito 5 ай бұрын
Hilarious 🎉
@iuhere
@iuhere 5 ай бұрын
stress testing without a stop 🛑 button 😅
@danielbaker1248
@danielbaker1248 2 ай бұрын
Fork me, this is interesting!(:
@K_Forss
@K_Forss 5 ай бұрын
I remember my first attempt at a fork bomb, it was perhaps 15 years ago in high school and I wrote it in C, it didn't really work too well, I probably had some more advanced scheduler than I thought and while it slowed down my computer I was able to still kill the process. But I added a small malloc (about 4k if I remember correctly) in the loop ant it totally freezed my computer in seconds. Fun times Edit: If I had known more when I was young I'd probably done a mix of forking and daemonizing to try to hit it harder
@cmoor8616
@cmoor8616 5 ай бұрын
Reminds me of the prankster batch files for cmd.exe I used to make during my windows years. The simplest I managed to create (DO NOT RUN THIS) %0 >> %0 %0 With an empty line after,
@chromosome24
@chromosome24 4 ай бұрын
I prefer the spoon bomb
@ai-spacedestructor
@ai-spacedestructor 5 ай бұрын
the VM setup is questional, you said you had to restart your system and the VM. sounds like you gave it too much pc resources or using some vm i never heard about before which doesnt asign a limited number of resources in order to run it.
@EngineerMan
@EngineerMan 5 ай бұрын
I only had to restart the VM, not my whole system.
@ai-spacedestructor
@ai-spacedestructor 5 ай бұрын
@@EngineerMan you did say in the video something about your vm and the whole system after it crashed. might have misunderstood but to me it did sound like you said you had to restart the whole system.
@clockblower6414
@clockblower6414 5 ай бұрын
You can fix a lot of problems in Linux by running sudo dd if=/dev/null of=/dev/sda
@Alex-eq1cs
@Alex-eq1cs Ай бұрын
Systemd solution this.... Límite del 30% de procesos máximos del sistema.
@n0tjak
@n0tjak 5 ай бұрын
hi :)
@Angelinajolieshorts
@Angelinajolieshorts 3 ай бұрын
Can you please tecah us these skills. Please 🙏🙏🙏
@florianmattausch8563
@florianmattausch8563 5 ай бұрын
It is Not exponential. it is just times 2.
@patfre
@patfre 5 ай бұрын
Exponential is repeated multiplication. So it is exponential because it is multiplying by 2 over and over
@enty-3035
@enty-3035 3 ай бұрын
%0|%0 is the windows version it is fun
@colonthree
@colonthree 5 ай бұрын
Cat :3
@rebel478
@rebel478 5 ай бұрын
How is your eyebrow straight again
@googleuser4720
@googleuser4720 5 ай бұрын
Is your name a Daniel?
@cruz1ale
@cruz1ale 5 ай бұрын
fork bombs are for dorks
@MrGeekGamer
@MrGeekGamer 5 ай бұрын
"There is ways" There are.
@mikebresnahan8682
@mikebresnahan8682 5 ай бұрын
Being an old fart, I have to point out that the fork bomb existed prior to linux, albeit with the same shell syntax you describe. en.wikipedia.org/wiki/Fork_bomb
@darienverdugo290
@darienverdugo290 5 ай бұрын
What if i run it on an instance 🥸
Configuring Passwordless Server Login Using SSH
8:02
Engineer Man
Рет қаралды 23 М.
Showing a Craigslist scammer who's boss using Python
5:27
Engineer Man
Рет қаралды 6 МЛН
Маленькая и средняя фанта
00:56
Multi DO Smile Russian
Рет қаралды 5 МЛН
Why? 😭 #shorts by Leisi Crazy
00:16
Leisi Crazy
Рет қаралды 46 МЛН
КАК СПРЯТАТЬ КОНФЕТЫ
00:59
123 GO! Shorts Russian
Рет қаралды 2,7 МЛН
Cat story: from hate to love! 😻 #cat #cute #kitten
00:40
Stocat
Рет қаралды 13 МЛН
Linux File System/Structure Explained!
15:59
DorianDotSlash
Рет қаралды 4 МЛН
Become a shell wizard in ~12 mins
12:25
CODE IS EVERYTHING
Рет қаралды 208 М.
Why You Shouldn't Nest Your Code
8:30
CodeAesthetic
Рет қаралды 2,5 МЛН
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 559 М.
ZIP BOMBS vs. Windows
10:36
FlyTech Videos
Рет қаралды 1,5 МЛН
Tmux has forever changed the way I write code.
13:30
Dreams of Code
Рет қаралды 894 М.
how NASA writes space-proof code
6:03
Low Level Learning
Рет қаралды 2 МЛН
30 Windows Commands you CAN’T live without
14:35
NetworkChuck
Рет қаралды 2,1 МЛН
3 Types of Algorithms Every Programmer Needs to Know
13:12
ForrestKnight
Рет қаралды 433 М.
Gitlab DELETING Production Databases | Prime Reacts
17:27
ThePrimeTime
Рет қаралды 295 М.
Which Phone Unlock Code Will You Choose? 🤔️
0:14
Game9bit
Рет қаралды 12 МЛН
wyłącznik
0:50
Panele Fotowoltaiczne
Рет қаралды 22 МЛН