美文网首页
iOS逆向-设备ssh免密登录

iOS逆向-设备ssh免密登录

作者: X先生_未知数的X | 来源:发表于2023-09-04 08:39 被阅读0次

    iOS逆向-设备ssh免密登录 | 继刚的博客 (madordie.github.io)

    前提条件

    • 已越狱设备
    • 越狱设备安装OpenSSH(⚠️记得修改默认的’alpine’登录密码)
    • 电脑和设备同局域网。(我这里设备IP:10.11.12.13,并且设置成静态IP了😂)

    步骤

    生成RSA证书

    我这里生成的证书为:ipad,可自己需要定义。(注意如果直接回车会覆盖~/.ssh/id_rsa

    执行命令ssh-keygen,如下:

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-gutter-background); color: var(--highlight-gutter-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px; position: relative; border: 0px; text-align: right;">1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    </pre>

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-background); color: var(--highlight-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px 0px 10px 10px; position: relative; border: 0px; width: 582.156px;">cd ~/.ssh/ ssh-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/Madordie/.ssh/id_rsa): ipad
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in ipad.
    Your public key has been saved in ipad.pub.
    The key fingerprint is:
    SHA256:GpQBeAf+oqUzWlUhtItDcVyVFz2wd0EcIgD+BZLPK8U Madordie@Bingo.local
    The key's randomart image is:
    +---[RSA 2048]----+
    | .++++o++.o+. |
    | .+o+o=...oo... |
    | ..o.=+ .o ... |
    | . . = .E. . . |
    | o = o.S. |
    | * ..o. |
    | * .. |
    | o o |
    |. |
    +----[SHA256]-----+

    $ ls ~/.ssh/ipad*
    /Users/Madordie/.ssh/ipad /Users/Madordie/.ssh/ipad.pub
    </pre>

    |

    将公钥推送至越狱设备

    默认是没有~/.ssh目录的,暂时放置在/var/root下。

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-gutter-background); color: var(--highlight-gutter-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px; position: relative; border: 0px; text-align: right;">1
    </pre>

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-background); color: var(--highlight-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px 0px 10px 10px; position: relative; border: 0px; width: 396.812px;">$ scp ~/.ssh/ipad.pub root@10.11.12.13:/var/root
    </pre>

    |

    scp 默认端口为22 如果需要自定义端口可以在路径前添加-P 端口号参数。

    配置本机~/.ssh/config文件

    使用顺手的工具编辑~/.ssh/config文件。(没有就新建一个啦~

    按照如下格式填写。默认ssh登录端口为22可以不写。

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-gutter-background); color: var(--highlight-gutter-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px; position: relative; border: 0px; text-align: right;">1
    2
    3
    4
    5
    6
    </pre>

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-background); color: var(--highlight-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px 0px 10px 10px; position: relative; border: 0px; width: 316.227px;">Host ipad
    Hostname 10.11.12.13
    User root
    Port 22
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/ipad
    </pre>

    |

    配置越狱设备

    先用ssh root@10.11.12.13登录进设备(如果你没有修改密码那么默认是alpine,这个在OpenSSH上)。刚才我们将ipad.pub通过scp放在了/var/root下。

    一般情况下/var/root/.ssh是不存在的,使用命令mkdir -p /var/root/.ssh即可创建。

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-gutter-background); color: var(--highlight-gutter-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px; position: relative; border: 0px; text-align: right;">1
    </pre>

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-background); color: var(--highlight-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px 0px 10px 10px; position: relative; border: 0px; width: 396.812px;">$ cat ipad.pub >> /var/root/.ssh/authorized_keys
    </pre>

    |

    然后强迫症的可以使用rm -rf ipad.pub删除啦~

    对了,退出ssh登录的设备使用:

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-gutter-background); color: var(--highlight-gutter-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px; position: relative; border: 0px; text-align: right;">1
    2
    3
    </pre>

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-background); color: var(--highlight-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px 0px 10px 10px; position: relative; border: 0px; width: 275.93px;">$ exit
    logout
    Connection to 10.11.12.13 closed.
    </pre>

    |

    赶紧测试一下远程登录效果

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-gutter-background); color: var(--highlight-gutter-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px; position: relative; border: 0px; text-align: right;">1
    </pre>

    |

    <pre style="font-family: consolas, Menlo, monospace, "PingFang SC", "Microsoft YaHei"; font-size: 1em; background: var(--highlight-background); color: var(--highlight-foreground); line-height: 1.6; margin: 0px; overflow: auto; padding: 10px 0px 10px 10px; position: relative; border: 0px; width: 90.5938px;">$ ssh ipad
    </pre>

    |

    然后你会发现你已经完成了免密码登录越狱设备。

    总结

    其实这并不是只有越狱iOS设备才能使用的免登录,而是ssh所支持的。用途也很方便~

    PS. 这里面的IP地址(10.11.12.13) 是你设备的IP。如果超时的话或者ping不通或者网速比较差的话,可以采用usbmux方案进行,文档已相当详细,此处不再赘述。

    相关文章

      网友评论

          本文标题:iOS逆向-设备ssh免密登录

          本文链接:https://www.haomeiwen.com/subject/rowqvdtx.html