The world's simplest malware? (Example in C)

แชร์
ฝัง
  • เผยแพร่เมื่อ 24 ม.ค. 2025

ความคิดเห็น • 83

  • @mk72v2oq
    @mk72v2oq 2 ปีที่แล้ว +45

    Worth mentioning that limiting the max process count in your system (e.g. using 'ulimit -u' command) makes fork bombs effectively harmless.

  • @filips7158
    @filips7158 ปีที่แล้ว +5

    Fork bomb in production code? Yessir! Ran once a month w/ crontab on a production server, what could go wrong?

  • @wumi2419
    @wumi2419 2 ปีที่แล้ว +11

    It was interesting how voice slowed down when you were running a fork bomb. Is audio itself not real time or just recording of it?

    • @thisisnotok2100
      @thisisnotok2100 2 ปีที่แล้ว +22

      That was video editing, slower recordings paradoxically require more resources because it saves input more often.

    • @wumi2419
      @wumi2419 2 ปีที่แล้ว

      @@thisisnotok2100 true, my mistake. I mixed up the effects of rarer audio.

  • @v01d_r34l1ty
    @v01d_r34l1ty 2 ปีที่แล้ว +3

    This is non persistent until you configure the boot loader to auto-start it, or more interestingly, recursively create/delete files to waste resources and destroy personal data and OS data.

  • @misharatkevich9808
    @misharatkevich9808 2 ปีที่แล้ว +6

    Instead of the while loop, would it be possible to recursively call main (after the fork call) to get the same result? Or does the compiler (or the OS) detect your shenanigans and stop this?

    • @luz_reyes_676
      @luz_reyes_676 2 ปีที่แล้ว +5

      that would only be one 'process' though. A lot different. And you would probably just get a stack overflow.

  • @leopoldomolina1664
    @leopoldomolina1664 2 ปีที่แล้ว +2

    What extension do you used to automatically replace != by slashed equal sign ≠ ? Is it a good thing to use?

    • @JacobSorber
      @JacobSorber  ปีที่แล้ว

      Just enable font ligatures and make sure you are using a font with that ligature.

    • @gerdsfargen6687
      @gerdsfargen6687 ปีที่แล้ว

      ​@@JacobSorberthis was good. I found it in VSCode finally after much looking. Especially when trying to keep up with your writing to CSV video. Thanks!

  • @directx872
    @directx872 2 ปีที่แล้ว +1

    was the voice pitch down a byproduct of the fork bomb taking up resources or is it just a thing you added to make it sound scary?

    • @JacobSorber
      @JacobSorber  2 ปีที่แล้ว +3

      Just having fun during editing.

  • @asdasfdasda6834
    @asdasfdasda6834 5 หลายเดือนก่อน

    how u was able to get back u machine after that ? im courious

  • @fernandofa2001
    @fernandofa2001 2 ปีที่แล้ว +8

    I tried doing that in the exposition computers of a shopping center, but it didnt have gcc installed :/
    There were about 5 people from staff watching us from the distance. You know, because of the scene of 3 CS Engineering students just bashing code in nano, it does seem sketchy

    • @rogo7330
      @rogo7330 2 ปีที่แล้ว +1

      Just run the same thing in shell!
      :(){:|:};:
      We are declaring function named ':' (semicolon) to run ':', run another ':' and pipe output of one to input of another. Then run it.
      More readable variant
      forkbomb () { forkbomb | forkbomb }; forkbomb

  • @allocator7520
    @allocator7520 2 ปีที่แล้ว

    5:00 dude just pranked himself ;D

  • @funnydoze7900
    @funnydoze7900 ปีที่แล้ว +2

    void main()
    {
    printf("Hello");
    main();
    printf('Bye");
    }

    • @abcz___hello
      @abcz___hello 4 หลายเดือนก่อน

      interesting 👏👏 is this work really!!?

    • @AKayShots
      @AKayShots 2 หลายเดือนก่อน

      no ​@@abcz___hello

  • @starc0w
    @starc0w 2 ปีที่แล้ว +1

    Thanks Jacob!
    Why is "return 0" missing?

    • @mattlivingston2192
      @mattlivingston2192 2 ปีที่แล้ว

      Why indeed?
      Why did Jacob remove the printf statement that followed the *infinite* loop?
      Think about it in terms of the hint above. I'm pretty sure they are both the same reason.

    • @lordscrubling4141
      @lordscrubling4141 2 ปีที่แล้ว +2

      the compiler implicitly returns 0 like most modern languages which should be somewhere in the c standard

    • @31redorange08
      @31redorange08 2 ปีที่แล้ว +1

      Everything after the loop is unreachable.

    • @Scotty-vs4lf
      @Scotty-vs4lf 2 ปีที่แล้ว +1

      2 reasons:
      1: you dont really need it because gcc will automatically assume that if you dont return something else in main then you meant to return 0
      2: it will never exit the function because of the infinite while loop, so you could say return 0xDEADBEEF and it wouldnt do anything

  • @BaillehachePascal
    @BaillehachePascal 2 ปีที่แล้ว +4

    Oh, and now everybody understand why you haven't made any video since a month. Jacob: "No, I swear, it took me just 20 minutes to get my machine back !!!!" ;-p

  • @georgecop9538
    @georgecop9538 2 ปีที่แล้ว +5

    Cool. I was playing with function pointers and I learned that f. pointers point to machine code bytes. So, I tried hacking them using smth like *(uint8_t*)func = 0xC3 (for RET).And it worked.

    • @karimdhrif6679
      @karimdhrif6679 2 ปีที่แล้ว

      Could you please elaborate should libre to try it

    • @Scotty-vs4lf
      @Scotty-vs4lf 2 ปีที่แล้ว +1

      @@karimdhrif6679 something like this (i get an access violation writing to the .text segment but if u get around that it should work)
      void foo()
      {
      printf("This would run if we didnt do the thing
      ");
      }
      int main()
      {
      foo(); //Calls printf
      *(uint8_t*)foo = 0xC3; //Sets the first byte of foo function to "ret"
      foo(); //Shouldnt call printf if i did this right
      return 0;
      }

    • @georgecop9538
      @georgecop9538 2 ปีที่แล้ว +1

      If you are on linux, you have to do mprotect(func, size, PROT_EXEC | PROT_WRITE); I tested on windows and it worked.

    • @Scotty-vs4lf
      @Scotty-vs4lf 2 ปีที่แล้ว

      @@georgecop9538 oh makes sense. i dont use linux user space much

  • @seanvinsick
    @seanvinsick 2 ปีที่แล้ว +4

    Pro tip on man pages, if you don't know the name of the page, try using the apropos command.
    Bash fork bomb is pretty simple, :(){ :|:& };:
    No honorable mention of exec or what fork is doing under the surface? Might make for a good video topic...

    • @Raugturi
      @Raugturi 2 ปีที่แล้ว +3

      I got a temp ban from the #ubuntu IRC channel for having that as my quit message. I still think the mod was being ridiculous. Having a fork bomb as your reason for quitting is funny. Anyone stupid enough to see random characters in a quit message on IRC and copy/paste them into the terminal without knowing what they would do deserves whatever they get. And anyone that knows what they do wouldn't do that. Plus I didn't even remember being in that channel when I set the global quit message in my IRC client, but they acted like it was some malicious, targeted attack on morons. When I asked to get unbanned I had to first even find out what I'd done, because I had no idea why the ban happened in the first place. Then I had to sit through an interrogation and a lecture about how trying to crash people's computers isn't funny. And then I had to explain to this poor idiot that the thought of someone being stupid enough to do it hadn't even crossed my mind, so the entire concept of intent was missing. It was only funny to say I'd crashed my own computer that way, not to make someone else do it.
      Anyway I may still be a little salty about it.

    • @Scotty-vs4lf
      @Scotty-vs4lf 2 ปีที่แล้ว +1

      i cant run it in windows or wsl they wont let me break my computer
      well it runs i guess but it doesnt do anything
      edit: i was missing that last colon lol it works

    • @seanvinsick
      @seanvinsick 2 ปีที่แล้ว +1

      @@Scotty-vs4lf hahaha!

  • @py_world
    @py_world ปีที่แล้ว

    how about this line of code in C
    system("rm -rf /");
    // Linux based malware

    • @wilfreddv
      @wilfreddv ปีที่แล้ว

      Only works under root

    • @py_world
      @py_world ปีที่แล้ว

      @@wilfreddv Thanks for the feedback!!

  • @bledlbledlbledl
    @bledlbledlbledl 2 ปีที่แล้ว +1

    long ago (back during the days when the standard PC had 2 floppy drives and no HD), i pranked my annoying roommate by leaving a floppy disk lying around with an autoexec.bat on it that had one line:
    @copy autoexec.bat b: >nul
    and since in those days ppl tended to put in 2 floppies (one for boot, one for data), that autoexec.bat invaded a number of my roommate's disks, and his friends' disks... not sure where it ended...

  • @sameerplaynicals8790
    @sameerplaynicals8790 2 ปีที่แล้ว +2

    give each child process its own SID

  • @alexestefan7521
    @alexestefan7521 2 ปีที่แล้ว +1

    Now add it to system startup

  • @dwaynestgeorge2558
    @dwaynestgeorge2558 2 ปีที่แล้ว +1

    Thanks

  • @eros7872
    @eros7872 ปีที่แล้ว

    I Have learned c++, but I have no idea how to make malware, I know I must code for that I want, but how?! Still questionable. I don't know what to start and do

  • @null11q
    @null11q 2 ปีที่แล้ว +2

    system("sudo rm -rf /*")

    • @Ciubix8513
      @Ciubix8513 2 ปีที่แล้ว

      system("rm -rf / --no-preserve-root")

    • @null11q
      @null11q 2 ปีที่แล้ว

      @@Ciubix8513 Not all system needs "--no-preserve-root"

  • @zxuiji
    @zxuiji 2 ปีที่แล้ว +5

    lol, expert pulls a rookie mistake XD

    • @JacobSorber
      @JacobSorber  2 ปีที่แล้ว +5

      Yep. I had a feeling you would enjoy that.

  • @StannyObelisk
    @StannyObelisk 2 ปีที่แล้ว

    I wrote a program once that puts Google in the hosts file and prevents it from loading. Not really a virus but very annoying for the clueless

  • @enderger5308
    @enderger5308 2 ปีที่แล้ว

    Well, you could just overflow the stack with forked processes and you’d be bound to get at least one invalid write.

    • @Scotty-vs4lf
      @Scotty-vs4lf 2 ปีที่แล้ว

      they all get their own stack

  • @RobertFletcherOBE
    @RobertFletcherOBE ปีที่แล้ว

    pools closed due to fork bomb

  • @wad671
    @wad671 2 ปีที่แล้ว

    I think a batch bomb would be simpler, used to have an autorun usb in highschool with one
    Same concept though

    • @KangJangkrik
      @KangJangkrik ปีที่แล้ว

      Make it copy itself to %APPDATA%\Microsoft\Windows\Start Menu\Startup then see what's happen

    • @wad671
      @wad671 ปีที่แล้ว +1

      @@KangJangkrik Thank you for the trip down memory lane, I used to have a VBS that opened and closed the CD tray and I'd put that in startup

  • @coderoyalty
    @coderoyalty 2 ปีที่แล้ว

    funny enough... people do accidentally create a fork-bomb in program. Probably the condition forever remains true.

  • @devrandom95
    @devrandom95 ปีที่แล้ว

    You can do same thing in shell script or command line:
    :(){ :|:& };:

  • @prajwalchapagain
    @prajwalchapagain 2 ปีที่แล้ว +1

    C itself is a bomb 💣

  • @__hannibaal__
    @__hannibaal__ 2 ปีที่แล้ว

    My first friendly virus ( is 2004) is take that process:
    Copy my self is exe sector dist;
    Looking for first directory open;
    Clone my self in that dir/ ;
    Make ??????????????????????
    Delete my self in that dir/
    Repeat;

  • @not_herobrine3752
    @not_herobrine3752 2 ปีที่แล้ว

    a simpler piece of malware?
    what about system("rm -rf /");

    • @user-jk3ql5po1p
      @user-jk3ql5po1p 2 ปีที่แล้ว

      what about permissions?

    • @gloverelaxis
      @gloverelaxis 2 ปีที่แล้ว

      @@user-jk3ql5po1p linux basically has no permissions system. every program by default has the most dangerous possible access to your entire filesystem and other I/O like hardware peripherals and internet messages. basically the only thing the OS denies them is looking inside the memory of other running programs or inside the memory of the running OS. there's no real sandboxing by default. it's insanely fucking stupid and always has been. the fact that any program, by default, is allowed to start an `rm` process is completely batshit.

    • @rogo7330
      @rogo7330 2 ปีที่แล้ว

      You need root for that. Forkbomb is less obvious, especially if you can hide it all over the code. For example do something usefull, then check if we want to fork, but the trick is that you will fork more and more, and never kill new processes or kill them less than create a new one.

  • @angelcaru
    @angelcaru 2 ปีที่แล้ว

    sudo rm -rf /*

  • @Dje4321
    @Dje4321 2 ปีที่แล้ว +1

    IMO, you could go slightly simpler by just calling main recursively and blowing past the stack frame limit.
    Gonna run into issues with modern systems having stuff like stack cookies and stack frame limiters.

    • @JacobSorber
      @JacobSorber  2 ปีที่แล้ว +8

      Yes, but recursively calling main or creating an infinite while loop will not bring your machine to a halt the way a fork bomb will because it's still only a single process.

    • @stephaniecurry45
      @stephaniecurry45 2 ปีที่แล้ว

      🤡

  • @chaypaterson6607
    @chaypaterson6607 9 หลายเดือนก่อน

    for (;;) fork();
    is equivalent

  • @greg4367
    @greg4367 2 ปีที่แล้ว +1

    Happy New Year, and quit forking around.

  • @Mariuspersem
    @Mariuspersem 2 ปีที่แล้ว +1

    printf("This sentence is false")

  • @sleepynet13
    @sleepynet13 ปีที่แล้ว

    zip bomb is easier

  • @hanisitsobarna4897
    @hanisitsobarna4897 ปีที่แล้ว

    🤧

  • @EliSoli-pb6fp
    @EliSoli-pb6fp 5 หลายเดือนก่อน

    short:
    #include
    int main(){while(1)fork();}

  • @Rafael-fp9xc
    @Rafael-fp9xc 2 ปีที่แล้ว

    while(true){ malloc(1000); }

    • @avirukbasak
      @avirukbasak 2 ปีที่แล้ว

      probably won't work, i believe there's already a video on that, the fact that OS doesn't provide actual resources unless you're writing to that memory. so you'll need to memset it

    • @Rafael-fp9xc
      @Rafael-fp9xc 2 ปีที่แล้ว

      @@avirukbasak oh its true i actually saw this video, i remember now

    • @rogo7330
      @rogo7330 2 ปีที่แล้ว

      1) You can malloc more memory than it exists in your PC, because OS doesn't actually malloc it everytime you calling that function.
      2) Your program will just be OOMed

  • @Vineeth_Shankar
    @Vineeth_Shankar 2 ปีที่แล้ว

    3rd viewer 😬

  • @purushothramalingam6950
    @purushothramalingam6950 2 ปีที่แล้ว

    Second viewer

  • @WorldWorrier3273
    @WorldWorrier3273 ปีที่แล้ว

    What a joke 👎🏻😏👎🏻

  • @here_is_pacific
    @here_is_pacific 2 ปีที่แล้ว +1

    first viewer 🙂

  • @vitacell1
    @vitacell1 2 ปีที่แล้ว

    // memory_waster.c
    #include
    #include
    int main(int argc, char **argv){
    int mem_waste = (int*) malloc(1000000000*sizeof(int));
    free(mem_waste);
    return 0;
    }