Java Virtual Machine (Obfuscation and Java) - PowerPoint PPT Presentation

About This Presentation
Title:

Java Virtual Machine (Obfuscation and Java)

Description:

????????? ? ????????? ??????. ????????? ??????? ?????? ????-???? ... Java ?????????? ?????? SUN Microsystems. 1991 ?. James Gosling ???? Oak. 1995 ?. ... – PowerPoint PPT presentation

Number of Views:73
Avg rating:3.0/5.0
Slides: 41
Provided by: aap3
Category:

less

Transcript and Presenter's Notes

Title: Java Virtual Machine (Obfuscation and Java)


1
Java Virtual Machine(Obfuscation and Java)
  • ??????? ?????????
  • 2004

2
What it is all about?
  • ????????? Java
  • Classfile
  • ??????????? ???
  • ????????? ? ????????? ??????
  • ????????? ??????? ?????? ????-????
  • ?????????? ? Java
  • QA

3
Java Technology(????????)
  • Java ?????????? ?????? SUN Microsystems
  • 1991 ?. James Gosling ???? Oak
  • 1995 ?. ????????? ???????? ?? JAVA ? ??????
    ?????? ?????????? - JDK 1.0
  • 1998 ?. ????????? Java 2 ( SE, EE, ME)
  • Java ???
  • ?????????
  • ?????????
  • ???????????
  • ????????-??????????????

4
What is this all for?
SMART HOUSE
EMBEDDED MEDICAL SYSTEM
WEB SERVER
VM
DESKTOP
CELLPHONE
H.JAR
PALM
SMARTPHONE
iPAQ
5
???? ???? ? JAVA
Compiler (javac)
a.java
a.class
Obfuscator
JAR (jar) ZIP
b. class
b.java
External Verifier
b.java
b. class
H.JAR
Compiler (other)
e.other
e.class
Manifest.mf
f.png
g.txt
6
OOP (JIC)
Moveable
2DPoint Pos
SetPosition()
ValidatePos()
Figure
Draw()
SetColor()
ValidatePos()
ValidatePos()
7
CLASS FILE
8
Classfile structure(?????????)
  • ??????????? ?????????? Java ???????????????? ?
    ???? ?????? classfile-?? (??? ?? ??????? JAR)
  • ???????????? ????????? JAVA
  • ????????????
  • ?????? ??????????????????????
  • ??????? ??????????
  • ???????????? ???????? ??????????? ???????????

9
Classfile structure(????????)
  • ?????? classfile ???????????? ?????? ??????
    ?????? ??? ??????????
  • ?? ?? ?????? ????????? ??????? ?????? ?
    ????????????? ????????????? ?????? ?????? ???
    ??????????
  • Classfile ??? ????????? ???????????????????
    ????? ???? (big-endian)
  • ?? ???????????? ??????? classfile ??? ??????
    ??????

Classfile
JAVA
10
Classfile structure(??? ????????)
  • ??? ????????
  • ??? ?????? (??????, ???????????? ???)
  • ?????? ?? ?????-?????? (??????????)
  • ????? ?????????????? ???????????
  • ???????? ?????
  • ???????? ?????
  • ???????? ???????
  • ???????? ???????
  • ???????? ?????????

11
Classfile structure(??????????? ???)
  • ????? ??????? ??????????? ????????? ?????? ???
    ?????????? ? ???????? ???????? ?? ????
  • ???????? ????? ????????? ?????????? ?????????
  • ??????
  • ????????? (int, float, long, double, ?????? UTF8)
  • ?????? ?? ????????????? ???????? ??????? ????????
    (???????, ???????, ???????)
  • ???????????? ?????? ????????? 216
  • ??????????? ??? ????????? ? ???????? ??????????

12
??????
CONSTANT_Methodref_info
CONSTANT_Class_info
COCONSTANT_NameAndType_info
CONSTANT_Utf8_info
13
Attributes
  • SourceFile - ???????? ?????????
  • ConstantValue ???????? ?????????
  • Code ???????? ????
  • Exceptions ?????? ?????????? ???????? ???????
  • InnerClasses ?????? ????????? ??????? ?? ??????
    ???????
  • Synthetic ??????? ? ??? ??? ???? ??????
    ???????????? ? ?????????
  • LineNumberTable ?????? ?????? ?? ?????? ?????
  • LocalVariableTable ?????? ???? ?????????
    ??????????
  • Deprecated ??????? ? ??? ??? ???? ??? ?????
    ???????? (??????????)

14
Methods and attributes
attribute_info      u2 attribute_name_index
     u4 attribute_length      u1
infoattribute_length     
Code_attribute      u2 attribute_name_index
     u4 attribute_length      u2 max_stack
     u2 max_locals      u4 code_length     
u1 codecode_length      u2
exception_table_length      u2 start_pc
     u2 end_pc      u2 handler_pc      u2
catch_type      exception_tableexception_tabl
e_length u2 attributes_count     
attribute_info attributesattributes_count
    
method_info   u2 access_flags      u2
name_index      u2 descriptor_index      u2
attributes_count      attribute_info
attributesattributes_count     
15
JVM
16
???????????? JVM
  • ? ???? ??????? ????????? ????
  • ?? ????????? ????

17
JVM Subsystems
?????????
???????? ?????
???? ????? ?????
????? ??????????? ????????????
18
JVM (????????? JAVA ??????)
  • ???????????????
  • ????????? ??????????
  • ?????? ??????????? ?????? ??????????? ?? ???????
    ?? ???????
  • ?????????????? ?????? ??????
  • ??????? ??????????????? ??????????????

19
JVM (????????? JAVA ??????)
  • JVM ?????????? ???????? ?????? ? ??????????
    ???????????
  • ?????? ????? ? JVM ????? ???? ???? ?????
    ??????????? ????????
  • JVM ????????? ?
  • ?????? ????????? (??????? ????????)
  • ?????????? ??????????? ???????????
  • ???????????? ???????????

20
JVM
Runtime constpool
Thread 1
Thread 2
JVM Op Stack
Local Variables
Parameters
Frame3
21
JVM
FRAME STACK (call stack)
Thread 1
Thread 2
ALU
MEMORY
FRAME2
JVM Op Stack
HEAP
FRAME2
FRAME1
FRAME1
FRAME1
22
BYTE code(?????????)
  • ???????? ????? ????? ? 8 ??? ? ???????????
    ???????
  • ???????? ????? ????????? ????????? ????????????
  • ???? ????????? ????????
  • ???? ??????? ? ??????? ???????? (IS ???????????)
  • ?? ????? ???????????
  • ?????? ???????? ? ??????? ???????? 8, 32, 64 ????

23
BYTE code(???? ??????)
  • byte - 8-bit ???????? ?????
  • short - 16-bit ???????? ?????
  • int - 32-bit ???????? ?????
  • long - 64-bit ???????? ?????
  • char - 16-bit ??? ???????? ??? ?????????????
    UNICODE
  • float
  • double

24
BYTE code(????)
  • ?????? ? ???????????
  • Push ????-????
  • ?????????? ? ???????? ????????? ??????????
  • Pop ????-???? ? ?????? ?? ??????
  • ?????????????? ????????
  • ???????? ????????? ? ???????? ?????????, ????????
    ???????, ???????? ???????? ?? ???????
  • ???????? ???????????? ????????
  • ???????? ???????? ??????????? ? ????????????
    ?????
  • ???????? ????? ????????, ????????, ????????
    ?????????? ?????
  • ?????? ??????????
  • ?????? ? ???????????? ?????????
  • ??????? ???????? ?? ????
  • ??????? ???????? ? ??????? ????????

25
Size reduction
iconst_m1
push (byte)-1
n if (x lt 9 x gt 3) then x 3 else
OTHER_OPCODE push (byte)n
iconst_n
bipush
push x
sipush
push x
ldc
push CONST_POOLx
ldc_w
push CONST_POOLx
26
Vierifier
  • invoke virtual
  • ????? ?????? ???? ????? ?????? ??? ?????? ??????.
  • ? ??? ?????????
  • verifier
  • ? runtime

27
JIT
  • Pros vs Cons
  • Time 2x-40x faster
  • Memory Overhead 5x-10x
  • Compilation
  • JIT Just-In-Time
  • AOT Ahead-Of-Time
  • HI Hotspot Implementations

28
Garbage collection(????? ?????)
  • ????? ? ??????? ??????????? ?????????????
  • ? ????????? ??????? ??? ??? ???????????
  • ??? ????? ???? ??????????? ??????... ??????
    ??????? ??? ????
  • ??????????? ???? ?????? ? ?????? ?????? ? ???...
  • ???? ???????????? ?????????? ??? ?????????????,
    ???? ??? ????????????? ???????????? ? ??????
    ??????

29
Obfuscation
30
Obfuscation and Java
  • Pros
  • ??? ?? ????? ???? ??????????
  • Java ?????? ????? ?????????????
  • ?????????? ???????? ?????
  • Cons
  • Reflection ????? ???????? ???????
  • ????????? Java ?????? ??????????

31
Decompilers
  • Goto
  • ?????? ????? for ? synchronized ? ????-????
    ?? ?? ?????? ????? ??????? ? Java
  • ??? ???????? ????????, ???? ?? ?? ???????. ??????
    ????? ? ????? ?? ????????????, ???? ??? ??????????

32
Decompilers
? ?????? ??? ???? ?????????????.
b a a b
int tmp tmp a a b b tmp
iload_0 iload_1 istore_0 istore_1
iload_0 istore_2 iload_1 istore_0 iload_2 istore_1

???????????
33
Obfuscation - Names and profiles (Retroguard)
  • GNU GPL
  • ??????????

34
Names and profiles (JODE)
  • GNU GPL
  • ?????????????? ???????, ??????? ? ?????
  • ???????? ?????????? ??????????
  • ???????? ???????? ???? (???????, ???????,
    ?????)
  • ??????????? ????????? ????????? ??????????
  • ???? ????????????

35
Names and profiles (SandMark)
  • ?????? ??????????? ???????????? ?????????
    watermarking, tamper-proofing ? code obfuscation
  • ??????? ?? ?????????? by Venkatesan, Collberg,
    Stern, and others

36
Names and profiles (DashO)
  • Commercial
  • Suns choice
  • Features
  • Package/Class/Method/Field renaming using our
    patented Overload-Induction(tm) renaming system
  • Unused Class/Method/Field and constant pool entry
    removal
  • Advanced Control Flow Obfuscation
  • String Encryption
  • Class and method level optimization to improve
    JIT performance

37
Names and profiles
???????? ???? (name mangling) ????????? ?????? ????????? (code mangling) ??????????? ????? (strings enscription)
Retroguard ?
SandMark ? ?
DashO
JODE ?
38
Where is more information available?
  • ????????????? ?????????? ? Java ?????? ??????????
    ? ???????????? SUN ? ?????? ???? ???
  • http//sunsite.nstu.ru/java-stuff/vmspec/
  • ?????????? ? ?????????? ? classfile
  • ftp//ftp.cs.arizona.edu/reports/2004/TR04-11.pdf
  • ????????? ???????????
  • http//www.retrologic.com/retroguard-docs.html
  • http//sandmark.cs.arizona.edu/publications.html
  • http//www.preemptive.com/products/dasho/Features.
    html

39
THE END
  • ??????? ?? ????????

40
Q A
  • ?????? ?????? ?????
Write a Comment
User Comments (0)
About PowerShow.com