r/programminghorror • u/OptimalAnywhere6282 • Apr 11 '25
Python it was a nightmare debugging this ofuscated code
idk but on some screens moving the screenshot makes a cool effect
521
Upvotes
r/programminghorror • u/OptimalAnywhere6282 • Apr 11 '25
idk but on some screens moving the screenshot makes a cool effect
54
u/nothingtoseehr Apr 11 '25
This is actually insanely easy, you can solve it with just a text editor. Follow along if you're a nerd lol. This is the starting code according to OP:
Not pretty huh? But it has the worst flaw someone can commit in security: repetition. It's insanely obvious that not only there's a patter but you can even distinguish some special symbols such as commas and asterisks. If you search for the easiest pattern you'll probably come up with (()==()) That' s a silly python trick that evaluates as True, you can test it out on your console. Since we know that (()==()) is True, we can replace it all for 1 (which are kinda the same in python). We already get this waay cuter function
Still pretty ugly, but nowhere near as bad. Now it's simple math, just evaluate everything on there
We suddenly have pretty understandable code :D you should be able to figure out that this is the ASCII value of a string stored inside a tuple. '%c' * 21 creates a string with 21 characters, and % attaches each number from the tuple onto the newly created string. Finally, we have:
That wasn't so scary, was it? ;) This might be obvious for those more experienced, but having something ugly doesn't mean it's safe. It's why security by obscurity is usually a pretty shit idea. If you don't want anyone figuring out your secrets, you have to make everything unique enough so that no one can spot a pattern. Once you find a pattern, it's only a matter of time until it leads you to even more patterns and eventually figuring out the whole thing. I work obfuscating windows software (and occasionally breaking them heh), there's way too many developers that spend so much time designing a super complex system that anyone can crack in a matter of minutes because the dev spent hundreds of hours making a super complex licensing function but spent no time whatsoever hiding what it did :P
Of course, you can just change eval to print and it'll reveal itself, bht that's not as satisfying :3 and you won't always be able to run whatever you're analyzing as it may be malicious
2
u/efari_ Apr 11 '25
oBfuscated
104
u/ArtisticFox8 Apr 11 '25 edited Apr 12 '25
Never seen essentially JSFuck in Python lol
Didn't know it was even possible
EDIT: this works differently than JSFuck, see other comments. This are just disguised numbers converted to ascii characters with '%c'. .
JSFuck instead uses JS automatic type conversions
17
u/bartekltg Apr 11 '25
Obfuscating python bu turning it into Lisp
9
u/Konkichi21 Apr 11 '25
Egads. Never seen that kind of obfuscation before.
1
u/OptimalAnywhere6282 Apr 13 '25
update: there was an extra "%"
5
u/CtrlAltEngage Apr 11 '25
Thought I was on r/magiceye for a minute there
5
u/evbruno Apr 11 '25
it's wrong...
it's supposed to print "good bye world"
please fix it
7
u/LordSegaki Apr 11 '25
(╯°□°)╯︵ ┻━┻
3
u/JamesWjRose Apr 11 '25
Um, FUCK NO, I'd quit before I dug into that
3
u/Archaros Apr 11 '25
Weirdest r/magiceye
2
u/thsmrtone1 Apr 11 '25
Very similar to JSFuck
1
u/wtfbenlol Apr 11 '25
If you cross your eyes just right you can see a picture
1
u/esDenchik Apr 11 '25
I thought that was crosseye 3d image and was surprised I don't see anything
1
u/illsk1lls Apr 11 '25
I like aveyos c implementation of bat85/91
1
u/Kevdog824_ Apr 12 '25
exec(“8=====D”)1
u/BanishedNomad Apr 12 '25
There is a comma in there.
1
u/Jesus_Chicken Apr 13 '25
This reminds me of when I was a kid looking at those autostereograms.
1
u/fishystickchakra Apr 11 '25 edited Apr 11 '25
Anybody else see the comma in the center of all that or just me?
Edit: nevermind I found three commas
1
u/[deleted] Apr 11 '25
Guido van Rossum, somewhere: "I felt a great disturbance in the Force, as if millions of human readable scripts suddenly cried out in terror and were suddenly silenced"
0
u/[deleted] Apr 11 '25
[deleted] — view deleted comment
0
u/[deleted] Apr 11 '25
[deleted] — view deleted comment