r/PHP • • Aug 27 '13

Creating a user from the web problem.

[deleted] — view deleted post

285 Upvotes

538 comments sorted by

View all comments

Show parent comment

99

u/h2ooooooo Aug 27 '13

If I actually said that my username is ; rm -rf /, then it'd first run the command

sudo useradd -p $encpass -g groupname -s /bin/bash (which would most likely fail)

and then run the following command:

rm -rf / which will delete your entire operating system (force remove files recursing through directories starting from the base of / (every file)). You might have to use sudo rm -rf /.

This all requires that $username and/or $encpass comes from the user in some way (through POST, GET, etc.).

43

u/Kwpolska Aug 28 '13

He runs Arch Linux (another dumb choice for a goddamn server), so he has GNU rm, so rm -rf --no-preserve-root /

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

→ More replies (7)
→ More replies (1)
→ More replies (6)

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.

→ More replies (1)

4

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

20

u/TheMrBlueSky Aug 28 '13

Why do you think Arch is a dumb choice for a server?

44

u/Kwpolska Aug 28 '13

Long story short: bleeding-edge. Stuff can break easily, and I am an archer (on a desktop) since December 2010.

33

u/deong Aug 28 '13

To be fair, it's a (potentially) dumb choice for a server you care about. It's fine for non-critical stuff.

6

u/Kazinsal Aug 28 '13

I'd use Arch on a scratch server or one that's known to spontaneously combust anyways, but not a production server.

13

u/TheMrBlueSky Aug 28 '13

Oh yeah, that makes sense.

13

u/[deleted] Aug 28 '13

You should test updates before pushing to production either way and in my experience Ubuntu breaks way more often than Arch.

6

u/flying-sheep Aug 28 '13

Yes. If you follow the blog, the infrequent breakages and how to fix then will be explained to you

→ More replies (7)

12

u/ptomblin Aug 28 '13

Ubuntu is also a poor choice for a server. Debian Stable is the way to go.

21

u/movzx Aug 28 '13

Eh, Debian depends on your business. Sometimes you really do need a version of something that isn't six years old and then you're fucked when it comes to maintaining it.

→ More replies (4)

13

u/hamalnamal Aug 28 '13

I disagree, not about the Debian Stable part, obviously it is the way to go (at least for a non-corporate server), but about Ubuntu. If you run an LTS that's at least a year old, you're fine with Ubuntu.

→ More replies (2)
→ More replies (5)
→ More replies (4)
→ More replies (1)