隨筆 - 147  文章 - 71  trackbacks - 0
          <2009年11月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(1)

          隨筆分類(146)

          隨筆檔案(147)

          文章分類(28)

          文章檔案(28)

          喜歡的Blog

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          下載地址:http://proguard.sourceforge.net
          以下面的Test.java文件為例:
          import java.util.*;
          import java.io.*;

          public class Test {
              
          public static void main(String[] args) throws Exception 
                  BufferedReader stdin 
          = new BufferedReader(new InputStreamReader(System.in));
                     String s 
          = stdin.readLine();        
                  
          if(s.length()%2==0)
                      System.out.println(showMsg1()); 
                  
          else
                      System.out.println(showMsg2());
                  Flight a 
          = new Flight();
                  a.setName(s);
                  System.out.println(a.output());
                  Bomber b 
          = new Bomber();
                  b.setName(s);
                  System.out.println(b.output());
                  s 
          = stdin.readLine();
                  StringTokenizer st 
          = new StringTokenizer(s);
                  
          int n = Integer.parseInt(st.nextToken()); 
                  System.out.println(compute(n));
              }

              
              
          public static String showMsg1() 
                  
          return "You are my sun1"
              }

              
              
          public static String showMsg2() 
                  
          return "You are my sun2"
              }

              
              
          public static int compute(int n) 
                  
          if(n>1)
                      
          return n*compute(n-1); 
                  
          else
                      
          return 1;
              }

              
              
          public static class Flight{
                  
          public Flight(){
                  }

                  
                  
          public String output(){
                      
          return this.name;
                  }

                  
                  
          public void setName(String name){
                      
          this.name="Flight:"+name;
                  }

                  
                  
          private String name;
              }

              
              
          public static class Bomber{
                  
          public Bomber(){
                  }

                  
                  
          public String output(){
                      
          return this.name;
                  }

                  
                  
          public void setName(String name){
                      
          this.name="Bomber:"+name;
                  }

                  
                  
          private String name;
              }

          }

          首先jar cvf a.jar *.class打包程序,然后jad -d d:\ -r -s java d:\*.class反編譯程序,生成Test.java文件,通過對比可以發(fā)現(xiàn),它和原來文件的內(nèi)容基本是相同的。

          // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
          // Jad home page: http://www.kpdus.com/jad.html
          // Decompiler options: packimports(3) 
          // Source File Name:   Test.java

          import java.io.*;
          import java.util.StringTokenizer;

          public class Test
          {
              
          public static class Bomber
              
          {

                  
          public String output()
                  
          {
                      
          return name;
                  }


                  
          public void setName(String s)
                  
          {
                      name 
          = (new StringBuilder()).append("Bomber:").append(s).toString();
                  }


                  
          private String name;

                  
          public Bomber()
                  
          {
                  }

              }


              
          public static class Flight
              
          {

                  
          public String output()
                  
          {
                      
          return name;
                  }


                  
          public void setName(String s)
                  
          {
                      name 
          = (new StringBuilder()).append("Flight:").append(s).toString();
                  }


                  
          private String name;

                  
          public Flight()
                  
          {
                  }

              }



              
          public Test()
              
          {
              }


              
          public static void main(String args[])
                  
          throws Exception
              
          {
                  BufferedReader bufferedreader 
          = new BufferedReader(new InputStreamReader(System.in));
                  String s 
          = bufferedreader.readLine();
                  
          if(s.length() % 2 == 0)
                      System.out.println(showMsg1());
                  
          else
                      System.out.println(showMsg2());
                  Flight flight 
          = new Flight();
                  flight.setName(s);
                  System.out.println(flight.output());
                  Bomber bomber 
          = new Bomber();
                  bomber.setName(s);
                  System.out.println(bomber.output());
                  s 
          = bufferedreader.readLine();
                  StringTokenizer stringtokenizer 
          = new StringTokenizer(s);
                  
          int i = Integer.parseInt(stringtokenizer.nextToken());
                  System.out.println(compute(i));
              }


              
          public static String showMsg1()
              
          {
                  
          return "You are my sun1";
              }


              
          public static String showMsg2()
              
          {
                  
          return "You are my sun2";
              }


              
          public static int compute(int i)
              
          {
                  
          if(i > 1)
                      
          return i * compute(i - 1);
                  
          else
                      
          return 1;
              }

          }

          進入Proguard的lib目錄,用JDK打開proguardgui.jar,點選Input/Output標簽,選擇要混淆的JAR包(注意是JAR包),輸出JAR包,以及用到的所有類庫。
          點選Obfuscation標簽,選中不需要混淆的類(要被反射的類絕對不能被混淆),一般是1,4,5,9,10,11

          ,12這幾個選項。
          a.txt的文件內(nèi)容為:(混淆函數(shù)名)
          Gcd
          b.txt的文件內(nèi)容為:(混淆類名)
          A
          B

          點選Process標簽,Process按鈕,生產(chǎn)b.jar

          解壓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,具體內(nèi)容如下:

          A.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;
          }
          B.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 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;
          }
          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) 

          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;
              }

          }
          通過對比可以發(fā)現(xiàn),它和原來文件的內(nèi)容有許多出入。
          posted on 2009-11-23 20:40 飛翔天使 閱讀(12615) 評論(1)  編輯  收藏 所屬分類: java

          FeedBack:
          # re: Proguard使用教程 2012-06-09 15:39 謝謝啊
          謝謝啊謝謝啊謝謝啊謝謝啊謝謝啊謝謝啊謝謝啊謝謝啊  回復(fù)  更多評論
            
          主站蜘蛛池模板: 巧家县| 洪湖市| 焦作市| 迭部县| 拜泉县| 八宿县| 汝州市| 仁布县| 碌曲县| 定南县| 云梦县| 丹江口市| 楚雄市| 纳雍县| 苍溪县| 通江县| 贵阳市| 上思县| 绥宁县| 沭阳县| 太仆寺旗| 崇礼县| 德昌县| 龙口市| 沁水县| 华容县| 西青区| 罗江县| 普陀区| 南川市| 浦江县| 五家渠市| 封开县| 墨脱县| 大石桥市| 广元市| 武宣县| 拉孜县| 岳池县| 定结县| 资阳市|