-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoin_hook.js
More file actions
210 lines (194 loc) · 7.63 KB
/
Copy pathcoin_hook.js
File metadata and controls
210 lines (194 loc) · 7.63 KB
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
* Subway City - Coin Value Modifier
* Hook các hàm coin để nhân giá trị lên
*/
var MULTIPLIER = 10; // <== Thay đổi hệ số nhân ở đây
var uf = Process.getModuleByName("UnityFramework");
// ============ IL2CPP API ============
var il2cpp = {
domain_get: new NativeFunction(uf.getExportByName("il2cpp_domain_get"), "pointer", []),
domain_get_assemblies: new NativeFunction(uf.getExportByName("il2cpp_domain_get_assemblies"), "pointer", ["pointer", "pointer"]),
assembly_get_image: new NativeFunction(uf.getExportByName("il2cpp_assembly_get_image"), "pointer", ["pointer"]),
image_get_class_count: new NativeFunction(uf.getExportByName("il2cpp_image_get_class_count"), "uint32", ["pointer"]),
image_get_class: new NativeFunction(uf.getExportByName("il2cpp_image_get_class"), "pointer", ["pointer", "uint32"]),
class_get_name: new NativeFunction(uf.getExportByName("il2cpp_class_get_name"), "pointer", ["pointer"]),
class_get_methods: new NativeFunction(uf.getExportByName("il2cpp_class_get_methods"), "pointer", ["pointer", "pointer"]),
method_get_name: new NativeFunction(uf.getExportByName("il2cpp_method_get_name"), "pointer", ["pointer"]),
image_get_name: new NativeFunction(uf.getExportByName("il2cpp_image_get_name"), "pointer", ["pointer"]),
};
// ============ Resolve methods ============
function findMethod(className, methodName) {
var domain = il2cpp.domain_get();
var sizePtr = Memory.alloc(4);
var assemblies = il2cpp.domain_get_assemblies(domain, sizePtr);
var asmCount = sizePtr.readU32();
for (var i = 0; i < asmCount; i++) {
var asm = assemblies.add(i * Process.pointerSize).readPointer();
var image = il2cpp.assembly_get_image(asm);
var imgName = il2cpp.image_get_name(image).readUtf8String();
if (imgName.indexOf("SYBO") === -1) continue;
var classCount = il2cpp.image_get_class_count(image);
for (var j = 0; j < classCount; j++) {
var klass = il2cpp.image_get_class(image, j);
var cName = il2cpp.class_get_name(klass).readUtf8String();
if (cName !== className) continue;
var iter = Memory.alloc(Process.pointerSize);
iter.writePointer(ptr(0));
var m;
while (!(m = il2cpp.class_get_methods(klass, iter)).isNull()) {
var mName = il2cpp.method_get_name(m).readUtf8String();
if (mName === methodName) {
return m.readPointer(); // function pointer
}
}
}
}
return null;
}
var hooks = [
// ====================================
// 1. get_CoinWorth - giá trị mỗi coin sack
// int get_CoinWorth(this)
// Return value x MULTIPLIER
// ====================================
{
cls: "CoinSackPickupConfig",
method: "get_CoinWorth",
hook: function(fnPtr) {
Interceptor.attach(fnPtr, {
onLeave: function(retval) {
var original = retval.toInt32();
var modified = original * MULTIPLIER;
retval.replace(modified);
console.log("[CoinWorth] " + original + " -> " + modified);
}
});
}
},
// ====================================
// 2. get_Coins - đọc số coin hiện tại
// int get_Coins(this)
// Chỉ log để theo dõi
// ====================================
{
cls: "QuestTriggerContext",
method: "get_Coins",
hook: function(fnPtr) {
Interceptor.attach(fnPtr, {
onLeave: function(retval) {
console.log("[get_Coins] current = " + retval.toInt32());
}
});
}
},
// ====================================
// 3. set_Coins - ghi số coin
// void set_Coins(this, int value)
// Nhân value lên MULTIPLIER lần
// ====================================
{
cls: "QuestTriggerContext",
method: "set_Coins",
hook: function(fnPtr) {
Interceptor.attach(fnPtr, {
onEnter: function(args) {
var original = args[1].toInt32();
var modified = original * MULTIPLIER;
args[1] = ptr(modified);
console.log("[set_Coins] " + original + " -> " + modified);
}
});
}
},
// ====================================
// 4. GetExtraCoinsFromPerk - coin bonus từ perk
// int GetExtraCoinsFromPerk(this, arg1)
// Return value x MULTIPLIER
// ====================================
{
cls: "CoinSackProcessSystem",
method: "GetExtraCoinsFromPerk",
hook: function(fnPtr) {
Interceptor.attach(fnPtr, {
onLeave: function(retval) {
var original = retval.toInt32();
var modified = original * MULTIPLIER;
retval.replace(modified);
console.log("[ExtraCoinsFromPerk] " + original + " -> " + modified);
}
});
}
},
// ====================================
// 5. UpdateCoinBonusMultiplier - hệ số bonus cuối run
// void UpdateCoinBonusMultiplier(this, float/int multiplier)
// Nhân multiplier lên
// ====================================
{
cls: "ScreenRunOver",
method: "UpdateCoinBonusMultiplier",
hook: function(fnPtr) {
Interceptor.attach(fnPtr, {
onEnter: function(args) {
console.log("[CoinBonusMultiplier] arg1 = " + args[1]);
}
});
}
},
// ====================================
// 6. CoinsPickupSystem.Run - hệ thống nhặt coin chính
// Theo dõi khi nào coin được nhặt
// ====================================
{
cls: "CoinsPickupSystem",
method: "Run",
hook: function(fnPtr) {
Interceptor.attach(fnPtr, {
onEnter: function(args) {
console.log("[CoinsPickup] Run called");
}
});
}
},
// ====================================
// 7. TerminalOutcome.Coins - coin từ mystery box
// Return value x MULTIPLIER
// ====================================
{
cls: "TerminalOutcome",
method: "Coins",
hook: function(fnPtr) {
Interceptor.attach(fnPtr, {
onLeave: function(retval) {
var original = retval.toInt32();
if (original > 0) {
var modified = original * MULTIPLIER;
retval.replace(modified);
console.log("[TerminalCoins] " + original + " -> " + modified);
}
}
});
}
},
];
// ============ Install all hooks ============
var installed = 0;
hooks.forEach(function(h) {
var fnPtr = findMethod(h.cls, h.method);
if (fnPtr && !fnPtr.isNull()) {
try {
h.hook(fnPtr);
installed++;
console.log("[+] Hooked " + h.cls + "." + h.method + " @ " + fnPtr);
} catch(e) {
console.log("[-] Failed " + h.cls + "." + h.method + ": " + e);
}
} else {
console.log("[-] Not found: " + h.cls + "." + h.method);
}
});
console.log("\n=== Coin Hook Active ===");
console.log("Multiplier: x" + MULTIPLIER);
console.log("Hooks installed: " + installed + "/" + hooks.length);
console.log("Choi game di! Coin se duoc nhan x" + MULTIPLIER);
console.log("========================\n");