学习逆向工程的好地方是什么,特别适用于Mac OS X?关于这个主题,我钦佩两个应用程序:
超空间 - http://thecocoabots.com/hyperspaces/
和
轨道 - http://www.steventroughtonsmith.com/orbit/
谢谢你们。
答案 0 :(得分:17)
你应该抓一本Mac OS X Internals的副本,这是一本关于Apple没有告诉你的所有内容的精彩书。如果您对逆向工程感兴趣,它不仅会让您成为更好的OS X程序员。
答案 1 :(得分:4)
Apple发布了大量OS X作为开源的基础。 See here
此外,F-Script Anywhere将有助于解剖Finder和/或任何其他封闭源应用程序。
答案 2 :(得分:4)
使用class-dump-x / -z获取OS X / iPhone OS系统框架的私有Objective-C标头。公众隐藏了很多类/方法(有些是正确的)
答案 3 :(得分:3)
对于iPhoneOS,class-dump-z是转储标头的好方法。当然,唯一的问题是你实际上无法看到每个方法内部发生了什么。 IDA Pro和一些脚本可以查看这些系统框架的汇编指令。 (示例图片:http://grab.by/1Vn6)。
最方便的IDC脚本是fixobjc2和dyldinfo。您可以在此博客文章中找到每个链接:http://networkpx.blogspot.com/2010/01/two-ida-pro-5x-scripts-for-iphoneos.html
但是,如果您不能使用它,这些信息有什么用呢? iPhone开发人员saurik编写了一个名为MobileSubstrate的东西,可以挂钩到任何方法。 http://svn.saurik.com/repos/menes/trunk/mobilesubstrate/
答案 4 :(得分:1)
其他人已经提到过class-dump,它是从编译的可执行文件中检索类定义的优秀工具。在相关的说明中,您还应该看看otx,它提供了非常好的(可读的)反汇编输出。
如果您需要一种快速测试代码片段的方法,请使用F-Script(其他人提及),Nu或MacRuby。其中,我主要使用Nu。它能够动态定义桥接函数,并且可以处理指针,如果你需要调用任意C函数,这两个指针都非常方便。
由于您提到了Spaces和其他屏幕管理员的兴趣,您还应该阅读A brief tutorial on reverse engineering OS X。这是Rich Wareham(前Spaces多桌面应用程序的作者:'桌面管理器')的一篇旧文章,讲述了他如何找出少数私有CoreGraphics方法的调用语法,以便进行漂亮的桌面转换。 source code for Desktop Manager也可用,这可能对您有用。
答案 5 :(得分:1)
此站点显示了如何修补现有的Objective C程序:http://www.culater.net/wiki/moin.cgi/CocoaReverseEngineering
正在冒充:
[[B class] poseAsClass:[A class]];
和方法混合:
/**
* Renames the selector for a given method.
* Searches for a method with _oldSelector and reassigned _newSelector to that
* implementation.
* @return NO on an error and the methods were not swizzled
*/
BOOL DTRenameSelector(Class _class, SEL _oldSelector, SEL _newSelector)
{
Method method = nil;
// First, look for the methods
method = class_getInstanceMethod(_class, _oldSelector);
if (method == nil)
return NO;
method->method_name = _newSelector;
return YES;
}
// *** Example ***
// never implemented, just here to silence a compiler warning
@interface WebInternalImage (PHWebInternalImageSwizzle)
- (void) _webkit_scheduleFrame;
@end
@implementation WebInternalImage (PHWebInternalImage)
+ (void) initialize
{
DTRenameSelector([self class], @selector(scheduleFrame), @selector (_webkit_scheduleFrame));
DTRenameSelector([self class], @selector(_ph_scheduleFrame), @selector(scheduleFrame));
}
- (void) _ph_scheduleFrame
{
// do something crazy...
...
// call the "super" method - this method doesn't exist until runtime
[self _webkit_scheduleFrame];
}
@end
(从http://www.culater.net/wiki/moin.cgi/CocoaReverseEngineering复制的代码)
答案 6 :(得分:1)
作为对其他答案的补充,您将要查看DYLD_INSERT_LIBRARIES
以将您的代码注入Cocoa程序。
答案 7 :(得分:1)
您一定要考虑使用DTrace。在OS X上使用DTrace进行逆向工程有一个很好的BlackHat演示文稿,名为“DTRACE:逆向工程师的意外瑞士军刀”。
您可以获取副本并查看视频演示here。
在www.uninformed.org上也有一些关于逆向工程OS X的优秀论文。