iOS 越狱检测屏蔽插件 Shadow

 原创    2024-04-18

Shadow 是一款强大的 iOS 越狱检测屏蔽插件,与 kernbypass 主要模拟非越狱状态文件系统不同,Shadow 胜在提供了更精细更自由的 API Hook 能力。

上一篇文章我介绍了 iOS 内核级越狱检测屏蔽方案:KernBypass,在本文中看川将继续介绍另一种 iOS 越狱检测屏蔽插件 Shadow。

Shadow 插件由开发者 jjolano 开发,目前项目开源在 github上:

https://github.com/jjolano/shadow

在越狱 iPhone 上安装 Shadow

项目 README 中有详细说明:

Add https://ios.jjolano.me to your package manager and install the Shadow (me.jjolano.shadow) package. Alternatively, download the latest release directly from GitHub and open the file with your package manager.

You may need additional repositories for dependencies - these are the current dependencies:

  • libSandy from opa334's Repo (preferences - sandboxed loading)
  • AltList from opa334‘s Repo (preferences - application listing)
  • HookKit Framework (hooking + change hooking library feature)
  • RootBridge Framework (rootless compatibility/universal binary building)

A recommended (but not required) package is Injection Foundation from PoomSmart's Repo (https://poomsmart.github.io/repo). This package ensures that Shadow is injected properly into certain apps.

Shadow 拥有强大的 Hook 能力

一般的越狱检测思路,无非就是检查特定文件目录路径是否存在:

  • /Applications/Cydia.app
  • /Library/MobileSubstrate
  • ...

检查 stat、access、dladdr 等基础 API 是否在合法的动态库中,判断是否有 DYLD_INSERT_LIBRARIES 特征环境变量等。

但这些手段,都扛不住 Hook。

可以在 Shadow 的设置页面针对指定 App 启用不同特性的 Hook,特性全部开启,屏蔽效果更佳。

jailbreak Shadow

Shadow 内置了对众多关键系统 API 的 Hook,看川粗略分析,Hook 的系统方法包括但不限于:

  • _dyld_image_count
  • _dyld_get_image_name
  • _dyld_get_image_header
  • _dyld_register_func_for_add_image
  • _dyld_register_func_for_remove_image
  • dladdr
  • dlsym
  • dlopen
  • access
  • open
  • stat
  • sysctl
  • task_info
  • syscall
  • chroot
  • ptrace
  • objc_getClass
  • class_getImageName
  • objc_copyClassNamesForImage
  • objc_copyImageNames
  • NSFileManager
  • NSProcessInfo
  • NSBundle

更强悍的是,jjolano 还贴心地为我们提供了 HookKit 套件,基于 HookKit,可以在 Shadow 中自由切换不同的 Hook 组件,包括 fishhook、libhooker、Substitute等,涵盖了 inline hook、fishhook 以及 Objetive-C Runtime Hook 方式。

HookKit

以使用 Substitute 为例,当调用 _dyld_image_count 时,在 iOS 12 上测试的正常调用指令如下:

0x200521080 <+0>:  adrp   x8, 227542
0x200521084 <+4>:  add    x8, x8, #0xf08            ; gUseDyld3
0x200521088 <+8>:  ldrb   w8, [x8]
0x20052108c <+12>: cbz    w8, 0x200521094           ; <+20>
0x200521090 <+16>: b      0x20052b2f8               ; dyld3::_dyld_image_count()

但启用 Shadow 后变成了:

0x200521080 <+0>:  adrp   x17, -1047280
0x200521084 <+4>:  add    x17, x17, #0x870          ; ___lldb_unnamed_symbol234
0x200521088 <+8>:  br     x17
0x20052108c <+12>: cbz    w8, 0x200521094           ; <+20>
0x200521090 <+16>: b      0x20052b2f8               ; dyld3::_dyld_image_count()

br x17 指令即跳转到 Shadow 的实现中,包括 access、stat 等,都是一样的处理逻辑,Shadow 在其内部维护了一个特征字符串列表,比如 /Library/MobileSubstrate、substitute 等,对符合特征的文件路径绕过处理,从而导致常规检测返回错误结果。

这篇文章:iOS有反检测能力的越狱工具shadow的分析和检测 有对 Shadow 的详细分析,可以作为参考。

相关文章:

iOS 内核级越狱检测屏蔽方案:KernBypass
iOS启动优化之二进制重排
Address Sanitizer 的原理和使用
iOS 13越狱工具Checkra1n
iOS安全:iOS APP注入动态库重打包(非越狱)

发表留言

您的电子邮箱地址不会被公开,必填项已用*标注。发布的留言可能不会立即公开展示,请耐心等待审核通过。