-
Notifications
You must be signed in to change notification settings - Fork 1
/
Tweak.mm
415 lines (347 loc) · 12.9 KB
/
Tweak.mm
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
#import <CommonCrypto/CommonCrypto.h>
#import <Security/SecKey.h>
#import <substrate.h>
// Hook CCCrypt()
static OSStatus (*original_SecKeyEncrypt) (
SecKeyRef key,
SecPadding padding,
const uint8_t *plainText,
size_t plainTextLen,
uint8_t *cipherText,
size_t *cipherTextLen);
static OSStatus replaced_SecKeyEncrypt(
SecKeyRef key,
SecPadding padding,
const uint8_t *plainText,
size_t plainTextLen,
uint8_t *cipherText,
size_t *cipherTextLen) {
NSLog(@"calling replaced SecKeyPadding %u, plainTextLen %lu, cipherTextLen %lu", padding, plainTextLen, (unsigned long)cipherTextLen);
return original_SecKeyEncrypt(key, padding, plainText, plainTextLen, cipherText, cipherTextLen);
}
static CCCryptorStatus (*original_CCCrypt)(
CCOperation op,
CCAlgorithm alg,
CCOptions options,
const void *key,
size_t keyLength,
const void *iv,
const void *dataIn,
size_t dataInLength,
void *dataOut,
size_t dataOutAvailable,
size_t *dataOutMoved);
static CCCryptorStatus replaced_CCCrypt(
CCOperation op,
CCAlgorithm alg,
CCOptions options,
const void *key,
size_t keyLength,
const void *iv,
const void *dataIn,
size_t dataInLength,
void *dataOut,
size_t dataOutAvailable,
size_t *dataOutMoved)
{
NSLog(@"CCryptCalled %u", alg);
CCCryptorStatus origResult = original_CCCrypt(op, alg, options, key, keyLength, iv, dataIn,
dataInLength, dataOut, dataOutAvailable, dataOutMoved);
return origResult;
}
static int (*original_open)(const char *path, int oflag, mode_t mode);
static FILE* (*original_fopen) ( const char * filename, const char * mode );
static void handleOpen(const char* path) {
if(path != NULL) {
NSString *pathString = [[NSString stringWithUTF8String:path] stringByResolvingSymlinksInPath];
// Results are cached within the broker instance
// and are delivered to the DiOS backend when app execution has finished
if ([pathString hasSuffix:@".js"]) {
NSLog(@"wow js loaded!");
NSLog(@"%@",[NSThread callStackSymbols]);
}
}
}
static int replaced_open(const char *path, int oflag, mode_t mode) {
handleOpen(path);
//NSLog(@"Opening file %s", path);
return original_open(path, oflag, mode);
}
static FILE* replaced_fopen(const char *filename, const char * mode) {
handleOpen(filename);
//NSLog(@"Opening file %s", filename);
return original_fopen(filename, mode);
}
%ctor {
NSLog(@"RELAH ACTIVATED!");
MSHookFunction((void *) CCCrypt, (void *) replaced_CCCrypt, (void **) &original_CCCrypt);
MSHookFunction((void*)open, (void*)replaced_open, (void**)&original_open);
MSHookFunction((void*)fopen, (void*)replaced_fopen, (void**)&original_fopen);
MSHookFunction((void *) SecKeyEncrypt, (void *) replaced_SecKeyEncrypt, (void **) &original_SecKeyEncrypt);
}
%hook UIWebView
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script {
NSLog(@"RELAH: JAVASCRIPT");
NSLog(@"%@", script);
return %orig;
}
%end
/*
%hook SecurityHelper
+ (id)md5DataFromString:(id)arg1 {
NSLog(@"RELAH: md5DataFromString called %@", arg1);
id result = %orig;
NSLog(@"RELAH: md5DataFromString result %@", result);
return result;
}
+ (id)doCipher:(id)arg1 key1:(id)arg2 key2:(id)arg3 operation:(unsigned int)arg4 {
NSLog(@"RELAH: doCipher called arg1: %@, key1: %@, key2: %@", arg1, arg2, arg3);
NSLog(@"DOCIPHER %@",[NSThread callStackSymbols]);
id result = %orig;
NSLog(@"RELAH: doCipher result %@", result);
return @"";
//return result;
}
+ (id)decrypt:(id)arg1 password:(id)arg2 {
NSLog(@"RELAH: decrypt called, arg1: %@, password: %@", arg1, arg2);
id result = %orig;
NSLog(@"RELAH: decrypt result %@", result);
return result;
}
+ (id)encrypt:(id)arg1 password:(id)arg2 {
NSLog(@"RELAH: encrypt called, arg1: %@, password: %@", arg1, arg2);
id result = %orig;
NSLog(@"RELAH: encrypt result %@", result);
return result;
}
- (id)genKEY1:(id)arg1 {
NSLog(@"RELAH: genKey1 called: %@", arg1);
id result = %orig;
NSLog(@"RELAH: genKey1 result %@", result);
return result;
}
- (id)getTimeStamp {
NSLog(@"RELAH: getTimeStamp called");
id result = %orig;
NSLog(@"RELAH: getTimeStamp result %@", result);
return result;
}
- (id)genKEY2 {
NSLog(@"RELAH: genKey1 called");
id result = %orig;
NSLog(@"RELAH: genKey2 result %@", result);
return result;
}
- (id)getUDIDTokenKey {
NSLog(@"RELAH: getUDIDTokenKey Called");
id result = %orig;
NSLog(@"RELAH: getUDIDTokenKey result %@", result);
return result;
}
- (int)charToNum:(id)arg1 {
NSLog(@"RELAH: charToNum called: %@", arg1);
int result = %orig;
NSLog(@"RELAH: charToNum result %u", result);
return result;
}
- (id)toCharArray:(id)arg1 {
NSLog(@"RELAH: toCharArray called: %@", arg1);
id result = %orig;
NSLog(@"RELAH: toCharArray result %@", result);
return result;
}
- (id)genSqlTokens:(id)arg1 decryptEncrypt:(_Bool)arg2 {
NSLog(@"RELAH: genSqlTokens called: %@", arg1);
id result = %orig;
NSLog(@"RELAH: genSqlTokens result %@", result);
return result;
}
- (id)genTokens {
NSLog(@"RELAH: genTokens called");
id result = %orig;
NSLog(@"RELAH: genTokens result %@", result);
return result;
}
%end*/
%hook base64compression
+ (id)base64forData:(id)arg1 {
NSLog(@"RELAH: base64fordata called");
return %orig;
}
+ (id)decodeStringFromKony:(id)arg1 {
NSLog(@"RELAH: decodeStringFromKony called");
return %orig;
}
%end
%hook NSData
- (id)HMACWithAlgorithm:(unsigned int)arg1 key:(id)arg2 {
NSLog(@"RELAH: HMACWithAlgorithm called");
return %orig;
}
- (id)HMACWithAlgorithm:(unsigned int)arg1 {
NSLog(@"RELAH: HMACWithAlgoritmh2 called");
return %orig;
}
- (id)decryptedCASTDataUsingKey:(id)arg1 error:(id *)arg2 {
NSLog(@"RELAH: decryptedCASTDataUsingKey called");
return %orig;
}
- (id)CASTEncryptedDataUsingKey:(id)arg1 error:(id *)arg2 {
NSLog(@"RELAH: CASTEncryptedDataUsingKey called");
return %orig;
}
- (id)decryptedDESDataUsingKey:(id)arg1 error:(id *)arg2 {
NSLog(@"RELAH: decryptedDESDataUsingKey called");
return %orig;
}
- (id)DESEncryptedDataUsingKey:(id)arg1 error:(id *)arg2 {
NSLog(@"RELAH: DESEncryptedDataUsingKey called");
return %orig;
}
- (id)decryptedAES256DataUsingKey:(id)arg1 error:(id *)arg2 {
NSLog(@"RELAH: decryptedAES256DataUsingKey called");
return %orig;
}
- (id)AES256EncryptedDataUsingKey:(id)arg1 error:(id *)arg2 {
NSLog(@"RELAH: AES256EncryptedDataUsingKey called");
return %orig;
}
- (id)decryptedDataUsingAlgorithm:(unsigned int)arg1 key:(id)arg2 initializationVector:(id)arg3 options:(unsigned int)arg4 error:(int *)arg5 {
NSLog(@"RELAH: decryptedDataUsingAlgortihm called");
return %orig;
}
- (id)decryptedDataUsingAlgorithm:(unsigned int)arg1 key:(id)arg2 options:(unsigned int)arg3 error:(int *)arg {
NSLog(@"RELAH: decryptedDataUsingAlgortihm2 called");
return %orig;
}
- (id)decryptedDataUsingAlgorithm:(unsigned int)arg1 key:(id)arg2 error:(int *)arg3 {
NSLog(@"RELAH: decryptedDataUsingAlgortihm3 called");
return %orig;
}
- (id)dataEncryptedUsingAlgorithm:(unsigned int)arg1 key:(id)arg2 initializationVector:(id)arg3 options:(unsigned int)arg4 error:(int *)arg5 {
NSLog(@"RELAH: dataEncryptedusingAlgorthm1 called");
return %orig;
}
- (id)dataEncryptedUsingAlgorithm:(unsigned int)arg1 key:(id)arg2 options:(unsigned int)arg3 error:(int *)arg4 {
NSLog(@"RELAH: dataEncryptedusingAlgorthm1 called");
return %orig;
}
- (id)dataEncryptedUsingAlgorithm:(unsigned int)arg1 key:(id)arg2 error:(int *)arg3 {
NSLog(@"RELAH: dataEncryptedusingAlgorthm1 called");
return %orig;
}
- (id)_runCryptor:(struct _CCCryptor *)arg1 result:(int *)arg2 {
NSLog(@"RELAH: dataEncryptedusingAlgorthm1 called");
return %orig;
}
%end
%hook AESCrypto
+ (id)decryptKeychainData:(id)arg1 key:(id)arg2 {
NSLog(@"RELAH: decryptKeyChainData called");
return %orig;
}
+ (id)decryptData:(id)arg1 randomString:(id)arg2 {
NSLog(@"RELAH: AESCrypto-decryptData called arg1: %@, randomString %@", arg1, arg2);
id result = %orig;
NSLog(@"RELAH: AESCrypto-decryptData result %@", result);
return result;
}
+ (id)encryptData:(id)arg1 randomString:(id)arg2 {
NSLog(@"RELAH: AESCrypto-ENCRYPTData called arg1: %@, randomString %@", arg1, arg2);
id result = %orig;
NSLog(@"RELAH: AESCrypto-ENCRYPTData result %@", result);
return result;
}
%end
%hook RSAEncryption
- (id)randomStringWithLength:(int)arg1 {
NSLog(@"RELAH: randomStringWithLength called %u", arg1);
// NSLog(@"%@",[NSThread callStackSymbols]);
return %orig;
}
- (id)getRandomString {
NSLog(@"RELAH: randomString called");
// NSLog(@"%@",[NSThread callStackSymbols]);
return %orig;
}
- (id)base64forData:(id)arg1 {
NSLog(@"RELAH: base64ForData called %@", arg1);
// NSLog(@"%@",[NSThread callStackSymbols]);
id result = %orig;
NSLog(@"RELAH: base64 result %@", result);
return result;
}
- (id)encryptToString:(id)arg1 {
NSLog(@"RELAH: encryptToString called %@", arg1);
// NSLog(@"%@",[NSThread callStackSymbols]);
return %orig;
}
- (id)encryptWithString:(id)arg1 {
NSLog(@"RELAH: encryptWithString called %@", arg1);
//NSLog(@"RELAH: %@",[NSThread callStackSymbols]);
id result = %orig;
NSLog(@"RELAH: encryptWithString result %@", result);
return result;
}
- (id)encryptWithData:(id)arg1 {
NSLog(@"RELAH: encryptWithData called %@", arg1);
NSLog(@"%@",[NSThread callStackSymbols]);
id result = %orig;
NSLog(@"RELAH: encryptWithData result %@", result);
return %orig;
}
- (id)initWithPublicKey:(id)arg1 {
NSLog(@"RELAH: initWithPublicKey called %@", arg1);
// NSLog(@"%@",[NSThread callStackSymbols]);
return %orig;
}
- (id)initWithData:(id)arg1 {
NSLog(@"initWithData called %@", arg1);
NSData* data = (NSData*) arg1;
NSLog(@"initWithData base64 %@", [data base64EncodedStringWithOptions:0]);
NSLog(@"%@",[NSThread callStackSymbols]);
return %orig;
}
// Always make sure you clean up after yourself; Not doing so could have grave consequences!
%end
%hook swiftPayLahScanQRCodeController
- (void)donePressed {
NSLog(@"RELAH: DONE PRESSED");
%orig;
}
- (void)updateCounterWithString:(id)arg1 {
NSLog(@"RELAH: UPDATE COUNTER PRESSED %@", arg1);
%orig;
}
-(id)setQrCode:(id)qrCode key:(id)arg2 {
NSLog(@"setQR Code %@ : %@", qrCode, arg2);
return %orig;
}
-(id)setNetsQRCode:(id)qrCode key:(id)arg2 {
NSLog(@"setNetsQR Code %@ : %@", qrCode, arg2);
return %orig;
}
-(id)setQrCodeScanner:(id)qrCode key:(id)arg2 {
NSLog(@"setQrCodeScanner %@ : %@", qrCode, arg2);
return %orig;
}
-(id)setQrCodeImagePicker:(id)qrCode key:(id)arg2 {
NSLog(@"setQrCodeImagePicker %@ : %@", qrCode, arg2);
return %orig;
}
/*
@interface PayLah.PayLahQRCodeImagePicker (PayLah) <UIImagePickerControllerDelegate>
- (void)invalidQRCodePicked;
- (void)validQRCodePickedWithParsedQRCode:(id)arg1;
- (void)imagePickerController:(id)arg1 didFinishPickingMediaWithInfo:(id)arg2;
*/
%hook swiftPayLahQRCodeImagePicker
- (void)imagePickerController:(id)arg1 didFinishPickingMediaWithInfo:(id)arg2 {
NSLog(@"RELAH: FINISH PICKING IMAGE");
%orig;
}
%end
%ctor {
%init(swiftPayLahQRCodeImagePicker = objc_getClass("PayLah.PayLahQRCodeImagePicker"));
// %init();
}