Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proguard custom naming for classes, members and parameters obfuscation

Is there a simple description of how the dictionary file in Proguard should be structured?

I've read about -?obfuscationdictionary, but I couldn't find anything about the files themselves.

Besides, I'd like to change the naming scheme to something more complex, and not just a, b etc. and paramX, paramY... I'd like a random series of characters, if possible.

And yes, I know it's just a visual difference that can be remodeled (refactored?) to something easier to read. Still, just asking...

Thanks

like image 226
davidcesarino Avatar asked Apr 06 '12 14:04

davidcesarino


2 Answers

The dictionary file format is pretty simple:

  1. One word per line
  2. Blank lines ignored
  3. Lines starting with # ignored

If you want to create a dictionary of random strings, you could write a simple program to generate them and dump them to a text file, or use http://www.random.org/strings which has a nice simple web interface for creating random strings. It spits them out one per line, so you could use its output directly as your dictionary file.

Here's some sample output (you can generate strings of any size):

HISPj7KHQ7
Wja3o2vx62
eyd3OXAZgV
DxDJysLV5r
BsUTWEAMAI
R7N8DF4OVS
4q7UsoAgP4
cWbN6pumKk
SJowARcXwM
OyIbF7L6XB

Here's an example I found:

https://trac.openxdata.org/browser/trunk/j2me/openxdata-mobile/epihandy-lite/proguard/examples/dictionaries/keywords.txt?rev=1156

#
# This obfuscation dictionary contains reserved Java keywords. They can't
# be used in Java source files, but they can be used in compiled class files.
# Note that this hardly improves the obfuscation. Decent decompilers can
# automatically replace reserved keywords, and the effect can fairly simply be
# undone by obfuscating again with simpler names.
# Usage:
#     java -jar proguard.jar ..... -obfuscationdictionary keywords.txt
#

do
if
for
int
new
try
byte
case
char
else
goto
long
this
void
break
catch
class
const
final
float
short
super
throw
while
double
import
native
public
return
static
switch
throws
boolean
default
extends
finally
package
private
abstract
continue
strictfp
volatile
interface
protected
transient
implements
instanceof
synchronized
like image 127
ulmangt Avatar answered Nov 20 '22 23:11

ulmangt


Any text file will work. ProGuard uses all valid identifiers in the file. It ignores lines starting with '#'. The directory examples/dictionaries in the ProGuard distribution contains a few examples (including the example pasted by ulmangt).

like image 3
Eric Lafortune Avatar answered Nov 20 '22 21:11

Eric Lafortune