ZZIPlib
0.13.26


Library
-ZIP Access
-Transparently
-SDLrwops Example
-ext/io Customization
-xor/io Obfuscation
-Library API
-Parsing ZIPs
-64on32 extras
-Next To Come
-Config Helpers
-Making a zip/exe
-Hints And Links
-Referentials
-Functions List #
    (# autogenerated)
 

Download Area *
Sourceforge CVS
Sourceforge Project
zziplib.sf.net Home
LGPL/MPL license
 

generated 2003-12-23
(C) Guido Draheim
guidod@gmx.de

ZIP Obfuscation


Using obfuscations like XOR.

The EXT/IO calls

You really should read the section about the EXT/IO feature of the zziplib since the obfuscation routines are built on top of it. In order to use obfuscation, you will generally need to use all the three additional argument that can be passsed to _open_ext_io functions. For the XOR-example, only one IO-handler is modified being the read()-call that will simply xor each data byte upon read with a specific value. It two advantages - doing an xor twice does yield the same data, so as a developer you do not have to wonder about the encryption/decryption pair, and it is a stateless obfuscation that does not need to know about the current position within the zip-datafile or zippedfile-datatream.

The examples provided just use a simple routine for xoring data that is defined in all the three of the example programs:

      static int xor_value = 0x55;
      static zzip_ssize_t xor_read (int f, void* p, zzip_size_t l)
      {
          zzip_size_t r = read(f, p, l);
	  zzip_size_t i;     char* q = p;
          for (x=0; x < r; x++) q[x] ^= xor_value;
          return r;
      }
  
and place this routine into the io-handlers after initializing the structure:
    zzip_init_io (&xor_handlers, 0); xor_handlers.read = &xor_read;
  

The examples

There are three example programs. The first one is zzxorcopy.c which actually is not a zziplib based program. It just opens a file via stdio, loops through all data bytes it can read thereby xor'ing it, and writes it out to the output file. A call like "zzxorcopy file.zip file.dat" will create an obfuscated dat-file from a zip-file that has been possibly create with the normal infozip tools or any other archive program to generate a zip-file. The output dat-file is not recognized by normal zip-enabled apps - the filemagic is obfuscated too. This output dat-file however is subject to the other two example programs.

The zzxordir.c program will open such an obfuscated zip file and decode the central directory of that zip. Everything is still there in just the way it can be shown with the normal unzip programs and routines. And the zzxorcat.c program can extract data from this obfuscated zip - and print it un-obfuscated to the screen. These example programs can help you jumpstart with your own set of obfuscator routines, possibly more complex ones.

By the way, just compare those with their non-xor counterparts that you can find in zzdir.c and zzxorcat.c. Notice that the difference is in the setup part until the _open_ call after which one can just use the normal zzip_ routines on that obfuscated file. This is great for developing since you can start of with the magic-wrappers working on real-files then slowly turning to pack-files that hold most of the data and finally ending with a zip-only and obfuscated dat-file for your project.

Some rationale

Some people might ask why not adding standard zip-encryption. Well, first of all the standard zip-encryption has not been strong enough for modern computers, and there are hacker tools that even a half-literate computer-user can use to crack the password of a zip-archive. Furthermore, adding real encryption is a heavy weight that many people do not need, see the last argument for seeing the standard one is useless anyway, and adding a non-standard one should not be the case of the standard zziplib either, ye know.

On the other hand, obfuscation is a means to fear off half-literates just as well - there are no premade tools for the obfuscation you can invent from the xor examples. And a hacker that can de-obfuscate such a dat-file is able to dissassemble your program as well thereby going to see your decryption routine and the decryption key. Although there is a difference, it just ranges on about times and exprience, not magnitudes. Remember the old saying: you can irritate some people for some time but not irritate all people for all the time. As for encryption of artwork and AI scripts in games and applications, just keep in mind that the final recipient has the decryption key on his system anyway, just obfuscated. So each such encryption is nothing more than just a clever form of obfuscation, nothing mathemetical strong.

Some other people might ask why to obfuscate anyway. Well, the reason is theft. Even people who write opensource free software generally like to get some reward for what they do, some fame or atleast some sweet dream to have helped the world go a bit easier in the future. As for program text this is quite natural for the programmers who pick up some code from somewhere else - it happens that most of them have gone through some formation and they know how hard it is to get even some lines of code out of your brain. This is not the case for some artwork and AI parameters, people do not have much respect for those - they just pick it up, put it under their umbrella, and that's it - they even claim they could have done that themselves, and in most cases it is that they never have been really trying to do it and think of it as being comparable to that action-art they've seen on TV.

Just be sure that there is nothing wrong with obfuscating things for a binary distribution of your program even for the opensource case - the program text itself is an obfuscation in its source form when being compiled into cpu instructions. Still, the interested people can get hold of the source code since you provide it somewhere and actually the original programmers like to hear from literate people who could help with modifying the project. The same is true for you artwork and AI scripts, the interested people can still see them in the opensource project material, but only those will look who dare to, not just the halfwit next door.

Well, you do not need to that on the other hand - ID software has shown that it can be very helpful since people will start to write new maps and new bots, pack them and publish them. An open data format is a form of attraction for people who can use a graphics program and an editor but who do not know how to program. And if you use obfuscation within an opensource program, it is surely enought to just use the xor-format presented here, so that it easy for third people to get involved if they want to, they just have to rewrite their new datapacks with zzxorcopy, and that's it.

As for the non-opensource projects, be aware that there are some ways to even staticlink the zziplib into your project, so you can even hide that you used zip tools to create your dat files. This is well enough for anyone to do - as soon as a hacker will get to the point to notice you used a zip format, he would have had found any other deobfusation or decryption routine as well. If you are frightened, just encrypt the executable with tools you bought from somewhere else. On the other hand, should there be problems or bugs, you have an easier time to find them when they could be caused by your dat entries, and it is again easy to send a fixup file to your clients, since the command line tools are just a breeze compared with some other anti-hacking tools you'll find on the market.

Well, hope this is enough rationale to tell you that I do not see a need to implement anything more than obfuscation within zziplib - if you need real encryption, use real encryption software and its fileformat that supports it, not zip files.

staticlinking?


guidod@gmx.de 15. July 2002