您的位置:首页 > 其它

THEOS的第一个TWeak的成功创建

2015-09-21 00:24 561 查看


THEOS的第一个TWeak的成功创建html, body {overflow-x: initial !important;}.CodeMirror { height: auto; }
.CodeMirror-scroll { overflow-y: hidden; overflow-x: auto; }
.CodeMirror-lines { padding: 4px 0px; }
.CodeMirror pre { padding: 0px 4px; }
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { background-color: white; }
.CodeMirror-gutters { border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); background-color: rgb(247, 247, 247); white-space: nowrap; }
.CodeMirror-linenumbers { }
.CodeMirror-linenumber { padding: 0px 3px 0px 5px; min-width: 20px; text-align: right; color: rgb(153, 153, 153); }
.CodeMirror div.CodeMirror-cursor { border-left-width: 1px; border-left-style: solid; border-left-color: black; z-index: 3; }
.CodeMirror div.CodeMirror-secondarycursor { border-left-width: 1px; border-left-style: solid; border-left-color: silver; }
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor { width: auto; border: 0px; background-color: rgb(119, 238, 119); z-index: 1; background-position: initial initial; background-repeat: initial initial; }
.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite { }
.cm-tab { display: inline-block; }
.cm-s-default .cm-keyword { color: rgb(119, 0, 136); }
.cm-s-default .cm-atom { color: rgb(34, 17, 153); }
.cm-s-default .cm-number { color: rgb(17, 102, 68); }
.cm-s-default .cm-def { color: rgb(0, 0, 255); }
.cm-s-default .cm-variable { color: black; }
.cm-s-default .cm-variable-2 { color: rgb(0, 85, 170); }
.cm-s-default .cm-variable-3 { color: rgb(0, 136, 85); }
.cm-s-default .cm-property { color: black; }
.cm-s-default .cm-operator { color: black; }
.cm-s-default .cm-comment { color: rgb(170, 85, 0); }
.cm-s-default .cm-string { color: rgb(170, 17, 17); }
.cm-s-default .cm-string-2 { color: rgb(255, 85, 0); }
.cm-s-default .cm-meta { color: rgb(85, 85, 85); }
.cm-s-default .cm-qualifier { color: rgb(85, 85, 85); }
.cm-s-default .cm-builtin { color: rgb(51, 0, 170); }
.cm-s-default .cm-bracket { color: rgb(153, 153, 119); }
.cm-s-default .cm-tag { color: rgb(17, 119, 0); }
.cm-s-default .cm-attribute { color: rgb(0, 0, 204); }
.cm-s-default .cm-header { color: blue; }
.cm-s-default .cm-quote { color: rgb(0, 153, 0); }
.cm-s-default .cm-hr { color: rgb(153, 153, 153); }
.cm-s-default .cm-link { color: rgb(0, 0, 204); }
.cm-negative { color: rgb(221, 68, 68); }
.cm-positive { color: rgb(34, 153, 34); }
.cm-header, .cm-strong { font-weight: bold; }
.cm-em { font-style: italic; }
.cm-link { text-decoration: underline; }
.cm-s-default .cm-error { color: rgb(255, 0, 0); }
.cm-invalidchar { color: rgb(255, 0, 0); }
div.CodeMirror span.CodeMirror-matchingbracket { color: rgb(0, 255, 0); }
div.CodeMirror span.CodeMirror-nonmatchingbracket { color: rgb(255, 34, 34); }
.CodeMirror-activeline-background { background-color: rgb(232, 242, 255); background-position: initial initial; background-repeat: initial initial; }
.CodeMirror { position: relative; overflow: hidden; }
.CodeMirror-scroll { margin-bottom: -30px; margin-right: -30px; padding-bottom: 30px; padding-right: 30px; height: 100%; outline: none; position: relative; box-sizing: content-box; }
.CodeMirror-sizer { position: relative; }
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { position: absolute; z-index: 6; display: none; }
.CodeMirror-vscrollbar { right: 0px; top: 0px; overflow-x: hidden; overflow-y: scroll; }
.CodeMirror-hscrollbar { bottom: 0px; left: 0px; overflow-y: hidden; overflow-x: scroll; }
.CodeMirror-scrollbar-filler { right: 0px; bottom: 0px; }
.CodeMirror-gutter-filler { left: 0px; bottom: 0px; }
.CodeMirror-gutters { position: absolute; left: 0px; top: 0px; padding-bottom: 30px; z-index: 3; }
.CodeMirror-gutter { white-space: normal; height: 100%; box-sizing: content-box; padding-bottom: 30px; margin-bottom: -32px; display: inline-block; }
.CodeMirror-gutter-elt { position: absolute; cursor: default; z-index: 4; }
.CodeMirror-lines { cursor: text; }
.CodeMirror pre { border-top-left-radius: 0px; border-top-right-radius: 0px; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; border-width: 0px; background-color: transparent; font-family: inherit; font-size: inherit; margin: 0px; white-space: pre; word-wrap: normal; color: inherit; z-index: 2; position: relative; overflow: visible; background-position: initial initial; background-repeat: initial initial; }
.CodeMirror-wrap pre { word-wrap: break-word; white-space: pre-wrap; word-break: normal; }
.CodeMirror-code pre { border-right-width: 30px; border-right-style: solid; border-right-color: transparent; width: -webkit-fit-content; }
.CodeMirror-wrap .CodeMirror-code pre { border-right-style: none; width: auto; }
.CodeMirror-linebackground { position: absolute; left: 0px; right: 0px; top: 0px; bottom: 0px; z-index: 0; }
.CodeMirror-linewidget { position: relative; z-index: 2; overflow: auto; }
.CodeMirror-widget { }
.CodeMirror-wrap .CodeMirror-scroll { overflow-x: hidden; }
.CodeMirror-measure { position: absolute; width: 100%; height: 0px; overflow: hidden; visibility: hidden; }
.CodeMirror-measure pre { position: static; }
.CodeMirror div.CodeMirror-cursor { position: absolute; visibility: hidden; border-right-style: none; width: 0px; }
.CodeMirror-focused div.CodeMirror-cursor { visibility: visible; }
.CodeMirror-selected { background-color: rgb(217, 217, 217); background-position: initial initial; background-repeat: initial initial; }
.CodeMirror-focused .CodeMirror-selected { background-color: rgb(215, 212, 240); background-position: initial initial; background-repeat: initial initial; }
.cm-searching { background-color: rgba(255, 255, 0, 0.4); background-position: initial initial; background-repeat: initial initial; }
.CodeMirror span { }
@media print {
.CodeMirror div.CodeMirror-cursor { visibility: hidden; }
}

html { font-size: 14px; }
body { margin: 0px; padding: 0px; height: auto; bottom: 0px; top: 0px; left: 0px; right: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1rem; line-height: 1.42857143; color: rgb(51, 51, 51); background-color: rgb(255, 255, 255); overflow-x: hidden; }
a:active, a:hover { outline: 0px; }
::selection { background-color: rgb(181, 214, 252); text-shadow: none; background-position: initial initial; background-repeat: initial initial; }
#write { max-width: 854px; margin: 0px auto; height: auto; width: inherit; word-break: normal; word-wrap: break-word; position: relative; white-space: pre-wrap; text-align: justify; padding-bottom: 70px; }
body.typora-export { padding-left: 30px; padding-right: 30px; }
.typora-export #write { margin: 0px auto; }
#write > p:first-child, #write > ul:first-child, #write > pre:first-child, #write > blockquote:first-child, #write > div:first-child { margin-top: 30px; }
img { max-width: 100%; }
input, button, select, textarea { color: inherit; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; }
input[type="checkbox"], input[type="radio"] { line-height: normal; padding: 0px; }
::before, ::after, * { box-sizing: border-box; }
#write p, #write h1, #write h2, #write h3, #write h4, #write h5, #write h6, #write div, #write pre { width: inherit; }
h1 { font-size: 2rem; }
p, .mathjax-block { display: block; -webkit-margin-before: 1rem; -webkit-margin-after: 1rem; -webkit-margin-start: 0px; -webkit-margin-end: 0px; }
.hidden { display: none; }
.md-blockmeta { color: rgb(204, 204, 204); font-weight: bold; font-style: italic; }
a { cursor: pointer; }
li span { min-width: 10px; }
#write input[type="checkbox"] { cursor: pointer; width: inherit; height: inherit; margin: 4px 0px 0px; }
tr { page-break-inside: avoid; page-break-after: auto; }
thead { display: table-header-group; }
table { border-collapse: collapse; border-spacing: 0px; width: 100%; overflow: auto; page-break-inside: auto; }
table.md-table td { min-width: 80px; }
.CodeMirror-placeholder { opacity: 0.3; }
.CodeMirror-code pre { padding: 0px; }
.CodeMirror-lines { padding: 0px; }
div.hr:focus { cursor: none; }
.md-fences, pre.md-fences { font-size: 0.9rem; display: block; page-break-inside: avoid; text-align: left; overflow: visible; white-space: pre; position: relative !important; }
.md-fences .CodeMirror.cm-s-default.CodeMirror-wrap { top: -1.6em; margin-bottom: -1.6em; }
.md-fences.mock-cm { white-space: pre-wrap; }
.footnotes { color: rgb(136, 136, 136); font-size: 0.9rem; padding-top: 1em; padding-bottom: 1em; }
.footnotes + .footnotes { margin-top: -1em; }
.md-reset { margin: 0px; padding: 0px; border: 0px; outline: 0px; vertical-align: top; background-color: transparent; text-decoration: none; color: rgb(51, 51, 51); font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 1rem; text-shadow: none; float: none; position: static; width: auto; height: auto; white-space: nowrap; cursor: inherit; line-height: normal; font-weight: normal; text-align: left; box-sizing: content-box; direction: ltr; background-position: initial initial; background-repeat: initial initial; }
li div { padding-top: 0px; }
blockquote { margin: 1rem 0px; }
li p, li .mathjax-block { margin: 0.5rem 0px; }
li { margin: 0px; position: relative; }
blockquote > :last-child { margin-bottom: 0px; }
blockquote > :first-child { margin-top: 0px; }
.footnotes-area { color: rgb(136, 136, 136); margin-top: 0.714rem; padding-bottom: 0.143rem; }
@media print {
html, body { height: 100%; }
.typora-export * { -webkit-print-color-adjust: exact; }
}
.footnote-line { margin-top: 0.714em; font-size: 0.7em; }
a img, img a { cursor: pointer; }
#write pre.md-meta-block { font-size: 0.8rem; min-height: 2.86rem; white-space: pre; background-color: rgb(204, 204, 204); display: block; background-position: initial initial; background-repeat: initial initial; }
p > .md-image:only-child { display: inline-block; width: 100%; text-align: center; }
#write .MathJax_Display { margin: 0.8em 0px 0px; }
.mathjax-block { white-space: pre; padding-bottom: 0.65rem; overflow: hidden; width: 100%; }
p + .mathjax-block { margin-top: -1.143rem; }
.mathjax-block:not(:empty)::after { display: none; }
[contenteditable="true"]:active, [contenteditable="true"]:focus { outline: none; box-shadow: none; }
:focus { outline: none; box-shadow: rgb(79, 172, 249) 0px 0px 2px 3px, rgb(120, 174, 218) 0px 0px 2px inset; }
.task-list { list-style-type: none; }
.task-list-item { position: relative; padding-left: 1em; }
.task-list-item input { position: absolute; top: 0px; left: 0px; }
.math { font-size: 1rem; }
.md-toc { min-height: 3.58rem; position: relative; font-size: 0.9rem; border-top-left-radius: 10px; border-top-right-radius: 10px; border-bottom-right-radius: 10px; border-bottom-left-radius: 10px; }
.md-toc-content { position: relative; margin-left: 0px; }
.md-toc::after, .md-toc-content::after { display: none; }
.md-toc-item { display: block; color: rgb(65, 131, 196); text-decoration: none; }
.md-toc-inner:hover { text-decoration: underline; }
.md-toc-inner { display: inline-block; cursor: pointer; }
.md-toc-h1 .md-toc-inner { margin-left: 0px; font-weight: bold; }
.md-toc-h2 .md-toc-inner { margin-left: 2em; }
.md-toc-h3 .md-toc-inner { margin-left: 4em; }
.md-toc-h4 .md-toc-inner { margin-left: 6em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 .md-toc-inner { margin-left: 10em; }
.md-toc-h6 { margin-left: 12em; }
@media screen and (max-width: 48em) {
.md-toc-h3 .md-toc-inner { margin-left: 3.5em; }
.md-toc-h4 .md-toc-inner { margin-left: 5em; }
.md-toc-h5 .md-toc-inner { margin-left: 6.5em; }
.md-toc-h5 .md-toc-inner { margin-left: 8em; }
.md-toc-h6 { margin-left: 9.5em; }
}
a.md-toc-inner { color: inherit; font-size: inherit; font-style: inherit; font-weight: inherit; text-decoration: inherit; line-height: inherit; }
.footnote-line a:not(.reversefootnote) { color: inherit; }
.md-attr { display: none; }
.md-fn-count::after { content: '.'; }
.md-tag { opacity: 0.5; }
h1 .md-tag, h2 .md-tag, h3 .md-tag, h4 .md-tag, h5 .md-tag, h6 .md-tag { font-weight: initial; opacity: 0.35; }

html { font-size: 16px; }
html, body { background-color: rgb(243, 242, 238); font-family: 'PT Serif'; color: rgb(31, 9, 9); line-height: 1.5em; }
#write { max-width: 36em; }
ol, ul { list-style: none; }
blockquote, q { quotes: none; }
blockquote::before, blockquote::after, q::before, q::after { content: none; }
table { border-collapse: collapse; border-spacing: 0px; }
h1, h2, h3, h4, h5, h6 { font-weight: bold; }
h1 { font-size: 1.875em; line-height: 1.6em; margin-top: 2em; }
h2, h3 { font-size: 1.3125em; line-height: 1.15; margin-top: 2.285714em; margin-bottom: 1.15em; }
h3 { font-weight: normal; }
h4 { font-size: 1.125em; margin-top: 2.67em; }
h5, h6 { font-size: 1em; }
h1 { border-bottom-width: 1px; border-bottom-style: solid; margin-bottom: 1.875em; padding-bottom: 0.8125em; }
a { text-decoration: none; color: rgb(6, 85, 136); }
a:hover, a:active { text-decoration: underline; }
p, blockquote, pre.md-fences, .md-fences { margin-bottom: 1.5em; }
h1, h2, h3, h4, h5, h6 { margin-bottom: 1.5em; }
blockquote { font-style: italic; border-left-width: 5px; border-left-style: solid; margin-left: 2em; padding-left: 1em; }
ul, ol { margin: 0px 0px 1.5em 1.5em; }
ol li { list-style-type: decimal; list-style-position: outside; }
ul li { list-style-type: disc; list-style-position: outside; }
.md-meta, .md-before, .md-after { color: rgb(153, 153, 153); }
table { margin-bottom: 1.5em; font-size: 1em; }
thead th, tfoot th { padding: 0.25em 0.25em 0.25em 0.4em; text-transform: uppercase; }
th { text-align: left; }
td { vertical-align: top; padding: 0.25em 0.25em 0.25em 0.4em; }
code, pre.md-fences { background-color: rgb(218, 218, 218); padding-left: 1ch; padding-right: 1ch; }
pre.md-fences { margin-left: 2em; margin-bottom: 3em; }
pre, code, tt { font-size: 0.875em; line-height: 1.714285em; }
h1 { line-height: 1.3em; font-weight: normal; margin-bottom: 0.5em; }
p + ul, p + ol { margin-top: -1em; }
h3 + ul, h4 + ul, h5 + ul, h6 + ul, h3 + ol, h4 + ol, h5 + ol, h6 + ol { margin-top: 0.5em; }
li > ul, li > ol { margin-top: inherit; }
h2, h3 { margin-bottom: 0.75em; }
hr { border-style: none none solid; border-bottom-width: 1px; }
h1 { border-color: rgb(197, 197, 197); }
blockquote { border-color: rgb(186, 186, 186); color: rgb(101, 101, 101); }
thead.md-table-edit { background-color: transparent; }
thead { background-color: rgb(218, 218, 218); }
tr:nth-child(even) { background-color: rgb(232, 231, 231); background-position: initial initial; background-repeat: initial initial; }
hr { border-color: rgb(197, 197, 197); }
.task-list { padding-left: 1rem; }
.task-list-item { padding-left: 1.5rem; list-style-type: none; }
.task-list-item input::before { content: '√'; display: inline-block; width: 1.25rem; height: 1.5rem; vertical-align: middle; text-align: center; color: rgb(221, 221, 221); background-color: rgb(243, 242, 238); }
.task-list-item input:checked::before, .task-list-item input[checked]::before { color: inherit; }
#write pre.md-meta-block { min-height: 1.875rem; color: rgb(85, 85, 85); border: 0px; background-color: transparent; margin-left: 1em; margin-top: 1em; background-position: initial initial; background-repeat: initial initial; }
.md-image > .md-meta { color: rgb(155, 81, 70); }
.md-expand.md-image > .md-meta { background-color: rgba(255, 255, 255, 0.65098); }
.md-image > .md-meta { font-family: Menlo, 'Ubuntu Mono', Consolas, 'Courier New', 'Microsoft Yahei', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', sans-serif; }
#write > h3.md-focus::before { left: -2.5rem; color: rgb(153, 153, 153); border-color: rgb(153, 153, 153); }
#write > h4.md-focus::before { left: -2.5rem; top: 0.25rem; color: rgb(153, 153, 153); border-color: rgb(153, 153, 153); }
#write > h5.md-focus::before { left: -2.5rem; color: rgb(153, 153, 153); border-color: rgb(153, 153, 153); }
#write > h6.md-focus::before { left: -2.5rem; top: 0.3125rem; color: rgb(153, 153, 153); border-color: rgb(153, 153, 153); }
.md-toc:focus .md-toc-content { margin-top: 19px; }
.md-toc-content:empty::before { color: rgb(6, 85, 136); }
.md-toc-item { color: rgb(6, 85, 136); }
#write div.md-toc-tooltip { background-color: rgb(243, 242, 238); }
#outline-dropmenu { background-color: rgb(243, 242, 238); -webkit-box-shadow: rgba(0, 0, 0, 0.372549) 0px 6px 12px; box-shadow: rgba(0, 0, 0, 0.372549) 0px 6px 12px; }
.pin-outline #outline-dropmenu { background-image: inherit; background-size: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: inherit; box-shadow: none; border-right-width: 1px; border-right-style: dashed; background-position: inherit inherit; background-repeat: inherit inherit; }
.pin-outline #outline-dropmenu:hover .outline-title-wrapper { border-left-width: 1px; border-left-style: dashed; }
.outline-item:hover { background-color: rgb(218, 218, 218); border-left-width: 18px; border-left-style: solid; border-left-color: rgb(218, 218, 218); border-right-width: 18px; border-right-style: solid; border-right-color: rgb(218, 218, 218); }
.outline-expander::before { content: ''; font-family: FontAwesome; font-size: 14px; top: 1px; }
.outline-expander:hover::before, .outline-item-open > .outline-item > .outline-expander::before { content: ''; }

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来查看设置的环境变量是否设置好了.

[code]
zx:iOSTools zx$ echo $THEOS
[code]/usr/local/iOSTools/theo

b:下载theos

下载的方法很多

svn的方法有:
svn co http://svn.howett.net/svn/theos/trunk $THEOS
gitt途径(推荐,方便升级)
[code]
git clone git://github.com/DHowett/theos.git $ THEOS
当然了,也可以直接去git仓库里下载一份压缩的,将里面的内容解压到$THEOS

c:下载头文件

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

clone 头文件仓库
将头文件放到theos/include/目录下
复制系统的IOSurfaceAPI.h到**theos/include/IOSurface**目录下
注释掉IOSurfaceCreateXPCObject 和IOSurfaceLookupFromXPCObject.
[code]# 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
[code]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.当然了,你可以直接从源码编译安装,下面是源码仓库

[code]
https://github.com/rpetrich/ldid

e:配置MoblieSubstrate环境

方法一:

[code]# 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

“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.

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 创建工程

选一个目录,存放工程.

[code]
zx:theosCode zx$ pwd
[code]/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.
生成后的文件列表如下:

[code]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文件

[code]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

[code]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
[code]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
[code]Making all for tweak zxtest...
Preprocessing Tweak.xm...
Compiling Tweak.xm...
Linking tweak zxtest...
Stripping zxtest...
Signing zxtest...
打包
zx:zxtest zx$ make package
[code]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'.
上传到设备安装
[code]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

[code]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设备,生成证书就可以了

[code][code]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设备配置,

只需要方法一的一行

[code]$make package install
就可以实现,编译,打包,上传到设备,安装deb包,运行.

总结一些坑

下载头文件的时候,需要做一些替换,git仓库克隆后都有里面居然有这个步骤的注释!!!!(否则的话,打包就会出现找不到头文件,知道不到符号之类的错误)
ldid签名工具下载,直接去下载就好了,不要从源码编译了.
配置MoblieSubstrate环境的话,直接从iOS设备上拷贝出来就可以了.
makefile中指定iOS设备的IP地址,省了不少时间,同时,导入头文件,也是解决了找不到文件的错误.
打包文件的解压缩不一致导致的错误,
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: