zoukankan      html  css  js  c++  java
  • iOS逆向:1、THEOS 、Tweak 插件 -- 环境搭建(完结)(2020.11.12更)

    0、说到越狱插件开发,一般搜下去 都是 Tweak、Thews 之类的。按我学习的流水记录下。

    1、终端安装thews(相当于宏定义一个路径为THEOS,把这个git的东西下载到这个宏/路径)

    export THEOS=/opt/theos
    
    git clone --recursive https://github.com/theos/theos.git $THEOS

    2、安装brew(前提是ruby已安装,一般安装过cocoapods,就已经安装过ruby了)

    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

     注:这个时候,可能下载不下来。可能需要添加hosts

    sudo vi /etc/hosts

     然后把这个网址 https://site.ip138.com/raw.Githubusercontent.com/ 解析的IP加进去

    # GitHub Start
    52.74.223.119 github.com
    192.30.253.119 gist.github.com
    54.169.195.247 api.github.com
    185.199.111.153 assets-cdn.github.com
    151.101.76.133 raw.githubusercontent.com
    151.101.108.133 user-images.githubusercontent.com
    151.101.76.133 gist.githubusercontent.com
    151.101.76.133 cloud.githubusercontent.com
    151.101.76.133 camo.githubusercontent.com
    151.101.76.133 avatars0.githubusercontent.com
    151.101.76.133 avatars1.githubusercontent.com
    151.101.76.133 avatars2.githubusercontent.com
    151.101.76.133 avatars3.githubusercontent.com
    151.101.76.133 avatars4.githubusercontent.com
    151.101.76.133 avatars5.githubusercontent.com
    151.101.76.133 avatars6.githubusercontent.com
    151.101.76.133 avatars7.githubusercontent.com
    151.101.76.133 avatars8.githubusercontent.com
    # GitHub End

     注:hosts解析 参考自该文章 https://blog.csdn.net/laoxuan2011/article/details/106177126?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522160459280619724838554874%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=160459280619724838554874&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~top_click~default-1-106177126.pc_v1_rank_blog_v1&utm_term=raw.githubusercontent.com&spm=1018.2118.3001.4450 

    3、安装ldid(签名用)

    brew install ldid

    4、安装dpkg(打包成deb)

    brew install dpkg

    5 、安装 command line tools(不清楚用在哪里,照着教程装)

    https://developer.apple.com/downloads/?=Command%20Line%20Tools%20

    6、安装 sshpass(应该不需要,先跳过,有需要再看)

    brew install https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb

    基本会报错,

    Error: Calling Non-checksummed download of sshpass formula file from an arbitrary URL is disabled! Use 'brew extract' or 'brew create' and 'brew tap-new' to create a formula file in a tap on GitHub instead.

    网上的资料,都是 waring ,直接跳过,我的终端却是 error ,安装失败。这个时候可以下载至本地再次执行安装

    wget https://raw.githubusercontent.com/kadwanev/bigboybrew/master/Library/Formula/sshpass.rb
    brew install sshpass.rb

    注:如果 wget 指令没有的话,还需要先装 wget

    brew install wget

    7、安装 openssh(好像有git的,基本都有装openssh了。ssh-copy-id 要装,以后在终端执行ssh root@ip,就不用再输密码了)

    brew install openssl
    brew install ssh-copy-id

    ============================================== 安装 完成 ==============================================

    0、开始创建第一个demo

    1、每次打开终端,都需要对路径进行“宏定义”一次(第二行才是创建)

    export THEOS=/opt/theos
    $THEOS/bin/nic.pl

    2、然后根据返回的列表,输入 iphone/tweal 的序号。

    3、然后是 项目名、包名、开发者、监听领域、回车。

    注:好像 1)包名不能大写,不然编译有问题。

         2)监听领域:默认 om.apple.springboard ,iOS的桌面app

                      com.apple.UIKit ,作用于所有的app

    4、这个时候,会在 /Users,生成 项目名的文件夹。(为什么是/Users ? 因为,每次打开终端,都默认 /Users ,除非,自己再 cd )

    5、对 .x 或者 .xm 编程(版本不同 后缀不同,其实一样的)。

      编程内容为 %hook 开机类名,然后是方法名,%orig 是继续执行原来代码的意思,相当于[super xxx],最后%end。

    #import <SpringBoard/SpringBoard.h>
    %hook SpringBoard
    -(void)applicationDidFinishLaunching:(id)application {
        %orig;
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"你好" message:@"欢迎使用" delegate:nil cancelButtonTitle:@"hook成功了" otherButtonTitles:nil];
        [alert show];
    }
    %end

      注:网上写,如果不%orig,没办法进入系统,因为iOS桌面app没法执行下一步。

    (分支)、手机第一次用openssh,需要设置密码(手机端,也要记得从 cydia 下 openssh )

    获得手机控制权(SSH),终端输入

    ssh root@同一Wi-Fi下的越狱手机ip

    再设置/输入密码,一般都是 alpine(可修改),连接成功,光标处就变成 root 。(如输入 reboot ,手机将立即重启,这里只是说ssh root 后可以做什么,不是要你 reboot 重启手机

    reboot

    注:网上资料看到的修改密码指令,是这样的,暂未验证。

    passwd root        修改root用户密码
    passwd mobile    修改mobile用户密码
    
    ssh登录手机后,在命令行输入passwd
    root# passwd
    Changing password for root.
    New password:
    Retype new password:
    root#

    6、打开makefile,填入如下( 手机的IP,直接通过wifi下载/烧写,项目的UIAlertView 依赖UIKit库)

    export THEOS = /opt/theos
    export THEOS_DEVICE_IP = 同一Wi-Fi下越狱手机的ip
    
    项目名_FRAMEWORKS = UIKit
    
    
    
    放最后
    after-install::
        install.exec "killall -9 SpringBoard"

    7-1、编译( 先cd 项目文件夹 )

    make

      注:如果在上面(分支)步骤,终端进入了手机root模式,请先按ctl+D退出,或开新终端窗口

    7-2、编译 带 Wi-Fi下载( 先cd 项目文件夹 )

    make package install

      如果上面有装 openssl、ssh-copy-id ,可以避免输两次密码安装

      1)、生成密钥保存(如果使用过git,应该是有生成过了,可以跳过改步)

    ssh-keygen -t rsa -b 2048

      2)、复制到手机(网上看到有多种写法,我用第一种,成功)

    ssh-copy-id -i /Users/用户名/.ssh/id_rsa root@同一Wi-Fi下的越狱手机ip
    
    ssh-copy-id -i  root@同一Wi-Fi下的越狱手机ip
    
    ssh-copy-id root@同一Wi-Fi下的越狱手机ip

    ============================================== 出现的坑 ==============================================

    1、make 编译 失败

    ==> Error: You do not have any SDKs in /Library/Developer/CommandLineTools/Platforms/iPhoneOS.platform/Developer/SDKs or /opt/theos/sdks.
    make: *** [before-all] Error 1

     解决

    sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer/

    2、即使在 makefile 文件写,库依赖,但是还是make失败。

    项目名_FRAMEWORKS = UIKit

    解决:在 .xm或 .x 文件引入头文件

    #import <UIKit/UIKit.h>

    注:可能一些环境配置有问题,导致这个问题的原因还没找,有空再找找。

    3、make package install 下载后,无效果(插件没运行),查了网上一些资料,发现类似的,是下载到根目录了,需要移动到这个位置(可用爱思助手/iFile 手机越狱软件)。

    /Library/MobileSubstrate/DynamicLibraries/

    注:好像是版本的问题(用下面“参考自” - “新:”安装thoes,好像没再出现了)


    ============================================== 参考自 ==============================================

    旧:搭旧版本环境麻烦,要从手机拷贝文件,还要去下载ios头文件,但第一个demo比较详细

    https://www.jianshu.com/p/b546e26bddb1

    新:搭新版本环境 比较快上手

    https://www.jianshu.com/p/a5435650e828

  • 相关阅读:
    JS练习:定时器--背景颜色交替变换
    JS练习:切换图片
    BOM对象和DOM对象
    CSS练习:仿小米官网
    classification
    where does the error come from
    梯度下降
    torch 中各种图像格式转化
    regression
    torch 的包应用
  • 原文地址:https://www.cnblogs.com/leonlincq/p/13967248.html
Copyright © 2011-2022 走看看