Reverse Engineering for Beginners

(avery) #1

CHAPTER 54. JAVA CHAPTER 54. JAVA


public static void main(java.lang.String[]);
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=3, locals=2, args_size=1
0: iconst_5
1: bipush 10
3: bipush 15
5: multianewarray #2, 3 // class "[[[I"
9: astore_1
10: aload_1
11: iconst_1
12: aaload
13: iconst_2
14: aaload
15: iconst_3
16: iconst_4
17: iastore
18: aload_1
19: invokestatic #3 // Method get_elem:([[[I)I
22: pop
23: return

Now it takes twoaaloadinstructions to find rightreference:


public static int get_elem (int[][][] a)
{
return a[1][2][3];
}

public static int get_elem(int[][][]);
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=2, locals=1, args_size=1
0: aload_0
1: iconst_1
2: aaload
3: iconst_2
4: aaload
5: iconst_3
6: iaload
7: ireturn

54.13.8Summary.


Is it possible to do a buffer overflow in Java? No, because the array’s length is always present in an array object, array
bounds are controlled, and an exception is to be raised in case of out-of-bounds access.


There are no multi-dimensional arrays in Java in the C/C++ sense, so Java is not very suited for fast scientific computations.


54.14Strings


54.14.1First example.


Strings are objects and are constructed in the same way as other objects (and arrays).


public static void main(String[] args)
{
System.out.println("What is your name?");
String input = System.console().readLine();
System.out.println("Hello, "+input);
}
Free download pdf