Most client projects fade from memory quickly after the task is completed, but some will never be forgotten.

This one belongs to the latter category.

In a fairly large company, which I won’t name. It was a bunch of programs, the core building blocks of a business system, maintained by a single guy who had just been fired.

Companies often find that some of their key technologies are kept in one person’s head the whole time, and when something happens, like this person right now, you usually go through a painful phase of reading what he left behind, and then life gets a little bit more normal.

This time is a little different.

There was something wrong with the program, and the company sent one of them to fix it. When he came back, he was either crying or laughing, muttering something about “the pizza called the burger and passed the bun.”

A programmer’s code often has a sense of humor and a sense of confidentiality. We’ve all heard the incredible stories of the company that fired the tech guy, only to be told that accounting software would automatically erase all customer records if the company didn’t remit a certain amount of money to an offshore account within 48 hours. Gimmicks like this are relatively easy to deal with – assuming most of these tales are true, I still find it hard to believe that I have never encountered such a thing in real life.

The software this guy left behind didn’t have any logic bombs or nasty conspiracies, compiled perfectly, and everything worked fine except for one bug. However, you need to imagine that all the functions and variable names in the program are named after food. Pizza, tomatoes, fruits, vegetables, wine, blah, blah, blah, blah. The only thing that gives you immediate meaning is the name of the ‘main’ function and the call to the C standard library.

Take a look: github.crmeb.net/u/LXT

So I took over the thankless mess and tried to restore the program to a maintainable state.

To be honest, this is an excellent form of encryption, and you can only make sense of these “code salads” if you get the key. Little by little, I changed the function and variable names into meaningful names, which was cumbersome at first, but gradually became easier.

The known function and recover the source code in the other direction, than the unknown code parsing easier, because you want to distinguish the code which is first program, which is the data, I put in my in front of these programs are obviously is clear, all the work is not impossible, or exceptionally difficult, only the work too boring too boring. Once you’ve figured out what a variable might be given a meaningful name, all you have to do is find and replace.

The other problem was that the code was badly written. In fact, the spaghetti code was more confusing than the meaningless symbols. Once I had changed the function and variable names back to meaningful ones, I started rewriting a lot of the code to make them easier to understand and more efficient.

I never figured out if he had a set of code that wasn’t crypto obfuscated, and he could have used some ‘obfuscation’ script to obfuscate the original variable names by substitution. It’s hard for me to believe that someone would write code like this in the first place, because it’s a huge challenge for them, and there must be some skill there.

Of course, if your mind is thinking: you can’t because I’m a variable name does not make sense I fired (or should be back to bring me the app), that you are in delusion, no matter what the intention of this guy is, his approach is very wrong (I find it hard to imagine that his former boss will recommend him), anyway, it’s make me happy for several weeks.