uglify
There are many attempts out there at beautifying C/C++ sourcecode. Here now is my first attempt at automatically uglifying C/C++ sourceode.
Uglify used to be a proprietary Win32 application, but I decided to completely rewrite it in THE WORLDS BEST PROGRAMMING LANGUAGE, Python. You can download the current version 0.3 here. Of course it includes the full sourcecode :) You need to have Python 2.0 or higher installed to run this file.
See for yourself:
- This is the sourcecode for Java2Ks' DIE.
- This and this are the parts generated by Uglify (the new Python Version!!!)
If you don't think this compiles, here is a complete working obfuscated copy of Java2K (compiles with MSDEV). Here are some sources that compile with GCC/Cygwin.
Usage for uglify.py
Currently, uglify.py does not have command line options. You have to edit the file config.py to suit your needs. Its simple, really.
No more #includes !
uglify.py has a special mode, where all source files are first preprocessed by your installed compiler and then uglified. This effectively removes the need for #include files !!! This also has the side-effect that all project files become ridiculously large, and even more obfuscated than before <evil grin>.Furthermore, macros obfuscated identifiers and strings. For example, the string
"USAGE: eval <expression>"
will be #defined as
#define O_QQ_ooo(a4,a10,a15,a11,a3,a23,a22,a2,a5,a9,a13,a7,a19,a20,a8,\ a18,a6,a14,a21,a12,a0,a16,a1,a17) #a0## #a1## #a2## #a3## #a4## #a5##\ #a6## #a7## #a8## #a9## #a10## #a11## #a12## #a13## #a14## #a15## #a16##\ #a17## #a18## #a19## #a20## #a21## #a22## #a23 #define O_QQ_o_O O_QQ_ooo(E,l,p, ,G,>,n,A,:,a,e,e,s,i,v,s, ,x,o,<,U,r,S,e)
I really should optimize that so that I use all characters only once ;)
To use this feature on Linux, you have to have GCC installed. Hey, on Linux you have GCC installed. See config.py for how to set the proper options.Actually, this macro feature fully only works with GCC, the MSDEV starts sucking deeply: macros cannot have more than 16 arguments.
This actually is the first time I see GCC technically superior to the Microsoft Compiler :)
To use this feature on Win32, you have to have the Microsoft Compiler installed (MSDEV commandline). You can find out if you have this if you just type "cl" at a command line. If all is fine, you should see a message to the effect
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. usage: cl [ option... ] filename... [ /link linkoption... ]
If you don't see this message, try the following:
- Open a command line. Be sure to use CMD.EXE and not COMMAND.COM; the former is 32-bit, the latter a 16-Bit version.
- Change to the directory <Program Files>\Microsoft Visual Studio\VC98\Bin, where <Program Files>; is your installation directory.
- Type VCVARS32.BAT. If everything works fine, you'll see a message Setting environment for using Microsoft Visual C++ tools.
NOTE: Starting with version 0.3, you can also use Cygwin on Win32. Use the same settings you would use for GCC on Linux.
Download
You can download version 0.3 of uglify.py as a zip file here. You need to have Python 2.0 or higher installed to run this file !
You can download the Win32 legacy binary for Uglify here free for personal use.
Version History
Version 0.4 (July 15, 2001):
- Strings are now macro-ized completely, without the token pasting operator.
Version 0.3 (July 13, 2001):
- Macro arguments are now in randomized order :) making it more difficult to decipher the original identifier string.
- Added support for the GCC compiler. (Tested with cygwin).
- Minor bugfixes in the C++ parser: support for "%=", recognize float literals.
- You can now supply custom compiler switches for precompilation (see config.py for details)
Version 0.2:
- no more #includes !
- better output formatting
- many bugfixes in the C++ parser