7 ms·
Nothing beats #define TRUE (__LINE__ % 10 != 0)
by usrbinbash 5y ago
Nothing beats
#define TRUE (__LINE__ % 10 != 0)
- fouronnes3 5y agoexport EDITOR=rm
- Svetlitski 5y agoThat’s pure evil.
- marginalia_nu 5y ago#define while if
- toxik 5y agoPerfect balance of harmless and annoying. I would probably never figure it out. Maybe include a cryptic warning so the person eventually looks at it… #define while if #warning "loop flow control substituted for conditional"
- layer8 5y agoThat fails if you have a do ... while.
- toxik 5y agoMay I then suggest... #define if while
- layer8 5y agoThat fails when you have an else. :)
- Akronymus 5y agowould that work? #define while(x) for(;true;)
- layer8 5y agoIt would cause a compile error for do-while loops. And there’s no reason to use `for` here, `while (true)` would do the same (C macros don’t expand recursively in such cases).
- Akronymus 5y agoI guess i would go with this in a header file that includes rand.h instead, then: #define while(cond) while ((cond) && rand() >= somesufficientlysmallnumber)
- toxik 5y ago#define else There!
- layer8 5y agoI think I could devise scenarios where that would fail compilation when `else` is used as a macro argument, but other than that it seems quite solid. :)
- unionpivo 5y agoNo put that into some libc .h file on host :)
- dev_tty01 5y agoI've always liked #define else
- stkdump 5y agoOh, that's good. My favorite: #define while if Of course it will fail for programs that make use of do..while
- wruza 5y agoI'd replace != with ==, so that issue at src.c:380 were unlikely to be reproduced in a reduced case.
- adwn 5y agoI disagree. You want TRUE to be almost always 1. First, if TRUE is almost always 0, the underlying problem will be detected too quickly. Second, this will increase the chance that any seemingly irrelevant change will cause the code to work correctly, making any effort to isolate the bug a frustrating exercise.
- wruza 5y agoI thought I could mess that up in my mind, and indeed I did. Sorry for the noise!
- MadSudaca 5y agoIf only we'd harness all this creative energy for good, humanity would have transcended to a higher plane of existence.
- saimiam 5y agoMaybe the higher place of existence is to find humor in playing subtle pranks on our fellow man. I mean, most fun gods were also pranksters.
- 5y ago
- imglorp 5y agoThat's truly evil. echo "README: No such file or directory" > README
- gpvos 5y agoBack when security was less of a thing and the default $PATH usually included the current directory: echo 'echo ls: command not found' >ls; chmod 755 ls
- mrmattyboy 5y agoHaha nice, so maybe: notfound() { echo "$1: $2: No such file or directory"; } f_cat() { notfound cat "$1"; } f_ls() { notfound ls "$1"; } alias cat=f_cat alias ls=f_ls :D And then why not obfuscate ;) . <(cat <<'EOF' | base64 -d bm90Zm91bmQoKSB7IGVjaG8gIiQxOiAkMjogTm8gc3VjaCBmaWxlIG9yIGRpcmVjdG9yeSI7IH0K Zl9jYXQoKSB7IG5vdGZvdW5kIGNhdCAiJDEiOyB9CmZfbHMoKSB7IG5vdGZvdW5kIGxzICIkMSI7 IH0KYWxpYXMgY2F0PWZfY2F0CmFsaWFzIGxzPWZfbHMK EOF )
- Sohcahtoa82 5y agoA friend of mine was doing a CTF that puts you into a chroot jail. He could see the flag.txt, but trying to `cat flag.txt` was saying "cat: flag.txt: No such file or directory." He was absolutely stumped. I just said, "what if 'cat: flag.txt [...]' is the flag?" Sure enough. That was actually the flag.
- krallja 5y agohexdump -C flag.txt
- Sohcahtoa82 5y agoThe chroot jail did not have access to hexdump. Or vi. Or basically anything other than ls and cat.
- ritter2a 5y agoWhat about adding "echo sleep 0.01 >> ~/.bashrc" to their .bashrc (or whichever shell config file is used)?
- adwn 5y agoI don't get it. What's so bad/annoying about sleeping for 10 milliseconds whenever a new shell is opened? I don't think anyone would notice. "sleep 1000", on the other hand... EDIT: I misunderstood it as executing echo sleep 0.01 >> ~/.bashrc once instead of adding that line to .bashrc – even though that's exactly what you wrote...
- cto_of_antifa 5y agoWouldn't it add another ten Ms every time you opened a new terminal session?
- unionpivo 5y agoyeah its windows 95 simulator :)
- _flux 5y agoThe idea is to add the 'echo ..' to the .bashrc, not just run the command once.
- adwn 5y agoAh, now I get it. Thanks! That's evil, indeed.
- longwave 5y agoIt appends another sleep each time you start a new shell, so it subtly slows down over time.
- VHRanger 5y agowouldn't it do so exponentially? The first time it does it once, the second time the statement is there twice so it does it twice, then 4, 8, 16, etc. ?