Proguard为类,成员和参数混淆定制命名

时间:2012-04-06 14:38:11

标签: java dictionary refactoring obfuscation proguard

是否应该如何构建Proguard中字典文件的简单描述?

我已经阅读了-?obfuscationdictionary,但我找不到任何关于这些文件的信息。

此外,我想将命名方案更改为更复杂的方案,而不仅仅是ab等和paramXparamY ......如果可能的话,我想要一系列随机字符。

是的,我知道这只是一个视觉差异,可以改造(重构?)到更容易阅读的东西。不过,只是问......

由于

2 个答案:

答案 0 :(得分:23)

字典文件格式非常简单:

  1. 每行一个字
  2. 忽略空行
  3. #开头的行忽略
  4. 如果要创建随机字符串的字典,可以编写一个简单的程序来生成它们并将它们转储到文本文件中,或者使用http://www.random.org/strings,它有一个很好的简单Web界面来创建随机字符串。它每行吐出一个,所以你可以直接使用它的输出作为你的字典文件。

    这是一些示例输出(您可以生成任意大小的字符串):

    HISPj7KHQ7
    Wja3o2vx62
    eyd3OXAZgV
    DxDJysLV5r
    BsUTWEAMAI
    R7N8DF4OVS
    4q7UsoAgP4
    cWbN6pumKk
    SJowARcXwM
    OyIbF7L6XB
    

    以下是我发现的一个例子:

    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
    

答案 1 :(得分:3)

任何文本文件都可以使用。 ProGuard使用文件中的所有有效标识符。它忽略以'#'开头的行。 ProGuard发行版中的目录examples / dictionaries包含一些示例(包括ulmangt粘贴的示例)。