Xenia rule

169 points · 20 comments · view on lemmy.world

20 Comments

KokusnussRitter@discuss.tchncs.de · 38 pts · 148d (10 replies)

opens terminal, pauses So how fucked is my system gonna be afterwards?

cypherpunks@lemmy.ml · 31 pts · 148d (3 replies)

:(){ :|:& };: is a classic fork bomb for bash (and other shells which allow : as a function name).

running it will likely cause your system to need to be rebooted.

Voroxpete@sh.itjust.works · 48 pts · 148d

For those curious as to how this works...

Part one is ':()'. This creates a new function named ':'. That's because we start with the name, ':', then the open and closed brackets (this is where you put any inputs the function expects), which is the shell syntax for creating a function.

Part two is '{ :|:& }'. This creates the content of the function. The curly braces define the beginning and end of the content. Everything inside them is the function itself. The first part of the actual function is ':', so it's literally running itself. On its own this would just mean it runs forever doing nothing. But then we have a '|' (pipe) character; this takes the output of the previous command and feeds it into the input of the next one. The next command is another ':', so it's calling itself again. What this means is that every time ':' gets called, it calls itself twice. The last part of the function is an '&' character so that the second call of the function gets run in the background. So now every time this loop runs we create two copies of our program (yes, this is a program, just a very simple one), which each create two copies, and so on.

Finally, we have the last characters / commands. The first is a ';' (semi-colon) which means "After doing that, do this." That allows us to continue on to the last command, which is ':' again. So, having defined our endlessly multiplying function, we finally run it for the first time, setting off the entire self-replicating loop. Endless copies of this tiny program will run themselves infinitely, eating up all our RAM and CPU time and crashing the PC.

In practice, modern Linux systems have an upper limit on the number of processes that can run, so if your system resources are high enough it won't crash, just struggle.

AI_toothbrush@lemmy.zip · 3 pts · 148d (1 reply)

Why is the pipe required tho?

cypherpunks@lemmy.ml · 9 pts · 148d

Why is the pipe required tho?

it isn't really. what is required for it to consume memory very rapidly is for each invocation of the function to call itself more than once. using the pipe is just one way to do this; it would work just as well if the pipe character were replaced with an &

TabbsTheBat@pawb.social · 27 pts · 148d (3 replies)

If you're referring to the cat, it's a fork bomb. IIRC your system should realize what's going on and terminate the process before your PC commits seppuku, unless your system is really old. Either way I wouldn't recommend running it

atomicbocks@sh.itjust.works · 11 pts · 148d (2 replies)

A similar attack used to be able to be done in Windows by creating a batch file that calls itself at the end.

We used to do it where it would open the command prompt several times and then call itself, so after a couple seconds you would have dozens or hundreds of command prompt windows opening. On a system that only had 128 megs of RAM it didn’t take long for the system to become unresponsive.

trackball_fetish@lemmy.wtf · 7 pts · 147d (1 reply)
:loop
notepad.exe
goto loop

Then place the .bat in the startup folder

atomicbocks@sh.itjust.works · 2 pts · 147d

Pulling the script out of the vague recesses of my brain, what we did was more like:

ECHO pwned!
start /c start.bat
start /c start.bat
start /c start.bat
start.bat

Then make a shortcut, call it Internet Explorer with the blue E, and wait.

I also wrote a script that would create 1000 folders in your network drive and then change the owner so you couldn’t delete them. We used that one when people left their machine unlocked.

joyjoy@lemmy.zip · 5 pts · 148d

You'll get a syntax error because bash functions require a space after the {

panda_abyss@lemmy.ca · 3 pts · 148d

It’ll be fine after a reboot, or a killall -9 command

genuineparts@infosec.pub · 20 pts · 148d (4 replies)

Hm... fish: command substitutions not allowed here Strange name for a cat

u9000@lemmy.blahaj.zone · 6 pts · 148d (2 replies)

Curious if f(){;f|f&};f works in fish. The version in the image is bash specific, but iirc fish isn't posix compliant so idk if posix version works

genuineparts@infosec.pub · 5 pts · 148d

Nope. Still doesn't work.

fish: command substitutions not allowed in command position. Try var=(your-cmd) $var ...
f(){;f|f&};
 ^^
skrunkek@lemmy.world · 4 pts · 147d

Fish has a more explicit syntax so we would need something like function :;:&;:&;end;: But sadly it notices and stops it

scottmeme@sh.itjust.works · 5 pts · 148d

🐟🐟🐟

Smorty@lemmy.blahaj.zone · 10 pts · 148d (1 reply)

this was already posted 3 days ago!

oh well ~ ~ ~<3

festnt@sh.itjust.works · 1 pts · 145d

i knew it wasn't just deja vu...

u9000@lemmy.blahaj.zone · 6 pts · 148d

That's actually a bashism (defining : as a function name). For maximum damage, use f(){;f|f&};f

DmMacniel@feddit.org · 3 pts · 148d

Why do all my forks suddenly explode?! What have you done!