越狱开发笔记
必备插件

安装openSSH插件

-
SSH、open SSH
open SSH是工具,通过 open SSH 可以访问手机、和其他的应用
通过openSSH连接(登录)手机
$ ssh 用户名@用户服务器地址
// cycript 相当于 有个cycript应用,是电脑通过cycript 链接手机
// ssh 是协议:ssh登录手机



上图第9个、pwd: alpine
iOS 下有两个用户
- root 最高权限的用户 $ HOME: /var/root
- 还有一个 mobile $ HOME: /var/mobile
$ cd ~/.ssh
$ ls
$ cat known_hosts
$ pwd
$ exit
$ ssh mobile@192.168.31.178 //--> iPhone:~ mobile$ pwd
$ ssh root@192.168.31.178 //--> iPhone:~ root# pwd
// 1--------------------------------------------------------
$ ssh root@192.168.31.178 //--> iPhone:~ root# pwd
iPhone:~ root# cd /
iPhone:~ root# ls
iPhone:~ root# pwd
iPhone:~ root# touch 1.txt //新建一个文件 " 1.txt " --> 创建成功
iPhone:~ root# rm 1.txt //删除文件 " 1.txt " rm = remove
iPhone:~ root# passwd //修改登录密码
New password: xxx
Retype new password: xxx
iPhone:~ root# sudo
iPhone:~ root# cd var/mobile/
iPhone:var/mobile/ root# exit // --> logout
// 2 --------------------------------------------------------
$ ssh mobile@192.168.31.178 // --> iPhone:~ mobile$ pwd
iPhone:~ mobile# cd /
iPhone:~ mobile# ls
iPhone:~ mobile# pwd
iPhone:~ mobile# touch 2.txt //新建一个文件 --> 创建失败 touch:cannot touch '2.txt': Permission dened
iPhone:~ mobile#
iPhone:~ mobile#
iPhone:~ mobile# cd var/mobile/
iPhone:var/mobile/ root# exit // --> logout
// 由1、2 得出:root 用户才有读写权限




删除SSH服务器对应的公钥(登录过的才有,才能删除)
$ ssh-keygen -R 服务器IP地址
$ ssh-keygen -R root@192.168.31.178
// 第一次连接 SHA256:xxx (xxx是公钥的哈希值)
$ ssh root@192.168.31.178

如果第一次登录就被攻击了呢?
第一次登录 直接和 服务对比,用肉眼去看

查看公钥 :
$ cat known_hosts

划出来的 公钥 保存在Mac
$ ssh root@192.168.31.17
iPhone:~ root# cd /etc/ssh/
iPhone:/etc/ssh root# ls -l //--> ssh_host_rsa_key.pub
iPhone:/etc/ssh root# cat ssh_host_rsa_key.pub

-
004--SSH公钥登陆(免密登陆).wmv
$ ssh root@192.168.31.17



$ ssh-keygen //生成一对 公钥、私钥 ,id_rsa:私钥,id_rsa.pub:公钥
$ ls
$ ssh-copy-id root@192.168.31.178
$ ssh root@192.168.31.178
iPhone:~ root# ls
iPhone:~ root# cd ~/.ssh/
iPhone:~ root# cat authorised_keys
iPhone:~ root# rm authorised_keys //删除后 再去登录 就需要密码了
-
005--usbl连接.wmv //------------------------------------------------------------
$ ssh -p 22 root@192.168.31.178

这个脚本是做 映射的!映射到USB连接的手机!

//监听本地(本机Mac)的12345,只要监听到,就给手机的22 端口发数据
python tcprelay-py -t 22:12345

// 把 python-client 文件夹 移入 ZMshell 脚本文件夹内

login.sh --> cylogin.sh // 可以修改名称


//映射本地端口
$ python /Users/zhangmeng/ZMshell/python-client/tcprelay.py -t 22:12345

5.1、拷贝login.sh 文件,复制,改名为 usbConnect.sh
5.2、编辑此文件:删掉原内容,拷贝此命令到 此文件内
(命令为:python /Users/zhangmeng/ZMshell/python-client/tcprelay.py -t 22:12345)

$ sh usbConnect.sh //命令运行脚本,通过USB连接手机
5.3、拷贝usbConnect.sh 文件,复制,改名为 usbLogin.sh
// 下面登录连接会报错
$ ssh root@localhost -p 12345
$ ssh root@127.0.0.1


// 解决方案

5.4、编辑此文件(usbLogin.sh):删掉原内容,拷贝此命令到 此文件内
(命令为:ssh root@localhost -p 12345)
5.5、关闭终端,保存脚本
5.6、重新运行终端
$ sh usbConnect.sh
$ sh usbLogin.sh

//还是报错,解决方案:删除 localhost对应的 key
$ vim /Users/zhangmeng/.ssh/known_hosts // 编辑 hosts 删掉 localhost


$ sh usbLogin.sh //重新登录 并重新保存 key
5.7、编辑此文件(usbLogin.sh):修改内容命令为:ssh root@127.0.0.1 -p 12345
$ sh usbLogin.sh //重新登录,也成功了! 原因:公钥保存了,并没有改变
5.8、换一个手机
$ sh usbLogin.sh //重新登录,登录失败了!
$ vim /Users/zhangmeng/.ssh/known_hosts // 编辑 hosts 删掉 127.0.0.1
$ sh usbLogin.sh //重新登录,登录成功了!
默认密码 pwd: alpine
1.怎么样才能出现中间人攻击???
答:同样IP 不一样的公钥!!
2.本地只能保存一个公钥吗??
答:不止一个
3.本地一个IP:端口 只能保存一个公钥吗?
答:1个

$ cd ~/.ssh
$ ~/.ssh ls
$ ~/.ssh cat known_hosts

箭头处:只有端口号的 端口是 22
-
006--文件拷贝.wmv //----------------------------------------
-
6.1

$ sh usbLogin.sh //重新登录
$ touch 123.txt
$ ls
$ scp 123.txt root@192.168.31.178:~/ // 通过WiFi 拷贝
$ ssh root@192.168.31.178
$ cd / //到用户目录
$ cd ~/ //到电脑的根目录
$ rm 123.txt
-
6.2
$ cd Desktop
$ scp -P 12345 123.txt root@localhost:~/ // 把 12345 拷贝到 123.txt 文本内,通过映射 USB 传输数据
-
007--应用瘦身.wmv //----------------

//安装 越狱版:腾讯视频



// 剥离架构 应用瘦身
$ lipo live4iphone -thin arm64 -output arm64_live4 //166M --> 64M
创建文件夹 PayLoad,arm64_live4 放入PayLoad文件内,
$ zip -ry TenXunLive.ipa PayLoad //64M --> 47M

重新安装 TenXunLive.ipa //安装成功 --> 94.5 M 非越狱手机,用重签名安装

总结:
iOS 下有两个用户
- root 最高权限的用户 $HOME:/var/root
- 还有一个 mobile $HOME: /var/mobile
修改ssh登录密码
- passwd 输入两次新密码
SSH
SSH是一种网络协议.用于计算机之间的加密登录!
openSSH
openSSH其中一种软件.
SSH通讯过程

中间人攻击(Man-in-the-MiddleAttack,简称“MITM攻击”)
预防中间人攻击最有效的方法就是验证 公钥是不是服务器的!!
如果是公开的SSH服务器,一般会将公钥的哈希值 公布在网站上!!
SSH使用公钥登录
除了使用密码登录,也可以免密码登录!
所谓的"公钥登录",原理:
1.Mac电脑将自己的公钥发给远程的手机
2.手机随机的生成一段字符串,发给Mac电脑.
3.Mac利用私钥加密字符串!
4.手机利用公钥解密字符串!
如果还要输入密码的话,设置文件的权限! chmod 755
USB
SSH的默认端口是22
usbmuxd 在iOS和Mac上都是自带的!
通过openSSH连接(登录)手机
$ssh 用户名@用户服务器地址
删除SSH服务器对应的公钥
$ssh-keygen -R 服务器IP地址
网友评论