Comment On ANDY=NO

"Years ago," Mark wrote, "and long before I had started working there, the lead developer at my company tendered his resignation and starting up a firm of his own. It was a one-man consultancy built to service a single client: his former employer. They had little choice in retaining his services as, prior to leaving, he intentionally obfuscated all of the code. [expand full text]
« PrevPage 1 | Page 2 | Page 3Next »

Re: ANDY=NO

2009-01-16 10:32 • by CaptainChaos
First

Re: ANDY=NO

2009-01-16 10:33 • by lurgar (unregistered)
FIRST=NO

Re: ANDY=NO

2009-01-16 10:34 • by Kluge Doctor (unregistered)
MYCOMMENT=WTF?

Re: ANDY=NO

2009-01-16 10:35 • by snoofle
Oh come on, once you figure out stupid patterns like that, why not just stream edit it to at least put in proper spacing and parentheses (and of course, test compile).

Then it's just a matter of dealing with stupid variable names. And even those, once deciphered can be stream edited into what they actually represent.

Lots of work? Yup. But it can be done with a little (ok maybe a lot) of determination. Been there, done that.

Edit: I see that Irish Girl - The Sequel - is back :)

Re: ANDY=NO

2009-01-16 10:48 • by masonreloaded (unregistered)
The real WTF is that they "retained" the old developer's services after he intentionally sabotaged their code...

Re: ANDY=NO

2009-01-16 10:50 • by Bob Dole (unregistered)
239507 in reply to 239505
Seems rather trivial at that point you notice that... Hell, building a keyword library and inserting whitespace into the formatting should only take a few hours...days if the variant of VB has tons of weird/unique keywords. Then, variable by variable, you can find/replace X with more useful names. I admit the variable replacing thing might take awhile because you have to manually figure out what they all are, but if you just do it as you open code, I'd bet you'd only waste a few minutes in each piece of code.

Pretty-printer? Re: ANDY=NO

2009-01-16 10:53 • by Marcin (unregistered)
Why didn't you write a pretty-printer?

Re: ANDY=NO

2009-01-16 10:54 • by Ken B (unregistered)
IFC=ZTH ("if (c==z) then")
Given that THEN/TH is optional (according to the post), what if you have a "ZTH" variable? Is that "if ( c == z ) then" or "if (c == zth)"?
Eww.

Re: ANDY=NO

2009-01-16 10:55 • by geORge (unregistered)
239510 in reply to 239507
Bob Dole:
Seems rather trivial at that point you notice that... Hell, building a keyword library and inserting whitespace into the formatting should only take a few hours...days if the variant of VB has tons of weird/unique keywords.
But what do you do if geORge and sANDy are actual variable names? That might make the stream editing at least a little ... interesting, shall we say?

Re: ANDY=NO

2009-01-16 10:57 • by Marcin (unregistered)
239511 in reply to 239510
You might need to use...some kind of non-context-free parser. If only unix came with a library for that, or if there were text-processing languages that were capable of that.

Re: ANDY=NO

2009-01-16 10:58 • by Code Slave (unregistered)
Andy walks with me, Andy talks with me

Re: ANDY=NO

2009-01-16 10:59 • by DangerMouse9
Wouldn't copying it all and pasting it into a text document fix the spacing issues while trying to read through it?

that way if a space on the compiler were say 1 pixel, but would be the full character size in a text editor you'd be able to read it and not wonder who the fuck Andy was.

Re: ANDY=NO

2009-01-16 11:02 • by gurhall (unregistered)
239514 in reply to 239513
DangerMouse9:
Wouldn't copying it all and pasting it into a text document fix the spacing issues while trying to read through it?

that way if a space on the compiler were say 1 pixel, but would be the full character size in a text editor you'd be able to read it and not wonder who the fuck Andy was.


I honestly don't know whether to explain it to you or punch you.

Re: ANDY=NO

2009-01-16 11:04 • by NiceWTF (unregistered)
The real WTF's:

1. Lawsuit time!
2. Apparently they didn't have CVS/SVN logs nor even backups to revert the obfuscation?
3. Even then I'd as a matter of principle rather rewrite the entire thing than hire the services of such an asshole.

Re: ANDY=NO

2009-01-16 11:05 • by dave (unregistered)
Pity they didn't use source control so they could just check out the version before it was obfuscated

Re: ANDY=NO

2009-01-16 11:09 • by Marcin (unregistered)
239517 in reply to 239515
NiceWTF:
The real WTF's:

1. Lawsuit time!
2. Apparently they didn't have CVS/SVN logs nor even backups to revert the obfuscation?
3. Even then I'd as a matter of principle rather rewrite the entire thing than hire the services of such an asshole.


Maybe they could have hired him, then delayed payment. Possibly ensured that no orders were ever placed in writing, that sort of thing, and then found out who had the upper hand.

Re: ANDY=NO

2009-01-16 11:11 • by greg (unregistered)
239518 in reply to 239505
snoofle:
Oh come on, once you figure out stupid patterns like that, why not just stream edit it to at least put in proper spacing and parentheses (and of course, test compile).

Then it's just a matter of dealing with stupid variable names. And even those, once deciphered can be stream edited into what they actually represent.


s/stream edit/sed/

Re: ANDY=NO

2009-01-16 11:15 • by Anon (unregistered)
239519 in reply to 239510
geORge:
Bob Dole:
Seems rather trivial at that point you notice that... Hell, building a keyword library and inserting whitespace into the formatting should only take a few hours...days if the variant of VB has tons of weird/unique keywords.
But what do you do if geORge and sANDy are actual variable names? That might make the stream editing at least a little ... interesting, shall we say?


This is true, but at least one piece of software, the interpreter is able to understand this shit. Therefore, it must be possible, in theory, to write another piece of software that can parse the source and spit out something more readable (i.e. with whitespace). Presumably this particular version of basic must have some restriction on variable names like geORge or sANDy.

Re: ANDY=NO

2009-01-16 11:23 • by IMSoP (unregistered)
239520 in reply to 239519
Anon:
geORge:
But what do you do if geORge and sANDy are actual variable names? That might make the stream editing at least a little ... interesting, shall we say?


This is true, but at least one piece of software, the interpreter is able to understand this shit. Therefore, it must be possible, in theory, to write another piece of software that can parse the source and spit out something more readable (i.e. with whitespace). Presumably this particular version of basic must have some restriction on variable names like geORge or sANDy.


Precisely - I'm pretty sure many versions of BASIC only allowed variable names consisting of a single letter, or a single letter followed by a single digit.

So you could define 'variable' as /[A-Z][0-9]?/ and 'keyword' as /AND|OR|IF|THEN|TH/ etc, and from there it doesn't seem that impossible to produce a set of rules for basic pretty-printing.

Re: ANDY=NO

2009-01-16 11:24 • by shadowphiar (unregistered)
I'll never get used to not living next door to Andy.

Re: ANDY=NO

2009-01-16 11:24 • by biziclop (unregistered)
239522 in reply to 239510
geORge:
Bob Dole:
Seems rather trivial at that point you notice that... Hell, building a keyword library and inserting whitespace into the formatting should only take a few hours...days if the variant of VB has tons of weird/unique keywords.
But what do you do if geORge and sANDy are actual variable names? That might make the stream editing at least a little ... interesting, shall we say?


The same thing a BASIC interpreter does. And what every normal human (using the western alphabet) does. Read it from left to right.

Come on, tokenizing BASIC code is easy, some interpreters even de-tokenize/beautify it for you. In fact, most of them only store the tokenized form, so a LIST usually displays standard layout source code.

Re: ANDY=NO

2009-01-16 11:26 • by Loren Pechtel (unregistered)
LAWSUIT=YES

Re: ANDY=NO

2009-01-16 11:27 • by biziclop (unregistered)
239524 in reply to 239513
DangerMouse9:
Wouldn't copying it all and pasting it into a text document fix the spacing issues while trying to read through it?

that way if a space on the compiler were say 1 pixel, but would be the full character size in a text editor you'd be able to read it and not wonder who the fuck Andy was.


No, sadly that doesn't work. But if you print the code out, place it on a wooden table...

Re: ANDY=NO

2009-01-16 11:29 • by mallard
239525 in reply to 239510
geORge:
Bob Dole:
Seems rather trivial at that point you notice that... Hell, building a keyword library and inserting whitespace into the formatting should only take a few hours...days if the variant of VB has tons of weird/unique keywords.
But what do you do if geORge and sANDy are actual variable names? That might make the stream editing at least a little ... interesting, shall we say?


It probably needs whitespace before the keyword, but doesn't require it after, which of course means that you probably can't have variable names that begin with "OR" or "AND". Since this thing is unlikely to have the usual lex/parse structure, other keywords are probably immune.

Re: ANDY=NO

2009-01-16 11:31 • by Throknor
239527 in reply to 239519
Do they not teach BASIC anymore? The old ones I used were simple left to right tokenizers. While they required spaces, their symbols could not be used as variables. And as I recall AppleBASIC would pre-tokenize so in the stored file AND would actually be a single character.

I have no idea what this interpreter would do with GEORGE, but it should be easy to test and design a pseudo-parser that works the same way and inserts spaces.

If you have the language set, it should be a straightforward matter. Read a file straight through and throw spaces around keywords. Test if the program still works. Repeat on code as you need to interact with it.

Straightforward - not easy.

Re: ANDY=NO

2009-01-16 11:36 • by Anonymous (unregistered)
Could he have just compiled the obfuscated code then decompile the compiled code back into source? It should be more legible at that point.

Re: ANDY=NO

2009-01-16 11:36 • by biziclop (unregistered)
239531 in reply to 239527
Throknor:
Do they not teach BASIC anymore? The old ones I used were simple left to right tokenizers. While they required spaces, their symbols could not be used as variables. And as I recall AppleBASIC would pre-tokenize so in the stored file AND would actually be a single character.

I have no idea what this interpreter would do with GEORGE, but it should be easy to test and design a pseudo-parser that works the same way and inserts spaces.

If you have the language set, it should be a straightforward matter. Read a file straight through and throw spaces around keywords. Test if the program still works. Repeat on code as you need to interact with it.

Straightforward - not easy.


This.

It does my head in how people can't think in anything other than regular expressions anymore. You don't need anything like that for a BASIC interpreter, let alone yacc or lex and friends. All you need is to read character after character into a buffer and check if you have a valid token or not. Even a ten year old kid should be able to do it.

Re: ANDY=NO

2009-01-16 11:38 • by biziclop (unregistered)
239532 in reply to 239530
Anonymous:
Could he have just compiled the obfuscated code then decompile the compiled code back into source? It should be more legible at that point.


It's an interpreter, you haven't got compiled code on disk. But you do have tokenized code in memory and you should be able to list it in a standard readable format, most of the time simply by typing in LIST.

Re: ANDY=NO

2009-01-16 11:38 • by dtech
239533 in reply to 239516
dave:
Pity they didn't use source control so they could just check out the version before it was obfuscated

If it was all basic, it was probably before source-control was widely being used.

Re: ANDY=NO

2009-01-16 11:39 • by Matt S. (unregistered)
Too bad Ctrl + K then D wouldn't work with Basic, because then that consultant would be out of a(nother) job!

Re: ANDY=NO

2009-01-16 11:46 • by Peter (unregistered)
I was rather expecting to find that Andy was the name of the original developer, and that when Mark changed the mysterious string to "ANDY=YES", the code magically became readable. That would have been neat (and would have enabled the company to dispense with the blackmailer's services). Pity.

Re: ANDY=NO

2009-01-16 11:51 • by Andy Goth
COMPUTER OVER.

ANDY = VERY YES.

Re: ANDY=NO

2009-01-16 11:52 • by Sutherlands (unregistered)
239537 in reply to 239515
NiceWTF:
The real WTF's:

1. Lawsuit time!
2. Apparently they didn't have CVS/SVN logs nor even backups to revert the obfuscation?
3. Even then I'd as a matter of principle rather rewrite the entire thing than hire the services of such an asshole.
Basically this

Re: ANDY=NO

2009-01-16 12:03 • by Joe (unregistered)
239538 in reply to 239512
Andy tells me I am his own!

Re: ANDY=NO

2009-01-16 12:04 • by Charles400
Well, I don't have to obfuscate my code... it looks like shit naturally!

Re: ANDY=NO

2009-01-16 12:13 • by DemonWasp
239540 in reply to 239531
biziclop:
...Even a ten year old kid should be able to do it.


Along that same line of thinking, you could just hire dozens of 10-year-olds at a low hourly wage to fix the code for you.

Re: ANDY=NO

2009-01-16 12:18 • by ML (unregistered)
I wonder if this "off-brand" BASIC was actually Commodore BASIC, which was very highly popular in the early 1980's. To quote Wikipedia:

Commodore BASIC keywords could be abbreviated by entering at least one letter, and then a shifted version of the next letter on. In the default text mode, this shifted character appeared as a graphics symbol; e.g. the GOTO command could be abbreviated G{Shift-O} (which resembled GΓ onscreen). In cases of ambiguity, more unshifted letters of the command were needed, such as GO{Shift-S} (GO♥) being required for GOSUB since G{Shift-O} was already taken.

[...]

Commodore BASIC lines did not need any spaces except where omitting one would be ambiguous, and in fact most Commodore BASIC programs were written with no spaces, e.g., 100IFA=5THENPRINT"YES":GOTO160 . Omitting spaces as such would lead to a more compact program, since the tokenizer never removes any space inserted between keywords: the presence of spaces results in extra 0x20 bytes in the tokenized program which are merely skipped during execution.

Re: ANDY=NO

2009-01-16 12:19 • by NH (unregistered)
That kind of system is best resolved by rewriting the whole thing in a better language.

You don't always need the source code of a piece of software - sometimes it's better to analyze what it does.

Re: ANDY=NO

2009-01-16 12:23 • by SeaDrive (unregistered)
Following along with other commenters, I think it would not have been to hard to de-obfuscate. My first thought is that it may have been an off-brand BASIC, but if it was still BASIC, then moving it directly into a mainstream product should have resulted in code with only a few kinds of errors related to the compatibility issues.

Since most BASIC interpreters did tokenize the keywords, I wonder if that capability had been turned off, or if some whitespace options were used to do the obfuscation in the first place.

Re: ANDY=NO

2009-01-16 12:27 • by me (unregistered)
239544 in reply to 239513
DangerMouse9:
that way if a space on the compiler were say 1 pixel, but would be the full character size in a text editor you'd be able to read it and not wonder who the fuck Andy was.


This... is priceless.

Re: ANDY=NO

2009-01-16 12:34 • by Tom (unregistered)
239545 in reply to 239514
gurhall:
DangerMouse9:
Wouldn't copying it all and pasting it into a text document fix the spacing issues while trying to read through it?

that way if a space on the compiler were say 1 pixel, but would be the full character size in a text editor you'd be able to read it and not wonder who the fuck Andy was.


I honestly don't know whether to explain it to you or punch you.


Best. Answer. Ever.

*claps*

Re: ANDY=NO

2009-01-16 12:41 • by dpm
239546 in reply to 239521
shadowphiar:
I'll never get used to not living next door to Andy.
Bob was there, too.

Re: ANDY=NO

2009-01-16 12:43 • by Anonym (unregistered)
239547 in reply to 239541
ML:
I wonder if this "off-brand" BASIC was actually Commodore BASIC, which was very highly popular in the early 1980's. To quote Wikipedia:

Commodore BASIC keywords could be abbreviated by entering at least one letter, and then a shifted version of the next letter on. In the default text mode, this shifted character appeared as a graphics symbol; e.g. the GOTO command could be abbreviated G{Shift-O} (which resembled GΓ onscreen). In cases of ambiguity, more unshifted letters of the command were needed, such as GO{Shift-S} (GO♥) being required for GOSUB since G{Shift-O} was already taken.

[...]

Commodore BASIC lines did not need any spaces except where omitting one would be ambiguous, and in fact most Commodore BASIC programs were written with no spaces, e.g., 100IFA=5THENPRINT"YES":GOTO160 . Omitting spaces as such would lead to a more compact program, since the tokenizer never removes any space inserted between keywords: the presence of spaces results in extra 0x20 bytes in the tokenized program which are merely skipped during execution.


The abbreviations are automatically expanded, the same thing is stored in memory if you enter "GO♥" or "GOSUB". Also, commands can't span multiple lines in Commodore BASIC.

Re: ANDY=NO

2009-01-16 12:44 • by JamesQMurphy
239548 in reply to 239506
masonreloaded:
The real WTF is that they "retained" the old developer's services after he intentionally sabotaged their code...

Agreed. The companies I worked for had me sign an agreement that says I wouldn't do this kind of stuff.

Besides, doesn't the IRS frown on this type of arrangement? If you are a consultant but working for your former employer, I think they may still consider you "employed" for tax reasons. (I am not an accountant or tax specialist.)

Re: ANDY=NO

2009-01-16 12:55 • by Herman (unregistered)
Just copy paste the code in Word and give it a nice format, like 'Comic Sans'.

Captcha = tristique, short for three pieces of antique.

Re: ANDY=NO

2009-01-16 13:01 • by Grimoire
239553 in reply to 239514
gurhall:
DangerMouse9:
Wouldn't copying it all and pasting it into a text document fix the spacing issues while trying to read through it?

that way if a space on the compiler were say 1 pixel, but would be the full character size in a text editor you'd be able to read it and not wonder who the fuck Andy was.


I honestly don't know whether to explain it to you or punch you.

To avoid the hassle of a debate, I recommend you explain it to him while you punch him.

Re: ANDY=NO

2009-01-16 13:09 • by tragomaskhalos (unregistered)
239554 in reply to 239541
ML:
I wonder if this "off-brand" BASIC was actually Commodore BASIC, which was very highly popular in the early 1980's. To quote Wikipedia:

Commodore BASIC keywords could be abbreviated by entering at least one letter, and then a shifted version of the next letter on. In the default text mode, this shifted character appeared as a graphics symbol; e.g. the GOTO command could be abbreviated G{Shift-O} (which resembled GΓ onscreen). In cases of ambiguity, more unshifted letters of the command were needed, such as GO{Shift-S} (GO♥) being required for GOSUB since G{Shift-O} was already taken.
Please tell me that people pronounced this stuff as written, eg "Mmmm, you forgot to go-heart the initialisation subroutine", or even "Go-gamma considered harmful" :-)

Re: ANDY=NO

2009-01-16 13:11 • by FORK=ATOM (unregistered)
I always liked FORK=ATOM which would do highly different things on different implementations of BASIC.

Re: ANDY=NO

2009-01-16 13:16 • by chosenken (unregistered)
239556 in reply to 239514
gurhall:
DangerMouse9:
Wouldn't copying it all and pasting it into a text document fix the spacing issues while trying to read through it?

that way if a space on the compiler were say 1 pixel, but would be the full character size in a text editor you'd be able to read it and not wonder who the fuck Andy was.


I honestly don't know whether to explain it to you or punch you.


Usually punching works better.

Re: ANDY=NO

2009-01-16 13:26 • by barfoo
239557 in reply to 239556
In Zen, punching IS explaining.
« PrevPage 1 | Page 2 | Page 3Next »

Add Comment