|
1adc8c69
»
|
costan |
2009-05-13 |
Set literals in JSON parsin... |
1 |
// |
| |
2 |
// ZNDebugIntegrity.h |
| |
3 |
// ZergSupport |
| |
4 |
// |
| |
5 |
// Created by Victor Costan on 5/12/09. |
|
4c1f4638
»
|
costan |
2009-05-24 |
Updates for StockPlay 0.5. |
6 |
// Copyright Zergling.Net. Licensed under the MIT license. |
|
1adc8c69
»
|
costan |
2009-05-13 |
Set literals in JSON parsin... |
7 |
// |
| |
8 |
|
| |
9 |
#import <dlfcn.h> |
| |
10 |
#import <sys/types.h> |
| |
11 |
|
| |
12 |
#import <Foundation/Foundation.h> |
| |
13 |
#import <TargetConditionals.h> |
| |
14 |
|
| |
15 |
|
| |
16 |
// The iPhone SDK doesn't have <sys/ptrace.h>, but it does have ptrace, and it |
| |
17 |
// works just fine. |
| |
18 |
typedef int (*ptrace_ptr_t)(int _request, pid_t _pid, caddr_t _addr, int _data); |
| |
19 |
#if !defined(PT_DENY_ATTACH) |
|
4c1f4638
»
|
costan |
2009-05-24 |
Updates for StockPlay 0.5. |
20 |
#define PT_DENY_ATTACH 31 |
|
1adc8c69
»
|
costan |
2009-05-13 |
Set literals in JSON parsin... |
21 |
#endif // !defined(PT_DENY_ATTACH) |
| |
22 |
|
| |
23 |
|
| |
24 |
void ZNDebugIntegrity() { |
|
4c1f4638
»
|
costan |
2009-05-24 |
Updates for StockPlay 0.5. |
25 |
// If all assertions are enabled, we're in a legitimate debug build. |
|
1adc8c69
»
|
costan |
2009-05-13 |
Set literals in JSON parsin... |
26 |
#if TARGET_IPHONE_SIMULATOR || defined(DEBUG) || (!defined(NS_BLOCK_ASSERTIONS) && !defined(NDEBUG)) |
| |
27 |
return; |
| |
28 |
#endif |
|
4c1f4638
»
|
costan |
2009-05-24 |
Updates for StockPlay 0.5. |
29 |
|
|
1adc8c69
»
|
costan |
2009-05-13 |
Set literals in JSON parsin... |
30 |
// Lame obfuscation of the string "ptrace". |
| |
31 |
char* ptrace_root = "socket"; |
| |
32 |
char ptrace_name[] = {0xfd, 0x05, 0x0f, 0xf6, 0xfe, 0xf1, 0x00}; |
| |
33 |
for (size_t i = 0; i < sizeof(ptrace_name); i++) { |
| |
34 |
ptrace_name[i] += ptrace_root[i]; |
| |
35 |
} |
|
4c1f4638
»
|
costan |
2009-05-24 |
Updates for StockPlay 0.5. |
36 |
|
|
1adc8c69
»
|
costan |
2009-05-13 |
Set literals in JSON parsin... |
37 |
void* handle = dlopen(0, RTLD_GLOBAL | RTLD_NOW); |
| |
38 |
ptrace_ptr_t ptrace_ptr = dlsym(handle, ptrace_name); |
| |
39 |
ptrace_ptr(PT_DENY_ATTACH, 0, 0, 0); |
| |
40 |
dlclose(handle); |
| |
41 |
} |