theos 是ios在越獄環境下,開發的工程管理工具 https://github.com/DHowett/theosios
下面分享下環境搭建過程:git
給xcode安裝 command line toolsgithub
從10.8開始xcode的command line tools就要本身安裝了,若是沒安裝的話,會出現各類問題,好比gcc沒有安裝,等等各類詭異的問題。新手非常懼怕。spring
https://developer.apple.com/downloads/?=Command%20Line%20Tools%20 xcode
安裝 macports app
macports是用於安裝dpkg的快速安裝工具,還能夠安裝其餘不少工具koa
設置配置iphone
export THEOS=/opt/theos
4.下載theos函數
sudo git clone https://github.com/moloch--/theos.git $THEOS
5.安裝dpkg
sudo port install dpkg
6. 下載 https://github.com/kokoabim/iOSOpenDev
7.下載的iOSOpenDev/lib 拷貝到 /opt/theos/lib
8.下載的iOSOpenDev/include 拷貝到 /opt/theos/include
9.下載的iOSOpenDev/bin 拷貝到 /opt/theos/bin
環境基本完成,若是須要hook一些特殊的頭文件,本身可使用class_dump_z解析出來放到header裏面,也能夠在google中找
---------------------------------------------------凌亂的分割線------------------------------------------
1.建立工程
$THEOS/bin/nic.pl NIC 1.0 - New Instance Creator —————————— [1.] iphone/application [2.] iphone/library [3.] iphone/preference_bundle [4.] iphone/tool [5.] iphone/tweak Choose a Template (required): 5
選擇com.apple.springboard開發桌面插件
2.建立成功後,在工程目錄下,修改MakeFile 修改頭部第一行
export ARCHS = armv7 export TARGET=iphone:latest:5.1 include $(THEOS)/makefiles/common.mk
3.編寫TWeak.xm文件代碼
%hook SBScreenShotter - (void)saveScreenshot:(BOOL)screenshot { %orig; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome" message:@"Welcome to your iPhone love" delegate:nil cancelButtonTitle:@"okokok" otherButtonTitles:nil]; [alert show]; [alert release]; } %end
%hook後面跟的是你要hook的類名稱,以一個%end結尾。上面的代碼說明咱們會hook Springboard類裏面的method。 %orig 當在一個method內部的時候,%orig會調用原來的方法(original method)。你甚至能夠給原來的method傳遞參數,例如:%orig(arg1,arg2)。若是你不調用%orig,原來的方法就絕對不會被調用。因此,若是你hook了SpringBoard的init方法,可是沒有調用%orig。那麼你的iphone就將不可用,除非你經過ssh刪除你的app。
上面代碼的做用就是在桌面截屏的時候彈出一個對話框!,固然,若是你不知道的想要hook的函數是什麼的話,請使用各類分析工具得到!,能夠看上面幾篇文章
4.增長frameWork
那是由於咱們依靠UIKit framework來顯示alert,因此須要在Makefile中加上以下一行: WelcomeWagon_FRAMEWORKS = UIKit
5.打包
cd到工程目錄下,make,make成功後,使用
設置配置安裝
export THEOS_DEVICE_IP=10.242.125.7 (這是手機的IP)
make package install