java,class文件批量反編譯成class文件,免安裝

 

官方文檔

This is README file for Jad - the fast Java Decompiler.
Jad home page: http://www.kpdus.com/jad.html
Copyright 2001 Pavel Kouznetsov ([email protected]).

0. Please read the disclaimer on the Jad home page.

1. Installation.

Unzip jad.zip file into any appropriate directory on your hard drive.
This will create two files:

    - an executable file named 'jad.exe' (Windows *)
      or 'jad' (*n*x)

    - this README file

No other setup is required.

2. How to use Jad

To decompile a single JAVA class file 'example1.class' 
type the following:

     jad example1.class

This command creates file 'example1.jad' in the current directory.
If such file already exists Jad asks whether you want to overwrite it or not.
Option -o permits overwriting without a confirmation.

You can omit .class extension and/or use wildcards in the names of
input files.

Option -s <ext> allows to change output file extension:

     jad -sjava example1.class

This command creates file 'example1.java'. Be careful when using
options -o and -sjava together, because Jad can accidentally overwrite
your own source files.

Jad uses JAVA class name as an output file name. For example, if class
file 'example1.class' contains JAVA class 'test1' then Jad will create
file 'test1.jad' rather than 'example1.jad'. If you want to specify
your own output file name use the output redirection:

   jad -p example1.class > myexm1.java

Option -d allows you to specify another directory for output files,
which are created, by default, in the current directory. For example:

   jad -o -dtest -sjava *.class

   (or jad -o -d test -s java *.class, which has the same effect)

This command decompiles all .class files in the current directory 
and places all output files with extension .java into directory 'test'.


If you want to decompile the whole tree of JAVA classes,
use the following command:

   jad -o -r -sjava -dsrc tree/**/*.class

This command decompiles all .class files located in all 
subdirectories of 'tree' and creates output files in subdirectories
of 'src' according to package names of classes. For example, if file 
'tree/a/b/c.class' contains class 'c' from package 'a.b', then 
output file will have a name 'src/a/b/c.java'.

Note the use of the "two stars" wildcard ('**') in the previous
command. It is handled by Jad rather than the command shell, so on
UNIX the last argument should be single-quoted:

   jad -o -r -sjava -dsrc 'tree/**/*.class'


In a case you want to check the accuracy of the decompilation or just
curious, there is an option -a which tells Jad to annotate the output
with JAVA Virtual Machine bytecodes.

Jad supports the inner and anonymous classes. 
When Jad expands wildcards in the input file names, 
it automatically skips matching inner classes. 
On UNIX Jad skips inner classes if there is more than 
one class specified in the command line.
Jad looks for inner classes in the directory of their top-level
container class.

3. List of the command-line options.

Jad accepts the following options:

   -a       - annotate the output with JVM bytecodes (default: off)
   -af      - same as -a, but output fully qualified names when annotating
   -clear   - clear all prefixes, including the default ones (can be abbreviated as -cl)
   -b       - output redundant braces (e.g., if(a) { b(); }, default: off)
   -d <dir> - directory for output files (will be created when necessary)
   -dead    - try to decompile dead parts of code (if any) (default: off)
   -disass  - disassemble method bytecodes (no JAVA source generated)
   -f       - output fully qualified names for classes/fields/methods (default: off)
   -ff      - output class fields before methods (default: after methods)
   -i       - output default initializers for all non-final fields
   -l<num>  - split strings into pieces of maximum <num> chars (default: off)
   -lnc     - annotate the output with line numbers (default: off)
   -lradix<num> - display long integers using the specified radix (8, 10 or 16)
   -nl      - split strings on newline character (default: off)
   -nocast  - don't generate auxiliary casts
   -nocode  - don't generate the source code for methods
   -noconv  - don't convert Java identifiers (default: convert)
   -noctor  - suppress the empty constructors
   -nodos   - do not check for class files written in DOS mode (CR before NL, default: check)
   -nofd    - don't disambiguate fields with the same names by adding signatures to their names (default: do)
   -noinner - turn off the support of inner classes (default: on)
   -nolvt   - ignore Local Variable Table information
   -nonlb   - don't output a newline before opening brace (default: do)
   -o       - overwrite output files without confirmation (default: off)
   -p       - send decompiled code to STDOUT (e.g., for piping)
   -pi<num> - pack imports into one line after <num> imports (default: 3)
   -pv<num> - pack fields with identical types into one line (default: off)
   -pa <pfx>- prefix for all packages in generated source files
   -pc <pfx>- prefix for classes with numerical names (default: _cls)
   -pf <pfx>- prefix for fields with numerical names (default: _fld)
   -pe <pfx>- prefix for unused exception names (default: _ex)
   -pl <pfx>- prefix for locals with numerical names (default: _lcl)
   -pm <pfx>- prefix for methods with numerical names (default: _mth)
   -pp <pfx>- prefix for method parms with numerical names (default: _prm)
   -r       - restore package directory structrure
   -radix<num> - display integers using the specified radix (8, 10 or 16)
   -s <ext> - output file extension (by default '.jad')
   -safe    - generate additional casts to disambiguate methods/fields (default: off)
   -space   - output space between keyword (if/for/while/etc) and expression (default: off)
   -stat    - display the total number of processed classes/methods/fields
   -t       - use tabs instead of spaces for indentation
   -t<num>  - use <num> spaces for indentation (default: 4)
   -v       - display method names being decompiled
   -8       - convert UNICODE strings into 8-bit strings
              using the current ANSI code page (Win32 only)
   -&       - redirect STDERR to STDOUT (Win32 only)

All single-word options have three formats:

  -o    - 'reverses' value of an option
  -o+   - set value to 'true' or 'on'
  -o-   - set value to 'false' or 'off'

You can specify the options you want to be set by default in the environment variable
JAD_OPTIONS. For example:

JAD_OPTIONS=-ff+ -nonlb+ -t+ -space+

 

使用用例1,反編譯單個文件:

 jad example1.class

如下圖所示,會生成一個*.jad的文件,如果是要生成java的話,用後續的代碼

 

用例2

 jad -sjava example1.class

生成一個*.java的文件

 

用例3,從命名一個文件名

jad -p example1.class > myexm1.java

 

 

用例4,可以批量轉換某個目錄下的所有.class的反編譯成.java,並生成在test目錄中

 jad -o -dtest -sjava *.class

也可以用命令

 jad -o -d test -s java *.class

 

用例5:  

批量轉換某個目錄下的所有.class文件,並按src的目錄進行存放反編譯後java文件

jad -o -r -sjava -dsrc tree/**/*.class

 

若有一些特殊的通配符用下面的命令

jad -o -r -sjava -dsrc 'tree/**/*.class'

 

一些特殊的擴展參數

 

   -a       -用JVM字節碼註釋輸出(默認值:關閉)

  -af       -與-a相同,但在註釋時輸出完全限定的名稱

 -clear     --清除所有的前綴,包含一些默認的前綴

  -b              -輸出冗餘大括號(例如,如果(a){b();},默認值:關閉),試了下看不到效果,沒看懂

 -d<dir>     -輸出文件的目錄(將在必要時創建)

  -dead    - 嘗試反編譯部分無法反編譯的代碼,默認:關閉

  -disass   -反彙編方法字節碼(未生成JAVA源代碼)

 -f       - 爲類/字段/方法輸出完全限定的名稱(默認值:關閉),就是引用外部類、方法/字段/方法  會輸出全路徑名稱,比如一個String,那就是輸出java.lang.String

 -ff       字段輸出在方法之前(默認:輸出在方法之後)

-i       - 爲所有非final字段輸出默認初始值設定項

-l<num>   -將字符串拆分爲最大<num>個字符(默認值:關閉),不知道啥效果,看到看到有些字符串被拆分後換行了

-lnc     -用行號註釋輸出(默認值:off)

-lradix<num>   -使用指定基數(8、10或16)顯示長整數

-nl-換行符上的拆分字符串(默認值:off)

-nocast-不生成輔助強制轉換

-nocode-不生成方法的源代碼

-noconv-不轉換Java標識符(默認值:convert)

-noctor-抑制空構造函數

-nodos-不檢查在DOS模式下寫入的類文件(在NL之前爲CR,默認值:check)

-nofd-不要通過在名稱中添加簽名來消除同名字段的歧義(默認值:do)

-noinner-關閉對內部類的支持(默認值:打開)

-nolvt-忽略本地變量表信息

-nonlb-在打開大括號之前不輸出換行符(默認值:do)

-o-在沒有確認的情況下覆蓋輸出文件(默認值:關閉)

-p-將反編譯代碼發送到STDOUT(例如,用於管道)

-pi<num>-在<num>導入之後將導入打包到一行中(默認值:3)

-pv<num>-將具有相同類型的字段打包成一行(默認值:off)

-pa<pfx>-生成的源文件中所有包的前綴

-pc<pfx>-帶有數字名稱的類的前綴(默認值:cls)

-pf<pfx>-帶有數字名稱的字段的前綴(默認值:_fld)

-pe<pfx>-未使用的異常名稱的前綴(默認值:_ex)

-pl<pfx>-帶有數字名稱的局部變量的前綴(默認值:_lcl)

-pm<pfx>-帶有數字名稱的方法的前綴(默認值:_mth)

-pp<pfx>-帶有數字名稱的方法參數的前綴(默認值:prm)

-r-還原包目錄結構

-radix<num>-使用指定的基數(8、10或16)顯示整數

-s<ext>-輸出文件擴展名(默認爲“.jad”)

-安全-生成其他強制轉換以消除方法/字段的歧義(默認值:off)

-space-關鍵字(if/for/while/etc)和表達式(默認值:off)之間的輸出空間

-stat-顯示已處理的類/方法/字段的總數

-t-使用製表符而不是空格進行縮進

-t<num>-使用<num>空格進行縮進(默認值:4)

-v-正在反編譯的顯示方法名稱

-8-將UNICODE字符串轉換爲8位字符串

使用當前ANSI代碼頁(僅Win32)

-&-將STDERR重定向到STDOUT(僅Win32)

 

下載鏈接

https://varaneckas.com/jad/

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章