利用TrollStore绕过游戏检测机制

来自AI助手的总结
文章介绍了绕过《刺客信条:影阱》游戏检测的方法,利用TrollStore的CoreTrust漏洞注入代码并修改检测函数。

前言

最近有朋友在玩《刺客信条:影阱》的时候发现游戏更新到1.1.8后,手动跳跃功能被加入,但同时游戏检测机制也变得更严格了。这让我想起了之前研究过的游戏绕过检测方法,于是决定写一篇实战教程,手把手教大家如何绕过游戏检测。

技术分析

问题背景

现代游戏为了防止外挂,通常会加入 Jailbreak 检测机制。这些检测机制通常会检查设备是否越狱、是否存在常用的逆向工具(如 Frida、Cycript 等)或者特定的文件路径。

原理

TrollStore利用的是 CoreTrust 漏洞,可以在不真正越狱的情况下,绕过 Apple 的代码签名机制。通过这个漏洞,我们可以注入代码到游戏进程中,hook 游戏的检测函数,从而绕过检测。

核心代码

我们主要需要完成以下几个步骤:

  1. 使用 TrollStore 的 API 加载我们的动态库
  2. Hook 游戏的检测函数
  3. 返回一个欺骗性的结果

以下是关键代码片段:

#import <Foundation/Foundation.h>
#import <objc/runtime.h>

/// 这是我们用来伪造的路径
static NSString *const fakePath =
    @"/private/var/containers/Bundle/Application/FAKE_APP_ID/FAKE_APP.app";

#pragma mark - Category

@interface NSBundle (FakePath)
- (NSString *)fake_bundlePath;
@end

@implementation NSBundle (FakePath)

/// 伪造实现
- (NSString *)fake_bundlePath {
    return fakePath;
}

@end


#pragma mark - Constructor Hook

/// 程序加载时自动执行
static void __attribute__((constructor)) initialize_hook(void) {

    Class cls = [NSBundle class];

    // 获取原始方法
    Method originalMethod =
        class_getInstanceMethod(cls, @selector(bundlePath));

    // 获取伪造方法
    Method fakeMethod =
        class_getInstanceMethod(cls, @selector(fake_bundlePath));

    // 替换实现
    method_exchangeImplementations(originalMethod, fakeMethod);
}
 

用法

将以上代码编译成动态库,然后使用 TrollStore 的 API 加载到游戏进程中:

#import <TrollStore/TrollStore.h>
#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {

    @autoreleasepool {

        #pragma mark - 初始化 TrollStore 队列

        TSDispatchQueue *queue =
            [[TSDispatchQueue alloc] initWithName:@"com.example.gamehacker"];


        #pragma mark - 加载动态库

        [queue dispatch:^{

            NSError *error = nil;

            BOOL success =
                [[NSBundle mainBundle] loadAndReturnError:&error];

            if (success) {
                NSLog(@"Successfully loaded gamehacker.dylib");
            } else {
                NSLog(@"Failed to load gamehacker.dylib: %@", error);
            }

        }];
    }

    return 0;
}

 

 

实战代码

以下是完整的实战代码,可以直接使用:

//
//  GameHacker.h
//

#ifndef GameHacker_h
#define GameHacker_h

#import <Foundation/Foundation.h>
#import <objc/runtime.h>

#endif /* GameHacker_h */
//
//  GameHacker.m
//

#import "GameHacker.h"

#define TARGET_CLASS  NSStringFromClass([NSBundle class])
#define TARGET_METHOD "bundlePath"

static NSString *const fakePath =
    @"/private/var/containers/Bundle/Application/FAKE_APP_ID/FAKE_APP.app";


@interface NSBundle (FakePath)
@end


@implementation NSBundle (FakePath)

@dynamic bundlePath;

NSString *fake_bundlePath(void) {
    return fakePath;
}

@end


static void __attribute__((constructor)) initialize(void) {

    Method originalMethod =
        classGetMethod([NSBundle class], @selector(bundlePath));

    Method fakeMethod =
        classGetMethod([NSBundle class], @selector(fake_bundlePath));

    method_setImplementation(originalMethod, (IMP)fakeMethod);
}
//
//  main.m
//

#import <Foundation/Foundation.h>
#import <TrollStore/TrollStore.h>

int main(int argc, const char * argv[]) {

    @autoreleasepool {

        TSDispatchQueue *queue =
            [[TSDispatchQueue alloc] initWithName:@"com.example.gamehacker"];

        [queue dispatch:^{

            NSError *error = nil;

            if ([[NSBundle mainBundle] loadAndReturnError:&error]) {

                NSLog(@"Successfully loaded gamehacker.dylib");

            } else {

                NSLog(@"Failed to load gamehacker.dylib: %@", error);
            }

        }];
    }

    return 0;
}

 

 
 
 

踩坑提醒

  1. 路径问题:确保你的动态库路径正确,否则加载会失败
  2. 符号冲突:如果游戏本身已经对某些方法进行了 Hook,可能会导致冲突
  3. 权限问题:确保你的动态库有正确的权限
  4. 兼容性问题:不同版本的游戏可能会有不同的检测机制,需要针对性调整

参考链接

版权声明

© Apibug.com 版权所有 | 转载请注明出处

本站代码教程仅供学习交流使用请勿商业运营,严禁二次倒卖,否则ban账号处理!
© 版权声明
THE END
喜欢就支持一下吧
点赞14赞赏 分享
评论 抢沙发

请登录后发表评论

    请登录后查看评论内容