阻止Reveal查看自己App的UI结构

Reveal已经算是逆向工程中常用的软件了(虽然它的本意不是用来逆向查看其他App的UI),为了保护自己的App不被其他人用Reveal来查看UI结构,我给出了一个简单的解决方案,当然,要是有人真的想逆向掉你的App,这也只是时间问题而已。

代码如下,应该还算写的比较清晰吧

#import <objc/runtime.h>
static void callback(CFRunLoopTimerRef timer, void *info){
    Class IBARevealLoader = NSClassFromString(@"IBARevealLoader");
    if (IBARevealLoader) {
        CFNotificationCenterPostNotification( CFNotificationCenterGetLocalCenter(), CFSTR("IBARevealRequestStop"), NULL, NULL, kCFNotificationDeliverImmediately);
        // 先停掉Reveal的服务

    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
            method_exchangeImplementations( class_getClassMethod ( NSClassFromString ( @"IBARevealLoader" ), NSSelectorFromString(@"requestStart:")), class_getClassMethod(NSClassFromString(@"ViewController"), @selector(requestStart:)));
            // 我们用method swizzed来干掉Reveal
            NSLog(@"Goodbye Reveal!");
            // 再见了, Reveal!
            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
                CFNotificationCenterPostNotification( CFNotificationCenterGetLocalCenter(), CFSTR( "IBARevealRequestStart" ), NULL, NULL, kCFNotificationDeliverImmediately );
            });
            // 我们在3秒之后试一下开启Reveal的服务
            // 应该会看到 + [ViewController startServer:] 输出的 "I don't wanna Reveal!"
        });
    }
}

@implementation ViewController

+ (void)requestStart:(id)object
{
    NSLog(@"I don't wanna Reveal!");
}

- (void)viewDidLoad
{
    [superviewDidLoad];
    CFRunLoopRef runloop = CFRunLoopGetCurrent();
    CFRunLoopAddTimer(runloop, CFRunLoopTimerCreate(NULL, 0, 1.0, 0, 0, callback, NULL), kCFRunLoopDefaultMode);
    // 每隔1s检查一次Reveal是否存在
}

@end

2 thoughts on “阻止Reveal查看自己App的UI结构”

  1. Class (*orig_func) (NSString* arg);
    Class *repl_func (NSString* arg);{
    if([arg compare:@"IBARevealLoader"] == NSOrderedSame)
    return nil;
    return orig_func(arg);
    MSHookFunction(XXXXX);//懒得写了

    如果reveal内部没有动态的话应该可以吧。。博主测试下

    另收到了10.10.3的Public Beta,博主收到了吗

    1. 嘛,本来就是打算阻止一部分只会看教程,然后就想用Reveal干坏事的人。cycript之后递归输出window的description可以基本达到同样的效果,只不过是纯文字而已。

Leave a Reply

Your email address will not be published. Required fields are marked *

15 − one =