Skip to content
This repository was archived by the owner on Jul 27, 2024. It is now read-only.

Commit 2b15194

Browse files
Add examples
1 parent 45c945e commit 2b15194

File tree

34 files changed

+1560
-12
lines changed

34 files changed

+1560
-12
lines changed

.idea/webResources.xml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
.class public Lobfuscapk/demo/OrderDemo;
2+
.super Ljava/lang/Object;
3+
.source "OrderDemo.java"
4+
5+
6+
# direct methods
7+
.method public constructor <init>()V
8+
.locals 0
9+
10+
.prologue
11+
.line 6
12+
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
13+
14+
return-void
15+
.end method
16+
17+
.method public static getGotoMessage()Ljava/lang/String;
18+
.locals 5
19+
20+
const v0, 7
21+
const v1, 4
22+
add-int v0, v0, v1
23+
rem-int v0, v0, v1
24+
if-gtz v0, :EbAukdQwmmPELTjd
25+
goto/32 :bPdknjDcQesDQUPu
26+
:EbAukdQwmmPELTjd
27+
:KbkerIsqVXNivOzU
28+
29+
.prologue
30+
.line 9
31+
new-instance v3, Ljava/util/ArrayList;
32+
33+
invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V
34+
35+
.line 11
36+
.local v3, "messages":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Ljava/lang/String;>;"
37+
const-string/jumbo v0, "message1"
38+
39+
.line 12
40+
.local v0, "message1":Ljava/lang/String;
41+
invoke-virtual {v3, v0}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
42+
43+
.line 14
44+
const-string/jumbo v1, "message2"
45+
46+
.line 15
47+
.local v1, "message2":Ljava/lang/String;
48+
invoke-virtual {v3, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
49+
50+
.line 17
51+
const-string/jumbo v2, "message3"
52+
53+
.line 18
54+
.local v2, "message3":Ljava/lang/String;
55+
invoke-virtual {v3, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
56+
57+
.line 20
58+
invoke-virtual {v3}, Ljava/util/ArrayList;->toArray()[Ljava/lang/Object;
59+
60+
move-result-object v4
61+
62+
invoke-static {v4}, Ljava/util/Arrays;->toString([Ljava/lang/Object;)Ljava/lang/String;
63+
64+
move-result-object v4
65+
66+
return-object v4
67+
:bPdknjDcQesDQUPu
68+
goto/32 :KbkerIsqVXNivOzU
69+
.end method
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
.class public Lobfuscapk/demo/OrderDemo;
2+
.super Ljava/lang/Object;
3+
.source "OrderDemo.java"
4+
5+
6+
# direct methods
7+
.method public constructor <init>()V
8+
.locals 0
9+
10+
.prologue
11+
.line 6
12+
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
13+
14+
return-void
15+
.end method
16+
17+
.method public static getGotoMessage()Ljava/lang/String;
18+
.locals 5
19+
20+
.prologue
21+
.line 9
22+
new-instance v3, Ljava/util/ArrayList;
23+
24+
invoke-direct {v3}, Ljava/util/ArrayList;-><init>()V
25+
26+
.line 11
27+
.local v3, "messages":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Ljava/lang/String;>;"
28+
const-string/jumbo v0, "message1"
29+
30+
.line 12
31+
.local v0, "message1":Ljava/lang/String;
32+
invoke-virtual {v3, v0}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
33+
34+
.line 14
35+
const-string/jumbo v1, "message2"
36+
37+
.line 15
38+
.local v1, "message2":Ljava/lang/String;
39+
invoke-virtual {v3, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
40+
41+
.line 17
42+
const-string/jumbo v2, "message3"
43+
44+
.line 18
45+
.local v2, "message3":Ljava/lang/String;
46+
invoke-virtual {v3, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z
47+
48+
.line 20
49+
invoke-virtual {v3}, Ljava/util/ArrayList;->toArray()[Ljava/lang/Object;
50+
51+
move-result-object v4
52+
53+
invoke-static {v4}, Ljava/util/Arrays;->toString([Ljava/lang/Object;)Ljava/lang/String;
54+
55+
move-result-object v4
56+
57+
return-object v4
58+
.end method
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package obfuscapk.demo;
2+
3+
import java.util.ArrayList;
4+
import java.util.Arrays;
5+
6+
public class OrderDemo {
7+
public static String getGotoMessage() {
8+
// Just some ordered instructions.
9+
ArrayList<String> messages = new ArrayList<>();
10+
11+
String message1 = "message1";
12+
messages.add(message1);
13+
14+
String message2 = "message2";
15+
messages.add(message2);
16+
17+
String message3 = "message3";
18+
messages.add(message3);
19+
20+
return Arrays.toString(messages.toArray());
21+
}
22+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
.class public Lobfuscapk/demo/AssetDemo;
2+
.super Ljava/lang/Object;
3+
.source "AssetDemo.java"
4+
5+
6+
# direct methods
7+
.method public constructor <init>()V
8+
.locals 0
9+
10+
.prologue
11+
.line 9
12+
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
13+
14+
return-void
15+
.end method
16+
17+
.method private static readBytes(Ljava/io/InputStream;)[B
18+
.locals 4
19+
.param p0, "inputStream" # Ljava/io/InputStream;
20+
.annotation system Ldalvik/annotation/Throws;
21+
value = {
22+
Ljava/io/IOException;
23+
}
24+
.end annotation
25+
26+
.prologue
27+
.line 12
28+
const/16 v3, 0x400
29+
30+
new-array v0, v3, [B
31+
32+
.line 13
33+
.local v0, "array":[B
34+
new-instance v1, Ljava/io/ByteArrayOutputStream;
35+
36+
invoke-direct {v1}, Ljava/io/ByteArrayOutputStream;-><init>()V
37+
38+
.line 15
39+
.local v1, "byteArrayOutputStream":Ljava/io/ByteArrayOutputStream;
40+
:goto_0
41+
invoke-virtual {p0, v0}, Ljava/io/InputStream;->read([B)I
42+
43+
move-result v2
44+
45+
.line 16
46+
.local v2, "read":I
47+
const/4 v3, -0x1
48+
49+
if-ne v2, v3, :cond_0
50+
51+
.line 21
52+
invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B
53+
54+
move-result-object v3
55+
56+
return-object v3
57+
58+
.line 19
59+
:cond_0
60+
const/4 v3, 0x0
61+
62+
invoke-virtual {v1, v0, v3, v2}, Ljava/io/ByteArrayOutputStream;->write([BII)V
63+
64+
goto :goto_0
65+
.end method
66+
67+
68+
# virtual methods
69+
.method public getMessageFromAsset(Landroid/content/res/AssetManager;)Ljava/lang/String;
70+
.locals 3
71+
.param p1, "assetManager" # Landroid/content/res/AssetManager;
72+
.annotation system Ldalvik/annotation/Throws;
73+
value = {
74+
Ljava/io/IOException;
75+
}
76+
.end annotation
77+
78+
.prologue
79+
.line 26
80+
const-string/jumbo v1, "message.txt"
81+
82+
invoke-static {p1, v1}, Lcom/decryptassetmanager/DecryptAsset;->decryptAsset(Landroid/content/res/AssetManager;Ljava/lang/String;)Ljava/io/InputStream;
83+
84+
move-result-object v0
85+
86+
.line 27
87+
.local v0, "assetInputStream":Ljava/io/InputStream;
88+
new-instance v1, Ljava/lang/String;
89+
90+
invoke-static {v0}, Lobfuscapk/demo/AssetDemo;->readBytes(Ljava/io/InputStream;)[B
91+
92+
move-result-object v2
93+
94+
invoke-direct {v1, v2}, Ljava/lang/String;-><init>([B)V
95+
96+
return-object v1
97+
.end method
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
.class public Lobfuscapk/demo/AssetDemo;
2+
.super Ljava/lang/Object;
3+
.source "AssetDemo.java"
4+
5+
6+
# direct methods
7+
.method public constructor <init>()V
8+
.locals 0
9+
10+
.prologue
11+
.line 9
12+
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
13+
14+
return-void
15+
.end method
16+
17+
.method private static readBytes(Ljava/io/InputStream;)[B
18+
.locals 4
19+
.param p0, "inputStream" # Ljava/io/InputStream;
20+
.annotation system Ldalvik/annotation/Throws;
21+
value = {
22+
Ljava/io/IOException;
23+
}
24+
.end annotation
25+
26+
.prologue
27+
.line 12
28+
const/16 v3, 0x400
29+
30+
new-array v0, v3, [B
31+
32+
.line 13
33+
.local v0, "array":[B
34+
new-instance v1, Ljava/io/ByteArrayOutputStream;
35+
36+
invoke-direct {v1}, Ljava/io/ByteArrayOutputStream;-><init>()V
37+
38+
.line 15
39+
.local v1, "byteArrayOutputStream":Ljava/io/ByteArrayOutputStream;
40+
:goto_0
41+
invoke-virtual {p0, v0}, Ljava/io/InputStream;->read([B)I
42+
43+
move-result v2
44+
45+
.line 16
46+
.local v2, "read":I
47+
const/4 v3, -0x1
48+
49+
if-ne v2, v3, :cond_0
50+
51+
.line 21
52+
invoke-virtual {v1}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B
53+
54+
move-result-object v3
55+
56+
return-object v3
57+
58+
.line 19
59+
:cond_0
60+
const/4 v3, 0x0
61+
62+
invoke-virtual {v1, v0, v3, v2}, Ljava/io/ByteArrayOutputStream;->write([BII)V
63+
64+
goto :goto_0
65+
.end method
66+
67+
68+
# virtual methods
69+
.method public getMessageFromAsset(Landroid/content/res/AssetManager;)Ljava/lang/String;
70+
.locals 3
71+
.param p1, "assetManager" # Landroid/content/res/AssetManager;
72+
.annotation system Ldalvik/annotation/Throws;
73+
value = {
74+
Ljava/io/IOException;
75+
}
76+
.end annotation
77+
78+
.prologue
79+
.line 26
80+
const-string/jumbo v1, "message.txt"
81+
82+
invoke-virtual {p1, v1}, Landroid/content/res/AssetManager;->open(Ljava/lang/String;)Ljava/io/InputStream;
83+
84+
move-result-object v0
85+
86+
.line 27
87+
.local v0, "assetInputStream":Ljava/io/InputStream;
88+
new-instance v1, Ljava/lang/String;
89+
90+
invoke-static {v0}, Lobfuscapk/demo/AssetDemo;->readBytes(Ljava/io/InputStream;)[B
91+
92+
move-result-object v2
93+
94+
invoke-direct {v1, v2}, Ljava/lang/String;-><init>([B)V
95+
96+
return-object v1
97+
.end method
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package obfuscapk.demo;
2+
3+
import android.content.res.AssetManager;
4+
5+
import java.io.ByteArrayOutputStream;
6+
import java.io.IOException;
7+
import java.io.InputStream;
8+
9+
public class AssetDemo {
10+
// Helper method.
11+
private static byte[] readBytes(InputStream inputStream) throws IOException {
12+
byte[] array = new byte[1024];
13+
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
14+
while (true) {
15+
int read = inputStream.read(array);
16+
if (read == -1) {
17+
break;
18+
}
19+
byteArrayOutputStream.write(array, 0, read);
20+
}
21+
return byteArrayOutputStream.toByteArray();
22+
}
23+
24+
public String getMessageFromAsset(AssetManager assetManager) throws IOException {
25+
// This is the instruction that will be replaced by loading the encrypted asset.
26+
InputStream assetInputStream = assetManager.open("message.txt");
27+
return new String(readBytes(assetInputStream));
28+
}
29+
}

0 commit comments

Comments
 (0)