THEOS的第一个TWeak的成功创建

THEOS的第一个TWeak的成功创建

THEOS的第一个TWeak的成功创建参考资料:成功的创建一个TWeak的弹出步骤1:安装Xcode和Xcode command line步骤2:安装theosa:下载theos前,设置保存的路径:环境变量b:下载theosc:下载头文件d:下载ldid签名工具e:配置MoblieSubstrate环境f:安装dpkg步骤3:开始编写Teak应用a 创建工程b.更改Tweak.xm文件c.编写makfiled: 编译,安装,运行步骤4: 证书设置(不用多次输入密码)总结一些坑

THEOS的第一个TWeak的成功创建

TWeak的成功创建也不是一件容易的事情.

参考资料:

  • http://www.iphonedevwiki.net/index.php/Theos/Getting_Started
  • http://security.ios-wiki.com/issue-3-6/
  • http://security.ios-wiki.com/
  • http://www.cppblog.com/AutomateProgram/archive/2013/11/11/204205.html
  • http://www.tuicool.com/articles/Bf2UFb
  • http://stackoverflow.com/questions/21013325/dpkg-error-contains-ununderstood-data-member

成功的创建一个TWeak的弹出

步骤1:安装Xcode和Xcode command line

Xcode的安装直接去Apple官网上去下载就好了.command line的话,现在的Xcode(2015-09-20,都是Xcode7了,Xcode6开始已经集成了command line到Xcode中了).

网上的教程有的是使用的Xcode4,5,等低版本.

这里埋下了一个坑.

步骤2:安装theos

a:下载theos前,设置保存的路径:环境变量

theos保存到哪里?这个路径是需要设置为环境变量的

可以直接写到~/.bash_profile中(设置环境变量的一般方法)

 
export THEOS=/usr/local/iOSTools/theos

网上很多的人都安装到了/opt/theos路径下,不过这个路径随意了,看你一般的开发工具放在哪里,就写那里就好了.

设置好后可以echo $theos来查看设置的环境变量是否设置好了.

 
zx:iOSTools zx$ echo $THEOS
/usr/local/iOSTools/theo

b:下载theos

下载的方法很多

  • svn的方法有:
 
svn co http://svn.howett.net/svn/theos/trunk $THEOS
  • gitt途径(推荐,方便升级)
 
git clone git://github.com/DHowett/theos.git $ THEOS

当然了,也可以直接去git仓库里下载一份压缩的,将里面的内容解压到$THEOS

c:下载头文件

头文件下载下来后需要做一些更改.

  • clone 头文件仓库
  • 将头文件放到theos/include/目录下
  • 复制系统的IOSurfaceAPI.h到**theos/include/IOSurface**目录下
  • 注释掉IOSurfaceCreateXPCObject 和IOSurfaceLookupFromXPCObject.
# clone iphoneheaders.git
git clone git://github.com/rpetrich/iphoneheaders.git 
mv iphoneheaders/*  theos/include/
cp /System/Library/Frameworks/IOSurface.framework/Headers/IOSurfaceAPI.h theos/include/IOSurface

如果没有拷贝和注释这两个步骤,最后会导致打包失败.

d:下载ldid签名工具

  • 下载ldid可执行文件
  • 放到theos/bin/目录下
 
# get ldid for Mac OS X
cd ~/theos/bin
curl -O http://dl.dropbox.com/u/3157793/ldid
chmod a+x ldid

这里的文件是在dropbox上,需要什么你的懂的.

所以,这里也提供一个百度盘上下载地址:

 
http://pan.baidu.com/s/1kTHoIGZ

注:我把这个工具下载下来放到了http://pan.baidu.com/s/1kTHoIGZ,也可以从这里下载,然后给它添加执行权限(chmod +x ldid)并移动到$THEOS/bin/这个目录下。(from http://security.ios-wiki.com/issue-3-6/)

PS.当然了,你可以直接从源码编译安装,下面是源码仓库

 
https://github.com/rpetrich/ldid

e:配置MoblieSubstrate环境

方法一:

# get libsubstrate.dylib substrate.h
cd ~/theos
curl -OL http://apt.saurik.com/debs/mobilesubstrate_0.9.3366-1_iphoneos-arm.deb
dpkg-deb -x mobilesubstrate_0.9.3366-1_iphoneos-arm.deb mobilesubstrate
cp mobilesubstrate/Library/Frameworks/CydiaSubstrate.framework/CydiaSubstrate  ~/theos/lib/libsubstrate.dylib
cp mobilesubstrate/Library/Frameworks/CydiaSubstrate.framework/Headers/CydiaSubstrate.h include/substrate.h

(from http://www.tuicool.com/articles/Bf2UFb)

方法二:

  • 从越狱后设备拷贝出来一份
  • 重名名为: theos/lib/libsustrate.dylib

将iOS上的“/Library/Frameworks/CydiaSubstrate.framework/ CydiaSubstrate”拷贝到OSX中,将其重命名为libsubstrate.dylib后放到“/opt/theos/lib/libsubstrate. dylib”中

(from http://book.51cto.com/art/201504/472934.htm)

方法三:

  • 百度盘里下载:http://pan.baidu.com/s/1o6ocwXk(from http://security.ios-wiki.com/issue-3-6/)

f:安装dpkg

方法一:

  • 通过mac port安装.

mac port也就是一个软件包管理工具,像weget,apt-install,brew等工具类似.

首先我尝试安装的是https://www.macports.org/install.php下的https://distfiles.macports.org/MacPorts/MacPorts-2.3.3-10.10-Yosemite.pkg

但是安装卡顿,失败.

然后,尝试源码编译安装,

MacPorts-2.3.3.tar.bz2

  1. “cd” into the directory where you downloaded the package and run “tar xjvf MacPorts-2.3.3.tar.bz2” or “tar xzvf MacPorts-2.3.3.tar.gz”, depending on whether you downloaded the bz2 tarball or the gz one, respectively.

  2. Build and install the recently unpacked sources:

    • cd MacPorts-2.3.3
    • ./configure && make && sudo make install

    Optionally:

    • cd ../
    • rm -rf MacPorts-2.3.3*

    (from https://www.macports.org/install.php)

但是

sudo port selfupdate
sudo port install dpkg

这里 时候,我的时候,根本不动了,毛网速没有啊....

方法二:

  • 通过brew来安装

brew的作者最近不是去了apple了吗?哈哈,以前配置号brew后,来下载就方便多了.

 
brew install dpkg

不到1分钟就可以下载好了. 真是给方法一给跪了.

步骤3:开始编写Teak应用

a 创建工程

选一个目录,存放工程.

 
zx:theosCode zx$ pwd
/Users/zx/documents/theosCode
zx:theosCode zx$ $THEOS/bin/nic.pl
NIC 2.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
Project Name (required): zxtest
Package Name [com.yourcompany.zxtest]: com.z2xy.zxtext(可选项,按enter,[]中的作为默认值)
Author/Maintainer Name [zx]: zx(按enter,[]中的作为默认值)
[iphone/tweak] MobileSubstrate Bundle filter [com.apple.springboard]: com.apple.springboard(按enter,[]中的作为默认值)
[iphone/tweak] List of applications to terminate upon installation (space-separated, '-' for none) [SpringBoard]: SpringBoard(按enter,[]中的作为默认值)
Instantiating iphone/tweak in zxtest/...
Done.

生成后的文件列表如下:

 
x
zx:zxtest zx$ pwd
/Users/zx/documents/theosCode/zxtest
zx:zxtest zx$ tree
.
├── Makefile
├── Tweak.xm
├── control
├── theos -> /usr/local/iOSTools/theos/
└── zxtest.plist
1 directory, 4 files

其中:

  • Makefiile文件用于自动化编译
  • Tweak.xm类似于我们 业务函数,main函数
  • control是一些工程信息
  • zxtest.plist也是项目的一些工程信息
  • 还有一个符号链接指向我们的$THEOS的安装目录(最开始配置的环境变量)

b.更改Tweak.xm文件

 
x
#import <SpringBoard/SpringBoard.h>
%hook SpringBoard
-(void)applicationDidFinishLaunching:(id)application {
%orig;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"__z2xy__" 
message:@"from zxdev" 
delegate:nil 
cancelButtonTitle:@"取消" otherButtonTitles:@"好的",nil];
[alert show];
[alert release];
}
%end

上面引入了一个头文件,然后替换了**applicationDidFinishLaunching方法的实现.

一些语法 %hook,%orig,%end,倒是很像django的模板语法.

这里不详细讲,见上的参考资料.

c.编写makfile

 
xxxxxxxxxx
ARCHS = armv7
THEOS_DEVICE_IP = 192.168.0.120 //(可选)
zxtest_FRAMEWORKS = UIKit
include theos/makefiles/common.mk
TWEAK_NAME = zxtest
zxtest_FILES = Tweak.xm
include $(THEOS_MAKE_PATH)/tweak.mk
after-install::
    install.exec "killall -9 SpringBoard"

主要是添加了头三行.

  • 第一行,指定了系统架构
  • 第二行,指定了同一局域网下的iOS设备的ip地址(需要根据自己的实际情况更换)

查看iOS设备的ip地址的话,直接到手机的设置,wifi,连接 wifi下查看就可以了.

如果需要自动安装的话,可以去掉这行

  • 第三行,导入UIKit头文件

如果不导入文件编译出错,找不到符号,因为我们使用了UIKit中的UIAlertView.

d: 编译,安装,运行

方法一:

需要指定iOS设备ip地址,需要设置好信任的证书.

 
zx:zxtest zx$ make package install
Making all for tweak zxtest...
make[2]: Nothing to be done for `internal-library-compile'.
Making stage for tweak zxtest...
dpkg-deb: building package `com.z2xy.zxtext' in `./com.z2xy.zxtext_0.0.1-1_iphoneos-arm.deb'.
install.exec "cat > /tmp/_theos_install.deb; dpkg -i /tmp/_theos_install.deb && rm /tmp/_theos_install.deb" < "./com.z2xy.zxtext_0.0.1-1_iphoneos-arm.deb"
Selecting previously deselected package com.z2xy.zxtext.
(Reading database ... 4989 files and directories currently installed.)
Unpacking com.z2xy.zxtext (from /tmp/_theos_install.deb) ...
Setting up com.z2xy.zxtext (0.0.1-1) ...
install.exec "killall -9 SpringBoard"

方法二:

  • 编译
 
zx:zxtest zx$ make
Making all for tweak zxtest...
 Preprocessing Tweak.xm...
 Compiling Tweak.xm...
 Linking tweak zxtest...
 Stripping zxtest...
 Signing zxtest...
  • 打包
 
zx:zxtest zx$ make package
Making all for tweak zxtest...
make[2]: Nothing to be done for `internal-library-compile'.
Making stage for tweak zxtest...
dpkg-deb: building package `com.z2xy.zxtext' in `./com.z2xy.zxtext_0.0.1-2_iphoneos-arm.deb'.
  • 上传到设备安装
 
x
zx:zxtest zx$ scp com.z2xy.zxtext_0.0.1-2_iphoneos-arm.deb  root@192.168.0.120:/var/root/
com.z2xy.zxtext_0.0.1-2_iphoneos-arm.deb                                                                     100% 2270     2.2KB/s   00:00 

当然了,可以使用各种工具将此deb文件上传到设备中,上面使用的是scp.

第一个参数是本地文件路径,第二参数目的路径

root@192.168.0.120指定了同一局域下的iOS设备,/var/root/指定的设备中的路径,中间有一个冒号连接.

  • 在设备上使用iFile到/var/root/目录下找到安装包安装

如果上面的步骤错误的话,

ununderstood data nember data.tar.xz

参考: http://stackoverflow.com/questions/21013325/dpkg-error-contains-ununderstood-data-member,打包的时候,压缩的方式和iOS设备上解压缩的方式不一致导致的错误.

方式是,替换$THEOS/makefiles/package/deb.mk文件中

 $(ECHO_NOTHING)COPYFILE_DISABLE=1 $(FAKEROOT) -r dpkg-deb -b "$(THEOS_STAGING_DIR)" "$(_THEOS_DEB_PACKAGE_FILENAME)" $(STDERR_NULL_REDIRECT)$(ECHO_END)

为:

$(ECHO_NOTHING)COPYFILE_DISABLE=1 $(FAKEROOT) -r dpkg-deb -Zgzip -b "$(THEOS_STAGING_DIR)" "$(_THEOS_DEB_PACKAGE_FILENAME)" $(STDERR_NULL_REDIRECT)$(ECHO_END)

  • 重启设备,看到弹窗

可以看到第一中方法简便了不少,只需要指定iP地址和完成证书配置就可以一行命令搞定.

步骤4: 证书设置(不用多次输入密码)

  • 删除iOS设备对应的ip地址所在行

~/.ssh/known_hosts

 
xxxxxxxxxx
 192.168.0.120 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvTS9W8/88Z+9j2D/TBft/ns173ssWhBGQgMyBnSAzIdhmfVd830aq2/78MgKyadyGxD6xhF/LG9tP5ZshaeZB9    XjBjQnEtB0gTZjiyGJpBWFdXCLX/uxV35gwZnu11Ts/HQzdC4+n+eh9pqKR7vsaJP/gIiYqfz/oDchlHrf7bdicZ0yKFlOpilTP4WLgPz2Qqr96xGcn/3dwimFTuye5zAqqfUApjTS/    idKvJNOEsFo6lVkuyOmkbItTjp6MfQliNorOY8nvV0DRFx2+lmedRjtq6UNPTyjuLPx3ymZIg/uOazvB0CHs/Ta2kMZRe1bPl8VcHI5/AbL0i7VHQB1p
  • mac上生成证书
 
$ssh-keygen -t rsa

如果已经生成过整数,直接得到~/.ssh/id_ras.pub 公钥就可以了.

  • iOS设置生成.ssh目录

ssh登录到iOS设备,生成证书就可以了

 
xxxxxxxxxx
$ssh root@192.168.0.120
zxde-iPhone:~ root# ssh-keygen
zxde-iPhone:~ root# ls -la
drwx------  2 root wheel    170 Sep 20 22:34 .ssh/
  • 用mac上的公钥,替换掉iOS设备上的公钥
 
scp ~/.ssh/id_rsa.pub root@192.168.0.120:/var/root/.ssh/

通过上面 的证书配置和iOS设备配置,

只需要方法一的一行

$make package install	

就可以实现,编译,打包,上传到设备,安装deb包,运行.

总结一些坑

  1. 下载头文件的时候,需要做一些替换,git仓库克隆后都有里面居然有这个步骤的注释!!!!(否则的话,打包就会出现找不到头文件,知道不到符号之类的错误)
  2. ldid签名工具下载,直接去下载就好了,不要从源码编译了.
  3. 配置MoblieSubstrate环境的话,直接从iOS设备上拷贝出来就可以了.
  4. makefile中指定iOS设备的IP地址,省了不少时间,同时,导入头文件,也是解决了找不到文件的错误.
  5. 打包文件的解压缩不一致导致的错误,

ununderstood data nember data.tar.xz

参考http://stackoverflow.com/questions/21013325/dpkg-error-contains-ununderstood-data-member就好了.

其实,有些问题在http://www.iphonedevwiki.net/index.php/Theos/Getting_Started 中已经给出了很好的回答

.9 Undefined symbols

9.10 Incompatible package compression

只是最开始没有看.

最后,"步骤4: 证书设置(不用多次输入密码)”,使用后,方便了很多.

最后的最后,这里还有一些列相关的资料:

  • http://security.ios-wiki.com/

undefined

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/544178.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

查询中,有没有可能多个索引一起用呢?

其实我们之前所讲的回表&#xff0c;就是两个索引树同时使用&#xff0c;先在二级索引树中搜索到对应的主键值&#xff0c;然后在再去主键索引树中查询完整的记录。但是我今天的问题是&#xff0c;两个不同的二级索引树&#xff0c;会同时生效吗&#xff1f;理论上来说&#xf…

ruby array_Ruby中带有示例的Array.sample()方法

ruby arrayArray.sample()方法 (Array.sample() Method) In this article, we will study about Array.sample() method. You all must be thinking the method must be doing something which is quite different from all those methods which we have studied. It is not as…

ThreadLocal夺命11连问

前言前一段时间&#xff0c;有同事使用ThreadLocal踩坑了&#xff0c;正好引起了我的兴趣。所以近期&#xff0c;我抽空把ThreadLocal的源码再研究了一下&#xff0c;越看越有意思&#xff0c;发现里面的东西还真不少。我把精华浓缩了一下&#xff0c;汇集成了下面11个问题&…

关于静态库、动态库的区别汇总

real framework中不可以使用类别 或 不可以不包含类文件real framework 中直接调用NSClassFromString函数会返回null 需要强制加载指定类 或 直接通过类名引用linux中静态库和动态库的区别一、不同库从本质上来说是一种可执行代码的二进制格式&#xff0c;可以被载入内存中执行…

PHP array_pad()函数与示例

PHP array_pad()函数 (PHP array_pad() function) array_pad() function is used to pad an array to given size with a specified value and returns a new array with a specified value. array_pad()函数用于将数组填充到具有指定值的给定大小&#xff0c;并返回具有指定值…

Spring Boot 优雅配置多数据源

大约在19年的这个时候&#xff0c;老同事公司在做医疗系统&#xff0c;需要和HIS系统对接一些信息&#xff0c;比如患者、医护、医嘱、科室等信息。但是起初并不知道如何与HIS无缝对接&#xff0c;于是向我取经。最终经过讨论采用了视图对接的方式&#xff0c;大致就是HIS系统提…

(转)新ITC提交APP常见问题与解决方法(Icon Alpha,Build version,AppIcon120x120)(2014-11-17)...

1&#xff09;ICON无法上传&#xff0c;提示图片透明&#xff08;有Alpha通道&#xff09;苹果现在不接受png里的Alpha了&#xff0c;提交的图标带有Alpha通道就提示&#xff1a;简单处理&#xff1a;用自带的预览打开&#xff0c;导出时不勾选Alpha&#xff0c;仍保存为png格式…

python 向量取整数_随机整数向量| 使用Python的线性代数

python 向量取整数Prerequisite: 先决条件&#xff1a; Defining a Vector using list 使用列表定义向量 Defining Vector using Numpy 使用Numpy定义向量 Random Integer Vector is a type of vector having a random integer value at each entry. Such types of vectors ha…

Spring 夺命 35 问!

有人说&#xff0c;“Java程序员都是Spring程序员”&#xff0c;可以看出Spring在Java世界里举足轻重的作用。基础1.Spring是什么&#xff1f;特性&#xff1f;有哪些模块&#xff1f;Spring Logo一句话概括&#xff1a;Spring 是一个轻量级、非入侵式的控制反转 (IoC) 和面向切…

Android百度地图开发03之地图控制 + 定位

前两篇关于百度地图的blog写的是&#xff0c;一些基本图层的展示 和 覆盖物的添加地理编码和反地理编码。 接下来&#xff0c;这篇blog主要说一些关于地图控制方面的内容和定位功能。 百度地图提供的关于地图的操作主要有&#xff1a;单击、双击、长按、缩放、旋转、俯视等。 地…

软件工程需要学什么_为什么我们需要软件工程?

软件工程需要学什么Software engineering is the application of the set of pre-defined procedures while developing any project. But why do we need Software engineering? What factors made us implement these predefined set of procedures and protocols while dev…

IDEA 版 Postman 面世了,功能真心强大!

IDEA是最常用的开发工具&#xff0c;很多程序员都想把它打造成一站式开发平台&#xff0c;于是安装了各种各样的插件。最近发现了一款IDEA插件RestfulFastRequest&#xff0c;细节做的真心不错&#xff0c;说它是IDEA版的Postman也不为过&#xff0c;推荐给大家&#xff01;Res…

DNS子域授权

转载于:https://blog.51cto.com/changeflyhigh/1697257

mongo数据库插入数据_深入研究Mongo数据库

mongo数据库插入数据More popularly known as "mongoDB". It is a no-sql based database. 俗称“ mongoDB” 。 这是一个基于无SQL的数据库。 BASIC STRUCTURE OF MONGO DB MONGO DB的基本结构 A COLLECTION IN MONGODB having 3 DOCUMENTS MONGODB中有3个文档的集…

java方法重载和重载方法_我们可以在Java中重载main()方法吗?

java方法重载和重载方法The question is that "can we overload main() method in Java?" 问题是“我们可以在Java中重载main()方法吗&#xff1f;” Yes, We can overload the main() method in Java. 是的&#xff0c;我们可以重载Java中的main()方法 。 JVM cal…

五分钟,手撸一个Spring容器!

Spring是我们最常用的开源框架&#xff0c;经过多年发展&#xff0c;Spring已经发展成枝繁叶茂的大树&#xff0c;让我们难以窥其全貌。这节&#xff0c;我们回归Spring的本质&#xff0c;五分钟手撸一个Spring容器&#xff0c;揭开Spring神秘的面纱&#xff01;从什么是IOC开始…

一步一步搭建客服系统 (7) 多人共享的电子白板、画板

多人共享、同时操作的电子白板&#xff0c;让不同的参入者以不同的颜色来画画&#xff1b;可以保存当前room的内容&#xff0c;以让后来者可以直接加载所有内容。 在github上找到一个用html5 canvas实现的一个电子白板的例子&#xff1a; https://github.com/kblcuk/canvas-whi…

Spring Cloud OpenFeign 的 5 个优化小技巧!

作者 | 磊哥来源 | Java中文社群&#xff08;ID&#xff1a;javacn666&#xff09;转载请联系授权&#xff08;微信ID&#xff1a;GG_Stone&#xff09;OpenFeign 是 Spring 官方推出的一种声明式服务调用和负载均衡组件。它的出现就是为了替代已经进入停更维护状态的 Feign&am…

java的equals方法_Java Vector equals()方法与示例

java的equals方法向量类的equals()方法 (Vector Class equals() method) equals() method is available in java.util package. equals()方法在java.util包中可用。 equals() method is used to check whether this Vector is the same or equals to the given object (ob) or …

推荐几个好文章

1 cocos2dx各种行动 http://www.cnblogs.com/linux-ios/archive/2013/04/06/3001946.html 2 cocos2dx自己定义曲线 http://blog.csdn.net/ufolr/article/details/7447773 3 lua中载入cocostudio动画&#xff0c;触发帧事件&#xff08;非常全&#xff0c;非常具体。还有源代码…