实施PT_DENY_ATTACH反盗版代码 [英] Implementing the PT_DENY_ATTACH anti-piracy code
问题描述
我已经尝试从这个wiki实现以下反盗版代码:
http://theiphonewiki.com/wiki/index.php?title=Bugging_Debuggers
I've been tryign to implement the following anti piracy code from this wiki: http://theiphonewiki.com/wiki/index.php?title=Bugging_Debuggers
但是尽管遵循了这封信我的应用程序退出了
But despite following it to the letter my app exits with a
Program exited with status value:45.
当我测试它时。如果我注释掉函数调用disable_gdb();该应用程序正常运行。
When i test it. If i comment out the function call disable_gdb(); the app runs as normal.
我做错了什么。或者是代码正在按原样执行..并在附加xcode时退出?
What is it that I'm doing wrong. Or is it that the code is doing as it should.. and exits while xcode is attached?
#import <UIKit/UIKit.h>
#import <dlfcn.h>
#import <sys/types.h>
typedef int (*ptrace_ptr_t)(int _request, pid_t _pid, caddr_t _addr, int _data);
#if !defined(PT_DENY_ATTACH)
#define PT_DENY_ATTACH 31
#endif // !defined(PT_DENY_ATTACH)
int main(int argc, char *argv[])
{
NSLog(@"Main Called ");
disable_gdb();
NSLog(@"After cracker code");
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
}
void disable_gdb()
{
void* handle = dlopen(0, RTLD_GLOBAL | RTLD_NOW);
ptrace_ptr_t ptrace_ptr = dlsym(handle, "ptrace");
ptrace_ptr(PT_DENY_ATTACH, 0, 0, 0);
dlclose(handle);
}
int main3(int argc, char *argv[])
{
return -1;
}
Kindest Regards,
-Code
Kindest Regards, -Code
推荐答案
代码按预期运行。那就是说,我应该告诉你,你在浪费时间。这种方法只有在 gdb
且攻击者/程序员合作时才有效。像 gdb
这样的工具的全部意义在于它们非常多才多艺,如果这样一个简单的bug阻止它们死在他们的轨道上,那么某人会很快解决它。 :)
The code is functioning as intended. That said, I should tell you that you're wasting your time. This approach will only work if gdb
and the attacker/programmer are cooperative. The whole point of tools like gdb
is that they are extremely versatile and if a simple "bug" like this stopped them dead in their tracks, someone would fix it very quickly. :)
如这个页面,你可以在 gdb
中执行以下操作:
As described on this page, you can just do the following from within gdb
:
(gdb) break ptrace
commands 1
return
continue
end
这篇关于实施PT_DENY_ATTACH反盗版代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!