Gerdiner
Gerdiner

Reputation: 1505

Deobfuscating C++ source code

In search for a c++ parser I recently stumbled across the project below. Within it there's a parser that seems extremely well suited to my needs, however I believe the author(s) have deliberately obfuscated some of the core pieces of code, which make examining the code a little difficult.

https://github.com/ArashPartow/math-parser-benchmark-project/blob/master/fparser/fpoptimizer.cc

There is a description in the file and on the author's website about there being a plain deobfuscated version, however the indicated site seems to only have a dead-link and attempts to contact the author have been fruitless.

I was wondering if fellow SOers would know of a quick and easy way to reverse the obfuscation in the above mentioned file.

Now I'm not sure because I'm not a C++ expert, but it could be that there is a legitimate reasons for the code to be the way it is, presumably as the name of the file suggests it could be for performance reasons.

Upvotes: 1

Views: 7581

Answers (2)

Journeyman Geek
Journeyman Geek

Reputation: 218

In this specific case, you could just try this link to the project page, with the latest devel files - I just worked out it was the version being wrong - the link says 4.5 and the current version is 4.5.2 as of this revision. They don't seem to keep old versions around so grab the latest there

Upvotes: 5

user93353
user93353

Reputation: 14039

Most compilers have options to just run the preprocessor on the code & generate the preprocessor output. That will remove any obfuscation done using #defines.

For e.g. in MSVC, you can run cl /P fpoptimizer.cc. This will create a file called fpoptimizer.i which will contain the pre-processed file.

You can remove the #includes in the program before doing this - so that only the #defines in the program are preprocessed and not other stuff.

gcc provides the -E option to do something similar.

Upvotes: 5

Related Questions