美文网首页
iOS 逆向随笔 - theos

iOS 逆向随笔 - theos

作者: 0x1Fu | 来源:发表于2018-11-27 23:02 被阅读0次

theos是iOS最方便的越狱开发工具包,可以用来构建命令行程序。

下载和安装theos

$ git clone https://github.com/theos/theos.git
$ export THEOS=$PWD/theos
$ $THEOS/bin/update-theos

下载 jtool 签名工具

jtool

Helloworld

最简单的Helloworld Command Line 程序需要一个Makefile、main.c和一个entitlement文件,

Demo代码可以在github获取,

$ git clone https://github.com/0x1Fu/ios_essays.git

Makefile - 不需要太多解释,

ARCHS = arm64
TARGET = iphone:clang::10.0

include $(THEOS)/makefiles/common.mk

TOOL_NAME = helloworld

helloworld_FILES = main.c
helloworld_CFLAGS =
helloworld_LDFLAGS =

main.c - 用了一辈子的helloworld,

#include <stdio.h>

int main(int argc, char *argv[]) {
    printf("hello world!\n");
    return 0;
}

ent.plist - 签名用entitlement文件,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>platform-application</key>
    <true/>
</dict>
</plist>

编译和运行

# 设置越狱设备IP地址
export ip=192.168.3.10

# Build
$ cd ios_essays/helloworld/
$ make debug=no
$ cp .theos/obj/arm64/helloworld .
$ jtool -arch arm64 --sign --ent ent.plist helloworld --inplace

# Deploy,使用 scp 拷贝到手机,也可以通过其它方式
$ ssh -t -p 2222 root@$ip 'rm -f /bootstrap/helloworld'
$ scp -P 2222 helloworld root@$ip:/bootstrap

# Run
$ ssh -t -p 2222 root@$ip '/bootstrap/helloworld'
hello world!

相关文章

网友评论

      本文标题:iOS 逆向随笔 - theos

      本文链接:https://www.haomeiwen.com/subject/lzfoqqtx.html