1 <h2> ZIP Obfuscation </h2> Using obfuscations like XOR.
3 <!--border--> <date> 15. July 2002 </date>
5 <h3> The EXT/IO calls </h3>
8 You really should read the section about the
9 <a href="zzip-extio.html">EXT/IO feature</a> of the zziplib since the
10 obfuscation routines are built on top of it. In order to use obfuscation,
11 you will generally need to use all the three additional argument that
12 can be passsed to _open_ext_io functions. For the XOR-example, only one
13 IO-handler is modified being the read()-call that will simply xor each
14 data byte upon read with a specific value. It two advantages - doing an
15 xor twice does yield the same data, so as a developer you do not have
16 to wonder about the encryption/decryption pair, and it is a stateless
17 obfuscation that does not need to know about the current position
18 within the zip-datafile or zippedfile-datatream.
20 The examples provided just use a simple routine for xoring data that
21 is defined in all the three of the example programs: <pre>
22 static int xor_value = 0x55;
23 static zzip_ssize_t xor_read (int f, void* p, zzip_size_t l)
25 zzip_size_t r = read(f, p, l);
26 zzip_size_t i; char* q = p;
27 for (x=0; x < r; x++) q[x] ^= xor_value;
32 and place this routine into the io-handlers after initializing
34 zzip_init_io (&xor_handlers, 0); xor_handlers.read = &xor_read;
38 <h3> The examples </h3>
41 There are three example programs. The first one is
42 <a href="zzxorcopy.c">zzxorcopy.c</a> which actually is not a zziplib
43 based program. It just opens a file via stdio, loops through all data bytes
44 it can read thereby xor'ing it, and writes it out to the output file. A
45 call like <code><nobr>"zzxorcopy file.zip file.dat"</nobr></code> will
46 create an obfuscated dat-file from a zip-file that has been possibly
47 create with the normal infozip tools or any other archive program to
48 generate a zip-file. The output dat-file is not recognized by normal
49 zip-enabled apps - the filemagic is obfuscated too. This output
50 dat-file however is subject to the other two example programs.
52 The <a href="zzxordir.c">zzxordir.c</a> program will open such an obfuscated
53 zip file and decode the central directory of that zip. Everything is
54 still there in just the way it can be shown with the normal unzip
55 programs and routines. And the <a href="zzxorcat.c">zzxorcat.c</a> program
56 can extract data from this obfuscated zip - and print it un-obfuscated
57 to the screen. These example programs can help you jumpstart with
58 your own set of obfuscator routines, possibly more complex ones.
60 By the way, just compare those with their non-xor counterparts that
61 you can find in <a href="zzdir.c">zzdir.c</a> and
62 <a href="zzxorcat.c">zzxorcat.c</a>. Notice that the difference is
63 in the setup part until the _open_ call after which one can just
64 use the normal zzip_ routines on that obfuscated file. This is
65 great for developing since you can start of with the magic-wrappers
66 working on real-files then slowly turning to pack-files that hold
67 most of the data and finally ending with a zip-only and obfuscated
68 dat-file for your project.
71 <p align="right"><small><small>
72 <a href="copying.html">staticlinking?</a>