[comp.lang.misc] C obfuscator

fish%kzin.utah.edu@cs.utah.edu (Russ Fish) (06/08/90)

Here's a copy of the short, chatty part of a posting to comp.sources.misc .
Messages I've been getting mentioned these newsgroups, but it didn't seem
proper to cross-post the sources, so I'll just send the discussion part here.

Please correspond by mail if you'd like, I haven't been reading much netnews
lately.

-Russ Fish			fish@cs.utah.edu		(801) 581-5884

From: fish@kzin.utah.edu (Russ Fish)
Path: kzin.utah.edu!fish
Newsgroups: comp.sources.misc
Subject: C obfuscator

A friend mentioned somewhere on the net that I had once written a C
obfuscator, and I've gotten numerous requests for it.  So I'll post it.

I make no claims for it, other than the fact that it once worked sufficently
to package up a portable "opaque source" distribution of a couple hundred
thousand lines of our geometric modeling system.  

The idea was to throw away all the information not absolutely needed by the
compiler or linker, or squish it into unreadable id's.  To support separate
compilation of large systems, it supports an optional dictionary of global
identifiers and their translations, which I generated simply by doing `nm' on
the .o files and .a libraries, and bashed into the dictionary format using
the usual morass of `grep', `sort', `sed', `awk', etc.

Everybody seems to agree that the results are pretty unreadable.  :-)

That was over five years ago, and I haven't used it since.  (We make binary
distribution tapes for various plaforms now...)  Feel free to use the code in
any way that seems useful.  (Pound nails with it, etc.  :-)

Files included below:
	opqcp.c	    	"Opaque Copy".  The obfuscator.
	opqcp.opq   	The result of hitting opqcp.c with opqcp.

	makefile    	

	misc.h	    	A few support files, chopped down to subsets.
	list.h
	symtab.h
	new.c
	symtab.c

-Russ Fish			fish@cs.utah.edu		(801) 581-5884


ps. Here's the germ of a slight improvement: The C keywords and punctuation
characters could be squished out of the obfuscated file as well, if cpp were
used to substitute them back in at compile time.  Then the source files would
all be COMPLETELY unreadable.  (But of course, the key .h file of
substitutions would have to be sent along, so it really doesn't gain that
much.)


-Russ Fish			fish@cs.utah.edu		(801) 581-5884