关于安全:IOS-Theos-Tweak-之-HelloWorld

一、指标

Theos是什么?

是一套跨平台的开发工具套件,不仅能够开发Ios,Mac、Windows和Linux也能够的哦,开源收费。

Tweak是什么?

能够了解成动态链接库,有搞过Windows下dll注入的同学应该能够秒懂了。Android的同学能够把它了解成IOS下的Xposed。

HelloWorld是什么?

是萌新程序员的信奉,在一个平台写下HelloWorld,证实我来了。

二、步骤

Mac下装置Theos

1、检测是否有 /opt目录,没有就新建一个

# 先切换到root权限
sudo su
cd /
mkdir opt
cd /opt

2、 在新建的/opt目录下clone我的项目源码

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

3、关上 ~/.bash_profile文件,增加以下四行

# theos
export THEOS=/opt/theos
export PATH=$THEOS/bin:$PATH
# iPhone手机的ssh地址
export THEOS_DEVICE_IP=localhost
export THEOS_DEVICE_PORT=2222

4、依照 之前的文章 Ios逆向环境搭建 (一) 配置好 SSH。

是的就这样就够了。 (可能还须要 ldid 和 dpkg-deb,用brew装下)

HelloWorld

开始创立一个 Tweak模板

# 创立模板命令 nic.pl 相似新建一个空工程
nic.pl
------------------------------
  [1.] iphone/activator_event
  [2.] iphone/application_modern
  [3.] iphone/cydget
  [4.] iphone/flipswitch_switch
  [5.] iphone/framework
  [6.] iphone/ios7_notification_center_widget
  [7.] iphone/library
  [8.] iphone/notification_center_widget
  [9.] iphone/preference_bundle_modern
  [10.] iphone/tool
  [11.] iphone/tweak
  [12.] iphone/xpc_service
# 抉择 11 iphone/tweak ,我之前装的是 11, 最新的是 15
Choose a Template (required): 11
# 输出工程名称
Project Name (required): helloworld
# 输出工程包名
Package Name [com.yourcompany.helloworld]: com.fefei.helloworld
# 作者必须是我了
Author/Maintainer Name [fenfei]: fenfei
# 要hook的程序包名,咱们这里正好要hook springboard
[iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]:
# 开发实现之后,装置好了咱们的tweak,要重启的app名称,个别都是咱们要hook的app的主程序名称,这里是 SpringBoard
[iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: 
Instantiating iphone/tweak in helloworld/...
Done.

这就搞定了

一共生成了4个文件

  • Makefile 编译的脚本
  • Tweak.xm 源代码
  • control 工程形容
  • helloworld.plist 要hook的App列表

急不可待了,咱们先写代码吧

#import <SpringBoard/SpringBoard.h>

// hook 了 SpringBoard类的 applicationDidFinishLaunching 办法,
// 具体景象就是 进入ios零碎桌面之前弹出提示框
%hook SpringBoard

-(void)applicationDidFinishLaunching:(id)application {
    %orig;

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome"
        message:@"456 Hello world,你好世界"
        delegate:nil
        cancelButtonTitle:@"确定"
        otherButtonTitles:nil];
    [alert show];
    [alert release];
}

%end

// 初始化执行
%ctor{
    NSLog(@"fenfei: 666 ctor!!!");
    %init(_ungrouped);
}    

编译和装置

make package install

装置后会主动重启SpringBoard,而后就会弹出咱们的HelloWorld

咱们再说说这个 NSLog ,这个很有用的,相似Android的 __android_log_print。 然而它从哪看呢?

Mac零碎有个叫 控制台 的程序,能够看到每个设施输入的Log。

木问题,出工。

三、总结

玩Ios难点在哪? 不在于Arm汇编,而在于没有设施。你起码得须要一个Mac电脑和Iphone。

不倡议装黑苹果,降级和鼓捣太麻烦了。 某鱼搞个二手Mac Pro最低有2k的, Iphone搞个6或者6s, 有3-400的。 Mac电脑系统起码要能装 macOS Mojave 10.14.x 。 Iphone要无锁的,最好国行,零碎就所谓了,最好低点 13以下。这样 Xcode 11.3也能玩。

醉后不知天在水,满船清梦压星河

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理