I have fixed the java class dumper and implemented a proper constant pool 
resolver for
opcode disassembling. Now if you set the file.id=true (NOTE THAT file.identify 
NO LONGER
EXISTS!!) radare will load the class information if it's a .class (the rabin 
part).

This is a sample session disassembling a hello world in java:

The missing part is the flagging of the methods, the code analysis should be 
mostly ok,
so for 0.9.4 i plan to have an almost decent java support for patching and 
reversing.
Java is a nice place to test our graphing layouts and code analysis, because of 
the
simple opcodes and the existence of code obfuscators.

Maybe in futures versionf of the radare java disassembler it will support code 
unscrambling,
deobfuscation of emulated pieces of code and so.

The opcode colorization should be done at code analysis level, this will make 
the disassembler
codes cleaner and stay simpler.

$ cat hello.java 
public class hello
{
        public static void main(String[] args)
        {
                System.out.println("Hello World");
        }
}

$ radare -e file.id=1 hello.class 
open ro hello.class
Message of the day:
  Execute a command on the visual prompt with cmd.vprompt
Version: 0x3200 0x0000
ConstantPoolCount 28
   1 MethodRef: class = 6, name_type = 15
   2 FieldRef: class = 16, name_type = 17
   3 String: string ptr 18
   4 MethodRef: class = 19, name_type = 20
   5 Class: 21
   6 Class: 22
   7 Utf8: <init>
   8 Utf8: ()V
   9 Utf8: Code
  10 Utf8: LineNumberTable
  11 Utf8: main
  12 Utf8: ([Ljava/lang/String;)V
  13 Utf8: SourceFile
  14 Utf8: hello.java
  15 NameAndType: name = 7, descriptor = 8
  16 Class: 23
  17 NameAndType: name = 24, descriptor = 25
  18 Utf8: Hello World
  19 Class: 26
  20 NameAndType: name = 27, descriptor = 28
  21 Utf8: hello
  22 Utf8: java/lang/Object
  23 Utf8: java/lang/System
  24 Utf8: out
  25 Utf8: Ljava/io/PrintStream;
  26 Utf8: java/io/PrintStream
  27 Utf8: println
  28 Utf8: (Ljava/lang/String;)V
Access flags: 0x2100
This class: 1280
Interfaces count: 0
Fields count: 0
Methods count: 2
 0: Access Flags: 1
    Name Index: 7 (<init>)
    Descriptor Index: 8 (()V)
    method Attributes Count: 1
    0: Name Index: 9 (Code)
     Length: 29
      Max Stack: 1
      Max Locals: 1
      Code Length: 5
      Code At Offset: 0x0000014d
      Exception table length: 0
      code Attributes_count: 1
    0: Name Index: 10 (LineNumberTable)
     Length: 6
     Table Length: 1
      0: start_pc:    0x0000
         line_number: 1
 1: Access Flags: 9
    Name Index: 11 (main)
    Descriptor Index: 12 (([Ljava/lang/String;)V)
    method Attributes Count: 1
    0: Name Index: 9 (Code)
     Length: 37
      Max Stack: 2
      Max Locals: 1
      Code Length: 9
      Code At Offset: 0x00000178
      Exception table length: 0
      code Attributes_count: 1
    0: Name Index: 10 (LineNumberTable)
     Length: 10
     Table Length: 2
      0: start_pc:    0x0000
         line_number: 5
      1: start_pc:    0x0008
         line_number: 6
[0x00000000]> s 0x178
[0x00000178]> pD 10
          0x00000178           b20002           getstatic out 
Ljava/io/PrintStream;
          0x0000017B           1203             ldc "Hello World"
          0x0000017D           b60004           invokevirtual println 
(Ljava/lang/String;)V
          0x00000180           b1               return

Funny huh? ;D

  --pancake
_______________________________________________
radare mailing list
[email protected]
https://lists.nopcode.org/mailman/listinfo/radare

Reply via email to