赞
踩
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
1. struct DexHeader {
2. u1 magic[8]; /* includes version number */
3. u4 checksum; /* adler32 checksum */
4. u1 signature[kSHA1DigestLen]; /* SHA-1
hash
*/
5. u4 fileSize; /* length of entire
file
*/
6. u4 headerSize; /* offset to start of next section */
7. u4 endianTag;
8. u4 linkSize;
9. u4 linkOff;
10. u4 mapOff;
11. u4 stringIdsSize;
12. u4 stringIdsOff;
13. u4 typeIdsSize;
14. u4 typeIdsOff;
15. u4 protoIdsSize;
16. u4 protoIdsOff;
17. u4 fieldIdsSize;
18. u4 fieldIdsOff;
19. u4 methodIdsSize;
20. u4 methodIdsOff;
21. u4 classDefsSize;
22. u4 classDefsOff;
23. u4 dataSize;
24. u4 dataOff;
25. };
|
1
2
3
4
5
|
1. struct DexStringId {
2. u4 stringDataOff; /*
file
offset to string_data_item */
3. };
|
1
2
3
4
5
|
1. struct DexTypeId {
2. u4 descriptorIdx; /* index into stringIds list
for
type
descriptor */
3. };
|
1
2
3
4
5
6
7
8
9
|
1. struct DexProtoId {
2. u2 classIdx; /* index into typeIds list
for
defining class */
3. u2 typeIdx; /* index into typeIds
for
field
type
*/
4. u4 nameIdx; /* index into stringIds
for
field name */
5. };
|
1
2
3
4
5
6
7
8
9
|
1. struct DexFieldId {
2. u2 classIdx; /* index into typeIds list
for
defining class */
3. u2 typeIdx; /* index into typeIds
for
field
type
*/
4. u4 nameIdx; /* index into stringIds
for
field name */
5. };
|
1
2
3
4
5
6
7
8
9
|
1. struct DexMethodId {
2. u2 classIdx; /* index into typeIds list
for
defining class */
3. u2 protoIdx; /* index into protoIds
for
method prototype */
4. u4 nameIdx; /* index into stringIds
for
method name */
5. };
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
1. struct DexClassDef {
2. u4 classIdx; /* index into typeIds
for
this class */
3. u4 accessFlags;
4. u4 superclassIdx; /* index into typeIds
for
superclass */
5. u4 interfacesOff; /*
file
offset to DexTypeList */
6. u4 sourceFileIdx; /* index into stringIds
for
source
file
name */
7. u4 annotationsOff; /*
file
offset to annotations_directory_item */
8. u4 classDataOff; /*
file
offset to class_data_item */
9. u4 staticValuesOff; /*
file
offset to DexEncodedArray */
10. };
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
1. struct DexClassData {
2. DexClassDataHeader header;
3. DexField* staticFields;
4. DexField* instanceFields;
5. DexMethod* directMethods;
6. DexMethod* virtualMethods;
7. };
|
1
2
3
4
5
6
7
|
1. struct DexField {
2. u4 fieldIdx; /* index to a field_id_item */
3. u4 accessFlags;
4. };
|
1
2
3
4
5
6
7
8
9
|
1. struct DexMethod {
2. u4 methodIdx; /* index to a method_id_item */
3. u4 accessFlags;
4. u4 codeOff; /*
file
offset to a code_item */
5. };
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
1. struct DexCode {
2. u2 registersSize;
3. u2 insSize;
4. u2 outsSize;
5. u2 triesSize;
6. u4 debugInfoOff; /*
file
offset to debug info stream */
7. u4 insnsSize; /* size of the insns array,
in
u2
units
*/
8. u2 insns[1];
9. /* followed by optional u2 padding */
10. /* followed by try_item[triesSize] */
11. /* followed by uleb128 handlersSize */
12. /* followed by catch_handler_item[handlersSize] */
13. };
|
1
2
3
4
5
6
7
|
1. String apkPath = this.getPackageCodePath();
2. ZipFile apkfile = new ZipFile(apkPath);
3. ZipEntry dexentry = zipfile.getEntry(
"classes.dex"
);
4. InputStream dexstream = zipfile.getInputStream(dexentry);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
1. String apkPath = this.getPackageCodePath();
2. Long dexCrc = Long.parseLong(this.getString(R.string.dex_crc));
3. try {
4. ZipFile zipfile = new ZipFile(apkPath);
5. ZipEntry dexentry = zipfile.getEntry(
"classes.dex"
);
6.
if
(dexentry.getCrc() != dexCrc){
7. System.out.println(
"Dex has been *modified!"
);
8. }
else
{
9. System.out.println(
"Dex hasn't been modified!"
);
10. }
11. } catch (IOException e) {
12.
//
TODO Auto-generated catch block
13. e.printStackTrace();
14. }
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
1. MessageDigest msgDigest = null;
2. try {
3. msgDigest = MessageDigest.getInstance(
"MD5"
)
4. byte[] bytes = new byte[8192];
5. int byteCount;
6. FileInputStream fis = null;
7. fis = new FileInputStream(new File(apkPath));
8.
while
((byteCount = fis.
read
(bytes)) > 0)
9. msgDigest.update(bytes, 0, byteCount);
10. BigInteger bi = new BigInteger(1, msgDigest.digest());
11. String md5 = bi.toString(16);
12. fis.close();
13. /*
14. 从服务器获取存储的 Hash 值,并进行比较
15. */
16. } catch (Exception e) {
17. e.printStackTrace();
18. }
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
1. public class Reflection {
2. public void methodA(){
3. System.out.println(
"Invoke methodA"
);
4. }
5. public void methodB(){
6. System.out.println(
"Invoke methodB"
);
7. }
8. }
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
1. protected void onCreate(Bundle savedInstanceState) {
2. ......
3. Reflection reflection = new Reflection();
4. reflection.methodA();
5. reflection.methodB();
6.
7. Class[] consTypes = new Class[]{};
8. Class reflectionCls = null;
9. String className =
"com.example.reflection.Reflection"
;
10. String methodName =
"methodA"
;
11. try {
12. reflectionCls = Class.forName(className);
13. Constructor cons = reflectionCls.getConstructor(consTypes);
14. Reflection reflectionIns = (Reflection) cons.newInstance(new Object[]{});
15. Method method = reflectionCls.getDeclaredMethod(methodName, new Class[]{});
16. method.invoke(reflectionIns, new Object[]{});
17. } catch (Exception e) {
18.
//
TODO Auto-generated catch block
19. e.printStackTrace();
20. }
21. }
|
1
2
|
1. public DexClassLoader (String dexPath, String optimizedDirectory, String
libraryPath, ClassLoader parent)
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
1. DexClassLoader classLoader = new DexClassLoader(apkPath, dexPath, null,
getClassLoader());
2. try {
3. Class<?> mLoadClass =
classLoader.loadClass(
"com.example.dexclassloaderslave.DexSlave"
);
4. Constructor<?> constructor = mLoadClass.getConstructor(new Class[] {});
5. Object dexSlave = constructor.newInstance(new Object[] {});
6. Method sayHello = mLoadClass.getDeclaredMethod(
"sayHello"
, new Class[]{} );
7. sayHello.setAccessible(
true
);
8. sayHello.invoke(dexSlave, new Object[]{});
9. } catch (Exception e)
10. {
11. e.printStackTrace();
12. }
|
1
|
1. String str =
"I am a string!"
;
|
1
|
1. const-string v0,
"I am a string!"
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
1. .line 26
2. .
local
v10, strBuilder:Ljava
/lang/StringBuilder
;
3. const-string v11,
"I"
4. invoke-virtual {v10, v11},
Ljava
/lang/StringBuilder
;->append(Ljava
/lang/String
;)Ljava
/lang/StringBuilder
;
5. .line 27
6. const-string v11,
"am"
7. invoke-virtual {v10, v11},
Ljava
/lang/StringBuilder
;->append(Ljava
/lang/String
;)Ljava
/lang/StringBuilder
;
8. .line 28
9. const-string v11,
"a"
10. invoke-virtual {v10, v11},
Ljava
/lang/StringBuilder
;->append(Ljava
/lang/String
;)Ljava
/lang/StringBuilder
;
11. .line 29
12. const-string v11,
"String"
13. invoke-virtual {v10, v11},
Ljava
/lang/StringBuilder
;->append(Ljava
/lang/String
;)Ljava
/lang/StringBuilder
;
14. .line 30
15. invoke-virtual {v10}, Ljava
/lang/StringBuilder
;->toString()Ljava
/lang/String
;
|
1
2
3
4
5
6
7
8
9
10
11
|
1. public void
test
(){
2. int a = 1;
3. int b = 2;
4. int c = a + b;
5. System.out.println(c);
6. }
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
1. .method public
test
()V
2. .locals 4
3.
4. .prologue
5. .line 24
6. const
/4
v0, 0x1
7.
8. .line 25
9. .
local
v0, a:I
10. const
/4
v1, 0x2
11.
12. .line 26
13. .
local
v1, b:I
14. add-int v2, v0, v1
15.
16. .line 27
17. .
local
v2, c:I
18. sget-object v3, Ljava
/lang/System
;->out:Ljava
/io/PrintStream
;
19.
20. invoke-virtual {v3, v2}, Ljava
/io/PrintStream
;->println(I)V
21.
22. .line 28
23.
return
-void
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
1. .method public
test
()V
2. .locals 4
3.
4. .
local
v2, c:I
5. goto :lab1
6. :lab3
7. sget-object v3, Ljava
/lang/System
;->out:Ljava
/io/PrintStream
;
8. invoke-virtual {v3, v2}, Ljava
/io/PrintStream
;->println(I)V
9. goto :end
10.
11. .
local
v1, b:I
12. :lab2
13. add-int v2, v0, v1
14. goto :lab3
15.
16. .
local
v0, a:I
17. :lab1
18. const
/4
v0, 0x1
19. const
/4
v1, 0x2
20. goto :lab2
21.
22. :end
23.
return
-void
24. .end method
|
1
2
3
|
1. TelephonyManager manager = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
2. String imsi = manager.getSubscriberId();
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
1. private static String[] known_files = {
2.
"/system/lib/libc_malloc_debug_qemu.so"
,
3.
"/sys/qemu_trace"
,
4.
"/system/bin/qemu-props"
5. };
6.
7. public static boolean hasQEmuFiles() {
8.
for
(String pipe : known_files) {
9. File qemu_file = new File(pipe);
10.
if
(qemu_file.exists())
11.
return
true
;
12. }
13.
return
false
;
14. }
|
1
2
3
4
5
6
7
8
9
|
1. unsigned int gpbf = get2LE(lfhBuf + kLFHGPBFlags);
2.
if
((gpbf & kGPFUnsupportedMask) != 0) {
3. ALOGW(
"Invalid General Purpose Bit Flag: %d"
, gpbf);
4.
return
false
;
5. }
|
1
2
3
4
5
6
7
|
1.
if
(getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE != 0){
2. System.out.println(
"Debug"
);
3. android.os.Process.killProcess(android.os.Process.myPid());
4. }
|
1
|
1. proguard.config=${sdk.
dir
}
/tools/proguard/proguard-android
.txt:proguard-project.txt
|
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。