Advertisement
Guest User

Untitled

a guest
Feb 20th, 2015
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.49 KB | None | 0 0
  1. $ cat Test.java
  2. public class Test {
  3. public static void main(String[] args) {
  4. System.out.println("Hello, World!");
  5. }
  6. }
  7.  
  8. $ javac Test.java
  9. $ java Test
  10. Hello, World!
  11. $ hexdump -C Test.class
  12. 00000000 ca fe ba be 00 00 00 34 00 1d 0a 00 06 00 0f 09 |.......4........|
  13. 00000010 00 10 00 11 08 00 12 0a 00 13 00 14 07 00 15 07 |................|
  14. 00000020 00 16 01 00 06 3c 69 6e 69 74 3e 01 00 03 28 29 |.....<init>...()|
  15. 00000030 56 01 00 04 43 6f 64 65 01 00 0f 4c 69 6e 65 4e |V...Code...LineN|
  16. 00000040 75 6d 62 65 72 54 61 62 6c 65 01 00 04 6d 61 69 |umberTable...mai|
  17. 00000050 6e 01 00 16 28 5b 4c 6a 61 76 61 2f 6c 61 6e 67 |n...([Ljava/lang|
  18. 00000060 2f 53 74 72 69 6e 67 3b 29 56 01 00 0a 53 6f 75 |/String;)V...Sou|
  19. 00000070 72 63 65 46 69 6c 65 01 00 09 54 65 73 74 2e 6a |rceFile...Test.j|
  20. 00000080 61 76 61 0c 00 07 00 08 07 00 17 0c 00 18 00 19 |ava.............|
  21. 00000090 01 00 0d 48 65 6c 6c 6f 2c 20 57 6f 72 6c 64 21 |...Hello, World!|
  22. 000000a0 07 00 1a 0c 00 1b 00 1c 01 00 04 54 65 73 74 01 |...........Test.|
  23. 000000b0 00 10 6a 61 76 61 2f 6c 61 6e 67 2f 4f 62 6a 65 |..java/lang/Obje|
  24. 000000c0 63 74 01 00 10 6a 61 76 61 2f 6c 61 6e 67 2f 53 |ct...java/lang/S|
  25. 000000d0 79 73 74 65 6d 01 00 03 6f 75 74 01 00 15 4c 6a |ystem...out...Lj|
  26. 000000e0 61 76 61 2f 69 6f 2f 50 72 69 6e 74 53 74 72 65 |ava/io/PrintStre|
  27. 000000f0 61 6d 3b 01 00 13 6a 61 76 61 2f 69 6f 2f 50 72 |am;...java/io/Pr|
  28. 00000100 69 6e 74 53 74 72 65 61 6d 01 00 07 70 72 69 6e |intStream...prin|
  29. 00000110 74 6c 6e 01 00 15 28 4c 6a 61 76 61 2f 6c 61 6e |tln...(Ljava/lan|
  30. 00000120 67 2f 53 74 72 69 6e 67 3b 29 56 00 21 00 05 00 |g/String;)V.!...|
  31. 00000130 06 00 00 00 00 00 02 00 01 00 07 00 08 00 01 00 |................|
  32. 00000140 09 00 00 00 1d 00 01 00 01 00 00 00 05 2a b7 00 |.............*..|
  33. 00000150 01 b1 00 00 00 01 00 0a 00 00 00 06 00 01 00 00 |................|
  34. 00000160 00 01 00 09 00 0b 00 0c 00 01 00 09 00 00 00 25 |...............%|
  35. 00000170 00 02 00 01 00 00 00 09 b2 00 02 12 03 b6 00 04 |................|
  36. 00000180 b1 00 00 00 01 00 0a 00 00 00 0a 00 02 00 00 00 |................|
  37. 00000190 03 00 08 00 04 00 01 00 0d 00 00 00 02 00 0e |...............|
  38. 0000019f
  39.  
  40. we can see that "Hello, World!" string is located at 0x93 offset. Now we will replace that string with "Hello, Earth!".
  41.  
  42. $ echo -n Hello, Earth! | dd conv=notrunc of=Test.class bs=1 seek=$((0x93))
  43. $ java Test
  44. Hello, Earth!
  45.  
  46. VoilĂ ! It works!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement