iOS逆向系列-theos

概述

theos是GitHub开源的一个项目,通过nic.pl创建tweak项目。通过编写我们注入代码,然后执行编译、打包、安装等操作将代码注入iPhone安装的制定程序。

theos环境配置

安装签名工具ldid

  • 确保安装了brew

    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • 利用brew安装ldid

    $ brew install ldid

下载theos

$ git clone --recursive https://github.com/theos/theos.git

由于theos依赖于其它的库所以我们使用recursive递归方式去clone自动下载锁依赖的库。我这里下载了~/目录下。

配置环境变量

为了是theos/bin目录下的命令全局有效,配置环境变量。

theos

theos创建工程

  • cd到一个存放项目代码的文件夹(比如桌面)

    $ cd ~/Desktop
    $ nic.pl
  • 选择【11.】iphone/tweak

  • 填写项目信息
    • 项目名称
    • 项目ID(随便写)
    • Author/Maintainer Name
      • 作者
      • 直接敲回车按照默认的做法就行(默认是Mac上的用户名)
    • [iphone/tweak]MobileSubstrate Bundle filter
      • 需要修改的App的Bundle Identifier(需要hook程序的Bundle Id)
      • 可以通过Cycript查看App的Bundle Identifier
  • [iPhone/tweak] List of applications to terminate upon installation
    • 直接敲回车按照默认做法就行

编写Makefile

  • 在前面加入环境变量,写清楚通过那个IP和端口访问手机

编写代码

  • 打开Tweak.xm文件

编译-打包-安装

  • 编译

    make
  • 打包成deb

    make package
  • 安装 (默认会重启SpringBoard)

    make install

遇到问题解决

make package的错误

$ make package
Can't locate IO/Compress/Lzma.pm in @INC (you may need to install the
IO::Compress::Lzma module) (@INC contains: /Library/Perl/5.18/darwin-
thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-
thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.2
/System/Library/Perl/5.18/darwin-thread-multi-2level
/System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-
multi-2level /System/Library/Perl/Extras/5.18 .) at
/Users/mj/theos/bin/dm.pl line 12.
BEGIN failed--compilation aborted at /Users/mj/theos/bin/dm.pl line 12.
make: *** [internal-package] Error 2

是因为打包压缩方式有问题,改成gzip压缩就行。修改dm.pl文件,用#注释掉下面两句

$ vim $THEOS/vendor/dm.pl/dm.pl
#use IO::Compress::Lzma;
#use IO::Compress::Xz;

修改deb.mk文件第6行的压缩方式为gzip

$ vim $THEOS/makefiles/package/deb.mk
_THEOS_PLATFORM_DPKG_DEB_COMPRESSION ?= gzip

make的错误

错误一

$ make
Error: You do not have an SDK in
/Library/Developer/CommandLineTools/Platforms/iPhoneOS.platform/Developer/S
DKs

是因为安装多个Xcode导致路径问题,需要指定一下Xcode

 $ sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

错误二

> Making all for tweak xxx...
make[2]: Nothing to be done for `internal-library-compile'.

是因为之前已经编译过,有缓存导致的,clean一下即可

$ make clean
$make

猜你喜欢

转载自www.cnblogs.com/CoderHong/p/8954143.html