进入Proguard的lib目录,用JDK打开proguardgui.jar,点选Input/Output标签,选择要混淆的JAR包(注意是JAR包),输出JAR包,以及用到的所有类库。
点选Obfuscation标签,选中不需要混淆的类(要被反射的类绝对不能被混淆),一般是1,4,5,9,10,11
,12这几个选项。
a.txt的文件内容为:(混淆函数名)
Gcd
b.txt的文件内容为:(混淆类名)
A
B
解压b.jar后,这时的3个class文件分别为A.class、B.class、Test.class;
重新反编译程序jad -d d:\b\ -r -s java d:\b\*.class,生成3个java文件:A.java、B.java、Test.java,具体内容如下:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

public final class A
{
public A()
{
}
public final String Gcd()
{
return Gcd;
}
public final void Gcd(String s)
{
Gcd = (new StringBuilder()).append("Bomber:").append(s).toString();
}
private String Gcd;
}
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

public final class B
{
public B()
{
}
public final String Gcd()
{
return Gcd;
}
public final void Gcd(String s)
{
Gcd = (new StringBuilder()).append("Flight:").append(s).toString();
}
private String Gcd;
}
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
import java.io.*;
import java.util.StringTokenizer;
public class Test
{
public Test()
{
}
public static void main(String args[])
{
String s;
if((s = (args = new BufferedReader(new InputStreamReader(System.in))).readLine()).length() % 2 == 0)
System.out.println("You are my sun1");
else
System.out.println("You are my sun2");
Object obj;
((B) (obj = new B())).Gcd(s);
System.out.println(((B) (obj)).Gcd());
((A) (obj = new A())).Gcd(s);
System.out.println(((A) (obj)).Gcd());
s = args.readLine();
args = Integer.parseInt((args = new StringTokenizer(s)).nextToken());
System.out.println(Gcd(args));
}
private static int Gcd(int i)
{
if(i > 1)
return i * Gcd(i - 1);
else
return 1;
}
}
本文介绍如何使用Proguard工具进行代码混淆,包括配置输入输出文件、排除特定类的混淆等步骤,并展示了混淆前后代码的具体变化。
1992

被折叠的 条评论
为什么被折叠?



