This weekend I have wrote a java assembler/disassembler and raw
class header parser. (Needs more work, the parser stills buggy),
but I expect to have this finished by the end of the week.

Here's a lil demo:

$ echo pD6 | ARCH=java ./radare Endian.class -vs 0x144
0x00000144 1203          ldc 3
0x00000146 b60004        invokevirtual 0x0 0x4
0x00000149 b1            return

The same functionality has been exported to the shell with a new
command called "javasm" to be called from 'rsc asm' and 'rsc dasm':

$ javasm -h
Usage: javasm [-a 'opcode'] [-d 'hexpairstring'] [-c 'classfile']

$ javasm -a 'bipush 123'
10 7b

$ javasm -d '10 7b'
bipush 123

My idea is to let javasm set a flag for each method of the class
pointing to the raw file image offset where it starts.

The java asm/disasm does not only targets virtual machines, my idea
is to let Jazzele support for the ARM debugger, to be able to 
disassemble the code pointed by the register with java_disasm and
after the BXJ call check the register values to get the exception
launched by the Java Coprocessor.

$ javasm -c Endian.class
Version: 0x3200 0x0000
ConstantPoolCount 25
   1 MethodRef: string[1536]
   2 FieldRef: 0x0d00 0x0e00
   3 String: string[3840]
   4 MethodRef: string[4096]
   5 Class: 18
   6 Class: 19
   7 Utf8: <init>
   8 Utf8: ()V
   9 Utf8: Code
  10 Utf8: main
  11 Utf8: ([Ljava/lang/String;)V
  12 NameAndType: 0x6176612f 0x70008
  13 Class: 20
  14 NameAndType: 0x6176612f 0x150016
  15 Utf8: Hello World
  16 Class: 23
  17 NameAndType: 0x6f20576f 0x180019
  18 Utf8: Endian
  19 Utf8: java/lang/Object
  20 Utf8: java/lang/System
  21 Utf8: out
  22 Utf8: Ljava/io/PrintStream;
  23 Utf8: java/io/PrintStream
  24 Utf8: println
  25 Utf8: (Ljava/lang/String;)V
Access flags: 0x2100
This class: 5 ((null))
Super class: 6 ((null))
Interfaces count: 0
Fields count: 0
Methods count: 2
 0: Access Flags: 1
    Name Index: 7 (<init>)
    Descriptor Index: 8 ()
    Attributes Count: 1
    0: Name Index: 9 (Code)
     Length: 17
      Max Stack: 1
      Max Locals: 1
      Code Length: 5
      Code At Offset: 0x00000122
      Exception table length: 0
      Attributes_count: 0
 1: Access Flags: 9
    Name Index: 10 (main)
    Descriptor Index: 11 ()
    Attributes Count: 1
    0: Name Index: 9 (Code)
     Length: 21
      Max Stack: 2
      Max Locals: 1
      Code Length: 9
      Code At Offset: 0x00000141
      Exception table length: 0
      Attributes_count: 0

Have fun!

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

Reply via email to