Live data from Hacker News

Confess HN: Share your Immoral Hacks, Codes or Tweaks

news.ycombinator.com

51–60 of 70 posts

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#51
post #50

Some years ago, doing high performance dense matrix code in C, I replaced a bunch of modulo calls with a bunch of bit operations. You had to work with matrices that were a power of 2 in rows and columns, but you could pad it out and stuff worked. A year later I looked at the code and couldn't figure out how it ever worked in the first place . . .

> A year later I looked at the code and couldn't figure out how it ever worked in the first place . . .

Isn't that the norm ?

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#53
Back in 2000 or so I ran an AOL hacking website called AOL-Files.com. One day, BMB, my confounder, successfully tricked a high level AOL employee into divulging his SecurID pin, which was required in addition to the user's password in order to sign on to their AOL accounts. SecurIDs, FYI, are a keychain-like device that you carry around that displays a six digit number which changes every 60 seconds seconds. AOL used it as an extra layer of security for important accounts.

Anyway, BMB gets this information and signs on to the account. Usually by this time the employee has figured out that you stole his information and is in the process of reporting it, so you don't have much time. BMB immediately attempts to go to the AOL Keyword Manager, which lets certain employees manage where specific AOL keywords take you. As it so happens, this employee had that access (it was very rare).

BMB redirected keyword "Welcome", which normally takes you to the AOL welcome screen, to our site, AOL-Files.com. Every person that signs on AOL, you see, gets automatically sent to keyword "Welcome" when they sign on.

For 20 minutes, every person that signed on AOL got sent to our site. We got 75,000 hits before AOL finally fixed it.

For anyone interested, I've got an archive of AOL-Files up on my site, which has a security breaches section that lists a lot of exploits like this one, including one where we stole every three character AIM name: http://www.mattmazur.com/archive/aol-files/index.html

I no longer support stealing people's stuff, but I still think the keyword Welcome exploit was badass.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#54
post #18

I am writing PHP in Common Lisp, and my codebase is litered with the following: (defun make-record (&rest args) ; insert &allow-other-keys ;-) (let ((*db-auto-sync* t)) (object (make-instance 'record args))) (when object (update-records-from-instance object)))) Both the LET binding of db-auto-sync and the update-records call do the EXACT same thing. However, due to weirdness I don't grok quite yet, the calls to the d…

UPDATE!

I hope no one was misled by the above false alarm; It seems like I have perfected a problem-solving technique known as "debugging through public embarassment". I just seem to catch agonizing problems the moment I write about them online or tell someone about them.

CLSQL:UPDATE-RECORDS-FROM-INSTANCE should NOT be fucked with; I am not sure how it's supposed to operate, but under MySQL, it will update all the records in a table and set them to the same slot-values as the instance. I.e. all identical records!

The feature I needed is cleanly implemented using WITH-TRANSACTIONS. Again, embarassed and sorry for the confusion.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#56
post #50

Some years ago, doing high performance dense matrix code in C, I replaced a bunch of modulo calls with a bunch of bit operations. You had to work with matrices that were a power of 2 in rows and columns, but you could pad it out and stuff worked. A year later I looked at the code and couldn't figure out how it ever worked in the first place . . .

> A year later I looked at the code and couldn't figure out how it ever worked in the first place . . . Isn't that the norm ?

Probably. It actually had the opposite effect on me. I try to keep my code cleaner and more understandable now. I'll stick in better, more expansive comments in difficult spots.

I'll schedule a code review with peers. If I can explain/justify an ugly hack maybe it's not so bad. But sometimes the fundamental "wrongness" of some piece of code just drives me to try and find a better fix. One of those classic trade-offs, elegance vs expediency.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#57
post #56

Earlier quoted context omitted.

> A year later I looked at the code and couldn't figure out how it ever worked in the first place . . . Isn't that the norm ?

Probably. It actually had the opposite effect on me. I try to keep my code cleaner and more understandable now. I'll stick in better, more expansive comments in difficult spots. I'll schedule a code review with peers. If I can explain/justify an ugly hack maybe it's not so bad. But sometimes the fundamental "wrongness" of some piece of code just drives me to try and find a better fix. One of those classic trade-offs,…

Similar experience here. When I look at code I wrote 20 years ago I always get the impression I was a better programmer then than I am today simply because it takes me a lot of time to understand what I was trying to achieve.

My 'new' code looks so simple and direct in comparision. No more trickery with setjmp and longjmp and no more abuse of side effects.

Then I realize that the simplicity is actually better, not the hacks of old.

What is surprising though is that it seems almost as if every generation of programmers has to learn these lessons all over again.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#58
post #22
post #18

I am writing PHP in Common Lisp, and my codebase is litered with the following: (defun make-record (&rest args) ; insert &allow-other-keys ;-) (let ((*db-auto-sync* t)) (object (make-instance 'record args))) (when object (update-records-from-instance object)))) Both the LET binding of db-auto-sync and the update-records call do the EXACT same thing. However, due to weirdness I don't grok quite yet, the calls to the d…

I've always wanted to do sort of the opposite... That is to say, I've always wanted to compile Scheme to PHP. I make the claim that PHP is the web's assembly language. Or, at least it's portable assembly language.

Javascript is the web's assembly language. PHP is the web's BASIC, down to its distribution method. BASIC was typed down from magazines and tutorials, PHP is google, cut and pasted.

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#59
I hacked my son. He was four at the time. My wife sent me off one Saturday purportedly for a "father/son" bonding expedition to buy her Christmas present.

Well, I had seen what my mother-in-law did to kids: set them on her lap and pumped them so dry they squeaked for a week. I figured daughter == mother...

So, little Jeremy and I went shopping. All the way to the store I told Jeremy to not tell Mom what we bought (the hook ;-). At the store, I picked up a CD/alarm clock for Mom's present. Of course, Jeremy couldn't read, so he really didn't know what it was. I asked him if he thought Mom would like a thingamajig, and he thought it was a fine idea (baiting the hook ;-).

All the way home, I emphasized to little Jeremy that he was not to tell Mom that we bought her a thingamajig (setting the hook ;-).

When we got home, I disappeared into another room, but stayed within earshot. Sure enough, Mom got little Jeremy on her lap and started pumping him. He resisted valiantly, but he was only four and cracked after a couple of minutes. "It was a thingamajig!" he said.

CAUGHT! :-D

Re: Confess HN: Share your Immoral Hacks, Codes or Tweaks

#60
I wanted to use a certain drawing program (better than xfig but proprietary) for some of my writing. Since I was too cheap to pay the $10 registration fee I decided to try and crack it. It took an afternoon with OllyDbg to crack the program (from its trail version). This is significant because I haven’t looked at x86 assembly in 10 years.

I don’t know if I should be ashamed or proud.

Post reply on HN