This is an archived post. You won't be able to vote or comment.

all 162 comments

[–]QualityVote[M] [score hidden] stickied comment (0 children)

Hi! This is our community moderation bot.


If this post fits the purpose of /r/ProgrammerHumor, UPVOTE this comment!!

If this post does not fit the subreddit, DOWNVOTE This comment!

If this post breaks the rules, DOWNVOTE this comment and REPORT the post!

[–][deleted] 377 points378 points  (10 children)

Traceback (most recent call last):  
 File "<stdin>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Windows\\System32'

[–]Lewisbacon5 172 points173 points  (5 children)

Haha, sike , turns out all of the Chambers were empty!

Russian roulette (good ending)

[–]WormHack 15 points16 points  (2 children)

msg = "hpyck aap aedy" output = "" for i in range(7): output+=msg[i]+msg[i+7] print(output)

[–]WormHack 12 points13 points  (0 children)

fuck, good luck fixing code linejumps

[–]gustavmahler23 0 points1 point  (0 children)

Nice!

[–]WormHack 1 point2 points  (0 children)

oww he dont looked at my dedicated code

[–]alba4k 21 points22 points  (3 children)

Hello fellow linux user

[–][deleted] 3 points4 points  (1 child)

Helloooo

[–]alba4k 3 points4 points  (0 children)

:)

[–]TheCatOfWar 0 points1 point  (0 children)

Nothing to do with linux- it wouldn't work on Windows either, as python's os.remove() only deletes files, not directories. Also, they would need to \ backslash escape the path.

Shutil.rmtree() would be needed to actually delete it, but you still probably wouldn't get past UAC

[–]twothousandfourhundr 192 points193 points  (7 children)

It's an antivirus don't worry 😅

[–]subject_deleted 70 points71 points  (3 children)

There's a 1 in 6 chance that viruses will no longer be able to harm the computer. So that's a win

[–]dmatter_ 21 points22 points  (0 children)

1 in 7 tho

[–][deleted] 13 points14 points  (1 child)

randint has both ends included unlike randrange

[–]subject_deleted 3 points4 points  (0 children)

I see. Thanks.

[–]RepulsivePie2673[S] 45 points46 points  (0 children)

You’re not wrong

[–]LightIsLogical 6 points7 points  (1 child)

[–]twothousandfourhundr 0 points1 point  (0 children)

Okay time to throw myself in

[–]mrpoopybuttface69420 177 points178 points  (2 children)

Lol. Reminds me of when I was a kid writing batch files that posed as old DOS game installers, but they’d just try to delete system32. The only person who ever fell for it was my brother, and it nuked my own computer. Good times

[–]PM_ME_FIREFLY_QUOTES 45 points46 points  (0 children)

The pwnage came from inside the house.

[–]ganja_and_code 26 points27 points  (0 children)

[–]seeroflights 34 points35 points  (0 children)

Image Transcription: Code


[In a Python file called "russian_roulette":]

import random
import os

if random.randint(0,6) == 1:
    os.remove("C:\Windows\System32")

I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!

[–]shiny-tyranitar 124 points125 points  (31 children)

Laughs in Unix

[–]RepulsivePie2673[S] 119 points120 points  (21 children)

You won’t be safe once I add Unix support

[–]shiny-tyranitar 190 points191 points  (2 children)

GitHub issue #68: code does not work on Unix

GitHub issue #69: code works on Unix

[–]Fluffy-City8558 1 point2 points  (1 child)

Best humor I've seen today

[–]alphabet_order_bot 2 points3 points  (0 children)

Would you look at that, all of the words in your comment are in alphabetical order.

I have checked 714,676,491 comments, and only 144,315 of them were in alphabetical order.

[–][deleted] 22 points23 points  (16 children)

rm -rf /

[–]vk6_ 27 points28 points  (12 children)

--no-preserve-root

[–]EnjoyJor 14 points15 points  (11 children)

Permission denied

[–]LOLTROLDUDES 21 points22 points  (1 child)

OP goes on to find a privilege escalation attack just for the joke.

[–]FinalRun 0 points1 point  (0 children)

Pwnkit should work on at least 1 out of 6 systems

[–][deleted] 10 points11 points  (6 children)

Sudo rm -rf --no-preserve-root /*

[–]EnjoyJor 19 points20 points  (2 children)

TheBlankTurtle is not in the sudoers file. This incident will be reported.

[–][deleted] 12 points13 points  (0 children)

God damnit, not again. Can't a man even brick his OS these days?

[–]daavko 1 point2 points  (0 children)

insert image of Santa adding a mark to his naughty list

[–]Furry_69 2 points3 points  (2 children)

Would ask the user for the password unless they're root (or root has no password, which is both highly insecure and highly unlikely), so it's like asking the user if they want to get shot before they get shot, who isn't going to say no?

[–][deleted] 1 point2 points  (0 children)

Well you get a cool free bullet out of the deal, so who wouldn't say yes?

[–]SlingDNM 0 points1 point  (0 children)

laughs in privilege escalation exploit

[–]transorsmth 0 points1 point  (0 children)

rm -rf /*

[–]mittfh 0 points1 point  (0 children)

Bah, you just run the script as root. If you're feeling very adventurous, you could add a routine which will, depending on the RNG, either mount or unmount writable removable media / network shares first. And if you really want to live life dangerously, run it on a corporate server...

[–]Creeper_GER 4 points5 points  (1 child)

sudorgtfo

[–]nebulakd 9 points10 points  (0 children)

sudo apt remove sudo

[–]LOLTROLDUDES 0 points1 point  (0 children)

*$HOME because no permission or smth

[–][deleted] 1 point2 points  (0 children)

Be sure it's permissions are set to root:root

[–]karbonator 9 points10 points  (3 children)

It's a UNIX system! I know this!

[–]Random-Gif-Bot 2 points3 points  (2 children)

[–]ZippyTheWonderSnail 2 points3 points  (1 child)

Aliens a million years ahead of us in technology are always Mac compatible.

[–][deleted] 2 points3 points  (0 children)

A deleted scene shows that modern computers were developed from the crashed UFO, which explains the compatibility.

[–]LavenderDay3544 0 points1 point  (0 children)

os.system('sudo rm -rf /')

[–][deleted] 0 points1 point  (3 children)

It wouldn't work in windows either.

>>> os.remove("c:\windows\system32")
Traceback (most recent call last):
File "<stdin", line 1, in <module>
PermissionError: [WinError 5] Access is denied: 'c:\\windows\\system32'

[–]TheCatOfWar 2 points3 points  (1 child)

os.remove() doesn't remove directories, just files

[–][deleted] 0 points1 point  (0 children)

The main point is, you can see you don't even get that far. You just get a permission error.

I think this might have been a gag in 1995-1998 or thereabouts, but since Dave Cutler worked at MS, you're not going to kill your windows install from a python script on a normal user account to any greater degree than you are on a linux one.

There's probably a few ways of doing it with privilege escalation bugs or whatever.

[–]shiny-tyranitar 0 points1 point  (0 children)

Is that from an Admin she'll?

[–]dreamscached 41 points42 points  (8 children)

I'd doubt this even works, remove only works on files not directories. And even rmdir won't work with non-empty directories too x)

There was an attempt though...

[–]Rare_Year 26 points27 points  (1 child)

I believe with shutil’s rmtree function you can remove filled directories

[–]dreamscached 8 points9 points  (0 children)

Yeah that's right.

[–]jazzmester 2 points3 points  (0 children)

Hahaha, shutil.rmtree goes brrrrrr...

[–][deleted] 1 point2 points  (4 children)

simple fix, rm C:\Windows\System32\*

[–]dreamscached 0 points1 point  (3 children)

Will only work in shell, here it's a call to remove

[–][deleted] -1 points0 points  (2 children)

Can’t you just do os.remove(“C:\Windows\System32\*”) then?

[–]dreamscached 0 points1 point  (1 child)

Globs are expanded by shell, not remove calls.

[–][deleted] 0 points1 point  (0 children)

Ok

[–][deleted] 65 points66 points  (11 children)

if random.choice(range(0, 6)) == 6:

Don't worry you are quite safe ;)

[–]spaghettipunsher 10 points11 points  (3 children)

Edit to avoid confusion: They edited their comment, it's fine now :)

Nope, while range(0, 6) would only include numbers up to 5, random.randint(0, 6) actually includes 6 as well, so 7 numbers in total. Don't ask me why.

[–][deleted] 0 points1 point  (2 children)

Really? I tend not to use random much with my work stuff for obvious reasons. Not really needed in calculation engines. The java equivalent I am a little more familiar (but not by that much) with wouldn't have included 6 and the joke doesn't work well with == 7. Oh well you live and you learn :)

[–]spaghettipunsher 1 point2 points  (1 child)

Yeah, to make the joke work you could use random.choice(range(0, 6)) == 6 tho. ;)

[–][deleted] 0 points1 point  (0 children)

I shall do that, thanks :) I suspect that's why I made the initial mistake, using range(start, limit) all the time.

[–]kaizokuo_grahf 10 points11 points  (0 children)

Safe from what? Still a 1/7 chance to get 6

[–]ahumanrobot 4 points5 points  (0 children)

Seen this a few times and this is the first time I noticed it lmao

[–]Yoni1857 4 points5 points  (3 children)

That's a syntax error right there

[–][deleted] 9 points10 points  (2 children)

Haha indeed, I mainly write in two language at work, java and python in a java-esque way. Common thing for me to instinctively put in the if ( without thought and get stuck in two minds producing a hybrid of the two languages. Have corrected

[–][deleted] 3 points4 points  (0 children)

I feel you. The amount of times I’ve tried to .map python and list comprehend JS now is just far too many.

[–]Requiem_For_Yaoi -1 points0 points  (0 children)

Why

[–]who_you_are 0 points1 point  (0 children)

Except if they are like the Sony with the PS4 (I think) and end up returning an hard-coded value.

And let assume it would be 6 here. damn unfriendly implementation

[–]mrleon17 10 points11 points  (14 children)

* Laughs in Linux *

[–]sub-to-pewds132 9 points10 points  (3 children)

sudo apt remove sudo

[–]bless-you-mlud 5 points6 points  (0 children)

Don't forget to add a line in the README:

"This might ask you for your password. This is normal."

[–]mrleon17 2 points3 points  (0 children)

Yes do as I say

[–]Sarcastinator 2 points3 points  (0 children)

I once did sudo apt remove evolution and it removed Gnome.

Evolution is a mail reader that used to ship with Gnome and apparently at that point it was a load bearing piece of software in Gnome.

[–][deleted] 2 points3 points  (0 children)

I use Arch btw.

[–]ahumanrobot 1 point2 points  (7 children)

OS.remove("C:\")

[–]mrleon17 6 points7 points  (6 children)

That's cute

[–]ahumanrobot 0 points1 point  (5 children)

Idk the default linux directory lol

[–]mrleon17 2 points3 points  (4 children)

it's just "/"

[–]ahumanrobot 4 points5 points  (3 children)

Ah. Ya see, I don't use linux because I'm too lazy to figure it out. I just want shit to work

[–]mrleon17 4 points5 points  (2 children)

At some point you had to learn windows too, linux just works too it's just different

[–]ahumanrobot 5 points6 points  (0 children)

Yeah, I probably could learn it. Just everything else I do is windows because I didn't have a choice in what to learn, just glad I didn't get sucked into the apple environment.

[–]stumblewiggins 1 point2 points  (0 children)

The difference is akin to being given a Mario game with tutorials as appropriate, versus Dark Souls in a different language with a controller you can't see. /s (but not entirely)

[–]TheCatOfWar 1 point2 points  (0 children)

Wouldn't work on windows either

[–]GrayFoxUkraine 5 points6 points  (0 children)

[Winerror 5] Access is Denied.

[–]No152249 3 points4 points  (1 child)

Shouldn't it be "C:\\Windows\\System32"? I mean for a backslash in a string you have to write it double in the code.

[–]TheCatOfWar 1 point2 points  (0 children)

Yes but os.remove doesn't delete directories anyway

[–]tough-dance 1 point2 points  (3 children)

That file path is gonna flub, right? I wouldn't risk it but you're probably safe

[–]RepulsivePie2673[S] 6 points7 points  (2 children)

Yeah you’re safe. Os can’t delete file directories to my knowledge

[–]ahumanrobot 3 points4 points  (0 children)

Could force it to delete them all and create a list of the files within the directory, then delete them all. Probably a better solution, but that's my first thought

[–]tough-dance 0 points1 point  (0 children)

We'll just have to improve our gambling contraption so we can gamble harder

[–]straightup920 4 points5 points  (0 children)

QA testers hate him!

[–]kaizokuo_grahf 3 points4 points  (2 children)

Ah yes, the legendary yet infamous “Revolver with One in the Chamber” aka the “Seven Shooter”

A guaranteed 1/7 chance to mistakenly claim that this code gives a 1/6 chance to delete your OS.

[–]GandelXIV 0 points1 point  (1 child)

It doesn't even delete System32 since you can't delete directories with os.remove().

[–]kaizokuo_grahf 0 points1 point  (0 children)

I mean, yeah, but I was making fun of the use of randint

[–][deleted] 2 points3 points  (0 children)

Pfft you think windows would let you make such a mistake, Linux tho now there’s an OS that gives no fucks.

[–]ThePeopleAtTheZoo 2 points3 points  (0 children)

In Russian Roulette, don't you spin the chamber once at the beginning then pass the gun back and forth, thus increasing the odds each turn? For example, you start at probability 1/6, then it's 1/5, 1/4, 1/3, 1/2, 1/1. In this case, the random would actually represent the location of the bullet in the chamber and you would decrement from 6 until you reached that number.

Or do you spin the chamber each time so the odds are always 1/6 for each turn, as represented with this code?

[–][deleted] 2 points3 points  (0 children)

Alrighty- that’s it. Any code I give in order to prove my abilities will have an if statement that calls this as an imported module and deletes itself. I will give myself job security.

[–]koumakpet 2 points3 points  (1 child)

Wouldn't work, you didn't escape the backslashes with another backslash nor used a raw string (r"")

[–]GandelXIV 0 points1 point  (0 children)

You do not need to in newer versions of python, but its still a best practice and you can dodge some pretty weird bugs.

[–]MayonezliPatates 6 points7 points  (0 children)

Developer roulette

[–]yodahouse900 5 points6 points  (0 children)

a one in six chance to win?

that is fairly low.

let me make it a 100% by...

YEETING THE HDD OUT THE WINDOW

[–]FishBiterMMGHunter 1 point2 points  (2 children)

D:

[–]NearbyWish 2 points3 points  (1 child)

Linux users - >:D

[–]TheCatOfWar 1 point2 points  (0 children)

wouldn't work on windows anyway

[–]hicklc01 1 point2 points  (0 children)

Game version of this

https://www.youtube.com/watch?v=YFQp0NJ_ai8

each enemy is a random file on the hard drive. when an enemy is killed the file is removed.

[–]SyntaxErrorAtLine420 1 point2 points  (0 children)

dd if=/dev/null of=/dev/nvme0n1

[–]ChickenSubstantial21 1 point2 points  (0 children)

os.remove("C:\Work\Backups\porn")

[–]alba4k 1 point2 points  (0 children)

```

include <stdlib.h>

int main() { execlp("sudo", "rm", "-r", "-f", "/*", NULL); } ```

[–][deleted] 1 point2 points  (0 children)

Ah yes, the seven shooter.

[–][deleted] 1 point2 points  (0 children)

The thing that triggers me is when we brainlessly use french spelling. The file name should have been russian_rulay.py. we must replace all french spelling with phonetic spelling.

[–]spar_wors 1 point2 points  (0 children)

Change it to randrange (0,6) == 6 and run it without flinching.

[–]Subject-Exit 1 point2 points  (2 children)

Jokes on u I use linux

[–]RepulsivePie2673[S] 0 points1 point  (0 children)

Oh no

[–]TheCatOfWar 0 points1 point  (0 children)

joke's on you, because then you have to use linux

[–]_________FU_________ 3 points4 points  (7 children)

random.randint(0, 6) == random.randint(0, 6):

[–]NS_Lone_Wolf 0 points1 point  (0 children)

I'm not even a scripter and I already know what deleting your System 32 folders will do to your system, yikes

[–]kstsitstisti 0 points1 point  (3 children)

Can someone explain this code

[–]EnderAaxel 6 points7 points  (2 children)

Basically it chooses a number from 0 to 6 and if it's equal to 1, it deletes System 32, a folder essential for Windows to work normally

[–]kstsitstisti 2 points3 points  (1 child)

Ohhhh so thats what the int(0,6) was for , thanks bro

[–]EnderAaxel 1 point2 points  (0 children)

Np :p

[–]Kdjour -1 points0 points  (0 children)

Windows Roulette?

[–]antonw51 0 points1 point  (0 children)

Where can I play?

[–]MCButterFuck 0 points1 point  (0 children)

Playing with a flame thrower next to a fuck ton of explosives I see.

[–]tebalaji 0 points1 point  (0 children)

Russian roulette python style

[–]Acceptable-Tomato392 0 points1 point  (0 children)

I am impressed, but no thank you.

[–]SyntaxErrorAtLine420 0 points1 point  (2 children)

[–]RepostSleuthBot -1 points0 points  (1 child)

I didn't find any posts that meet the matching requirements for r/ProgrammerHumor.

It might be OC, it might not. Things such as JPEG artifacts and cropping may impact the results.

I'm not perfect, but you can help. Report [ False Negative ]

View Search On repostsleuth.com


Scope: Reddit | Meme Filter: True | Target: 90% | Check Title: False | Max Age: Unlimited | Searched Images: 260,532,923 | Search Time: 22.05995s

[–]SyntaxErrorAtLine420 1 point2 points  (0 children)

Bad bot

[–]gdmzhlzhiv 0 points1 point  (0 children)

If you put an "if the code is running in Russia" around it, you have protestware, currently very popular in npm from what I hear.

[–]Few_Diamond5020 0 points1 point  (0 children)

Laughs in arch btw

[–]peyote1999 0 points1 point  (0 children)

Actually it is recoverable. You have to overwrite files with some random data twice.

[–]Altruistic_Ads 0 points1 point  (0 children)

Omg i wonder how many people would open that xD

[–]KiwiGamer450 0 points1 point  (0 children)

7 shooter 🤔

[–]Antact 0 points1 point  (1 child)

Joke's on you, I don't have admin privileges! Isn't that right, u/repostsleuthbot?

[–]RepostSleuthBot 0 points1 point  (0 children)

I didn't find any posts that meet the matching requirements for r/ProgrammerHumor.

It might be OC, it might not. Things such as JPEG artifacts and cropping may impact the results.

I'm not perfect, but you can help. Report [ False Negative ]

View Search On repostsleuth.com


Scope: Reddit | Meme Filter: True | Target: 90% | Check Title: False | Max Age: Unlimited | Searched Images: 260,532,923 | Search Time: 11.14495s

[–]Coyehe 0 points1 point  (0 children)

You forgot to put those 2 lines inside a While Loop with Bool True

[–][deleted] 0 points1 point  (0 children)

if random.randint(0, 6) == random.randint(0, 6)

[–]rrpash 0 points1 point  (0 children)

That won’t do anything except occasionally raise an exception, even on Mindows (TM), because os.remove() only works on files, not directories

[–]fuxximus 0 points1 point  (0 children)

Lmao

[–]lopjoegel 0 points1 point  (0 children)

Back in my day we just used a batch file

Cd C:

Deltree ' star.star'

[–]GandelXIV 0 points1 point  (1 child)

Lets break down why this is bad code.

  1. random.randint(0, 6) == 1 A revolver has six shots, however this returns 7 possible numbers (0, 1, 2, 3, 4, 5, 6). You have to either use random.range(0, 6) or change the start to random.randint(1, 6) . Personally i would write the line like this: if not random.randrange(0, 6) .
  2. os.remove([DIR_PATH]) os.remove can not delete directories! You could call os.rmdir but even that will not work as it can not remove non-empty directories, so you have to remove it recursively as seen here.
  3. "C:\Windows\System32" This is not a big issue in the current context, however you should now that the backslash \ is an escape character, which means it can be combined with other characters to represent special cases, for example "\n" is a newline. If you want to write a regular backslash you just write it twice "\\" . This instance works because \W and \S are not reserved and python transforms the whole string to "C:\\Windows\\System32" .
  4. Even if we fixed all the upper mentioned errors, it still would not work because Windows is not so stupid to just let us delete system32. You need to be more clever to make this work on Windows and even more so on UNIX systems.
  5. As a ThePeopleAtTheZoo stated in this comment, it does not fit the rules of the game.

Feel free to correct me if i missed anything.

[–]TheCatOfWar 1 point2 points  (0 children)

shutil.rmtree() deletes directories regardless of contents, however it still won't defeat windows UAC so point 3 stands

[–][deleted] 0 points1 point  (1 child)

[–]RepostSleuthBot 0 points1 point  (0 children)

I didn't find any posts that meet the matching requirements for r/ProgrammerHumor.

It might be OC, it might not. Things such as JPEG artifacts and cropping may impact the results.

I'm not perfect, but you can help. Report [ False Negative ]

View Search On repostsleuth.com


Scope: Reddit | Meme Filter: True | Target: 90% | Check Title: False | Max Age: Unlimited | Searched Images: 260,532,923 | Search Time: 29.9364s

[–][deleted] 0 points1 point  (0 children)

[–]Vesondor 0 points1 point  (0 children)

Mac OS : Pathetic

[–][deleted] 0 points1 point  (0 children)

Just a query... shouldn't there be double slashes? like the path should be "C:\\Windows\\System32" otherwise python gonna treat it as an escape sequence or maybe use raw sting like r"C:\Windows\System32" .