21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

if (!s.write) s.write = SPC_RESOLVE_SYM(lib, "write");<br />

return s.write;<br />

case fileop_seek:<br />

if (!s.seek) s.seek = SPC_RESOLVE_SYM(lib, "seek");<br />

return s.seek;<br />

}<br />

return 0;<br />

}<br />

The names of the libraries and functions should of course be stored as encrypted<br />

strings (see Recipe 12.11) to provide the best possible obfuscation; additional unused<br />

library and function names can be stored in plaintext to mislead the analyst.<br />

See Also<br />

Recipes 12.11, 13.2<br />

12.4 Performing Bit and Byte Obfuscation<br />

<strong>Problem</strong><br />

Small values such as bytes, shorts, and integers are difficult to disguise while undergoing<br />

mathematical transformations. This makes the values or ranges of constants,<br />

indexes, and counters easy to determine in compiled binary code.<br />

Solution<br />

The Obcode library by Pawel Krawczyk (http://echelon.pl/pubs/) provides an API for<br />

obfuscating bit and byte values, even during the manipulation of those values. The<br />

size of the variables are inflated eightfold, so that a byte variable takes 8 bytes and an<br />

integer variable takes 32 bytes. The library provides for byte operations such as XOR,<br />

AND, OR, and NOT, and operations for integers including ADD, XOR, copy, and<br />

swap.<br />

The Obcode library is still under development and thus is lacking in features; however,<br />

even in its current state it provides an excellent means of obfuscating small values<br />

in memory. Obfuscated values can be stored within data files or within the<br />

program itself, provided that the same seed or key is passed to obcode_init( ) for<br />

both the reading and the writing of the value.<br />

Discussion<br />

In the Obcode data types, each bit is represented by a byte. If the value of the byte is<br />

even, the value of the encoded bit is 1; otherwise, the value of the bit is 0. An<br />

Obcode byte is encoded as a series of 8 Obcode bits; likewise, an Obcode int is<br />

664 | Chapter 12: Anti-Tampering<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!