- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
First
Admin
FIRST=NO
Admin
MYCOMMENT=WTF?
Admin
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 :)
Admin
The real WTF is that they "retained" the old developer's services after he intentionally sabotaged their code...
Admin
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.
Admin
Why didn't you write a pretty-printer?
Admin
Admin
Admin
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.
Admin
Andy walks with me, Andy talks with me
Admin
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.
Admin
I honestly don't know whether to explain it to you or punch you.
Admin
The real WTF's:
Admin
Pity they didn't use source control so they could just check out the version before it was obfuscated
Admin
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.
Admin
s/stream edit/sed/
Admin
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.
Admin
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.
Admin
I'll never get used to not living next door to Andy.
Admin
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.
Admin
LAWSUIT=YES
Admin
No, sadly that doesn't work. But if you print the code out, place it on a wooden table...
Admin
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.
Admin
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.
Admin
Could he have just compiled the obfuscated code then decompile the compiled code back into source? It should be more legible at that point.
Admin
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.
Admin
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.
Admin
Admin
Too bad Ctrl + K then D wouldn't work with Basic, because then that consultant would be out of a(nother) job!
Admin
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.
Admin
Admin
Admin
Andy tells me I am his own!
Admin
Well, I don't have to obfuscate my code... it looks like shit naturally!
Admin
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.
Admin
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.
Admin
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.
Admin
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.
Admin
This... is priceless.
Admin
Best. Answer. Ever.
claps
Admin
Admin
Admin
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.)
Admin
Just copy paste the code in Word and give it a nice format, like 'Comic Sans'.
Captcha = tristique, short for three pieces of antique.
Admin
Admin
Admin
I always liked FORK=ATOM which would do highly different things on different implementations of BASIC.
Admin
Usually punching works better.
Admin
In Zen, punching IS explaining.