-
Notifications
You must be signed in to change notification settings - Fork 41
/
injectMethod.js
196 lines (162 loc) · 5.9 KB
/
injectMethod.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
const Start = '0x00667D80';
const ShowResult = '0x00667F14';
const ChangeA = '0x006684E8';
const changeB = '0x00668518';
const ChangeStr = '0x00668558';
const ChangeC = '0x006685EC';
const ChangeAr = '0x00668620';
const changeListInt = '0x0066869C';
const ChaneListStr = '0x00668738';
const GetIntA = '0x00668834';
const GetBoolB = '0x006688E8';
const GetStringStr = '0x0066898C';
const GetFloatC = '0x00668A1C';
const GetArrayInt = '0x00668AD8';
const ChangeValueStaticIntA = '0x00668BA0';
const changeValueStringStatic = '0x00668C34';
const GetListInt = '0x00668D00';
const GetListStr = '0x00668D78';
const ShowResultMethod = '0x00668DF0';
var count = 0;
var il2cpp = null;
function awaitForCondition(callback) {
var i = setInterval(function () {
var addr = Module.findBaseAddress('libil2cpp.so');
//console.log("Address found:", addr);
if (addr) {
clearInterval(i);
callback(+addr);
}
}, 0);
}
Java.perform(function () {
awaitForCondition(function (base) {
il2cpp = ptr(base);
tamperGetIntA()
// tamperGetArrayInt()
//tamperGetStringStr()
//callChangeA()
replaceChangeC()
makeToast('Modded by somebody')
})
})
function tamperGetIntA() {
Interceptor.attach(il2cpp.add(GetIntA), {
onEnter: function (args) {
console.log("getIntA is calling");
//args[1] = ptr(-999)
this.val = args[1] //int val
this.instance = args[0]
console.log('value argument:', this.val.toInt32());
},
onLeave: function (ret_val) {
console.log('getIntA was called');
//console.log(this.val.toInt32());
console.log('return value:', ret_val.toInt32()); // real value going to be returned
//ret_val.replace(-9)
return ret_val;
}
})
}
function tamperGetArrayInt() {
Interceptor.attach(il2cpp.add(GetArrayInt), {
onEnter: function (args) {
console.log("GetArrayInt is calling");
var ar = args[1]
console.log(ar.readByteArray(100));
console.log("array length:", ar.add(0x18).readInt());
console.log("array 0:", ar.add(0x20).readInt());
console.log("array 1:", ar.add(0x24).readInt());
console.log("array 2:", ar.add(0x28).readInt());
ar.add(0x20).writeInt(99)
ar.add(0x24).writeInt(99)
ar.add(0x28).writeInt(99)
},
onLeave: function (ret_val) {
console.log('GetArrayInt was called');
var ar = ret_val
//console.log(ar.readByteArray(100));
console.log("array length:", ar.add(0x18).readInt());
console.log("array 0:", ar.add(0x20).readInt());
console.log("array 1:", ar.add(0x24).readInt());
console.log("array 2:", ar.add(0x28).readInt());
ar.add(0x20).writeInt(11)
ar.add(0x24).writeInt(11)
ar.add(0x28).writeInt(111)
//return ret_val;
}
})
}
function tamperGetStringStr() {
Interceptor.attach(il2cpp.add(GetStringStr), {
onEnter: function (args) {
console.log("GetStringStr is calling");
this.val = args[1] //int val
count++;
},
onLeave: function (ret_val) {
switch (count) {
case 1:
console.log('value str:', ret_val.add(0x14).readUtf16String());
ret_val.add(0x14).writeUtf16String('see you again')
break;
case 2:
console.log('value static str:', ret_val.add(0x14).readUtf16String());
ret_val.add(0x14).writeUtf16String('!!!')
count = 0;
break;
default:
break;
}
return ret_val;
}
})
}
function tamperGetStringStr() {
Interceptor.attach(il2cpp.add(GetStringStr), {
onEnter: function (args) {
console.log("GetStringStr is calling");
this.val = args[1] //int val
count++;
},
onLeave: function (ret_val) {
switch (count) {
case 1:
console.log('value str:', ret_val.add(0x14).readUtf16String());
ret_val.add(0x14).writeUtf16String('see you again')
break;
case 2:
console.log('value static str:', ret_val.add(0x14).readUtf16String());
ret_val.add(0x14).writeUtf16String('!!!')
count = 0;
break;
default:
break;
}
return ret_val;
}
})
}
function callChangeA() {
Interceptor.attach(il2cpp.add(ShowResult), {
onEnter: function (args) {
this.instance = args[0]
new NativeFunction(il2cpp.add(ChangeA), 'void', ['pointer'])(this.instance);
}
})
}
function replaceChangeC() {
Interceptor.replace(il2cpp.add(ChangeC), new NativeCallback(function (instance) {
console.log('ChangeC is now ChangeA');
new NativeFunction(il2cpp.add(ChangeA), 'void', ['pointer'])(instance);
}, 'void', ['pointer']));
}
function makeToast(string) {
Java.perform(function () {
var context = Java.use('android.app.ActivityThread').currentApplication().getApplicationContext();
Java.scheduleOnMainThread(function () {
var toast = Java.use("android.widget.Toast");
toast.makeText(Java.use("android.app.ActivityThread").currentApplication().getApplicationContext(), Java.use("java.lang.String").$new(string), 1).show();
});
});
}