最近在干什么
最近被人问到怎么将自己电脑上的服务暴露到公网上,加上此前对内网穿透相关技术的了解。决定基于光猫的 IPV6 尝试一下。
经过尝试并结合网上的文章我发现小米路由器本身存在 IPV6 防火墙,所以这里主要介绍如何通过 ssh 登录路由器并关闭防火墙.
网上的文章有很多,但有些重点内容不注意就无法成功,所以这里做一个总结
有关使用移动宽带 IPV6 在公网暴露端口和服务看这里:传送门
获取 SSH 权限
其中的重点包括:
执行程序的电脑要通过网线连接到路由器不能使用 wifi
程序要在 Mac 或 Linux 环境下运行
要在 Windows 下运行需要借助 Docker 环境
程序运行第一次可能不成功,多试两次
我的路由器固件版本是 2.30.500 亲测这个版本成s功了
路由器重启后,已经开放的 ssh 端口会关闭,需要重新执行脚本
下载 OpenwrtInvasion 脚本,该脚本用于通过漏洞对官方固件开启 ssh
Github地址:https://github.com/acecilia/OpenWRTInvasion
执行命令的两种方式
Windows:
# 借助 Docker
# 构建一个包含程序所需运行环境的镜像
docker build -t openwrtinvasion https://github.com/acecilia/OpenWRTInvasion.git
# 使用这个镜像运行
docker run --network host -it openwrtinvasion
Mac or Linux:
# 需要 Python 环境
# 安装依赖
pip3 install -r requirements.txt
# 执行程序
python3 remote_command_execution_vulnerability.py
期间需要输入路由器地址,登录密码等信息
成功之后你可以通过以下方式登录到路由器
done! Now you can connect to the router using several options: (user: root, password: root)
* telnet 192.168.31.1
* ssh -oKexAlgorithms=+diffie-hellman-group-shal -oHostKeyAlgorithms=+ssh-rsa -c 3des-cbc -o UserKnownHostsFile=/dev/null root@192.168.31.1
* ftp: using a program like cyberduck
关闭防火墙
ip6tables -F
ip6tables -X
ip6tables -P INPUT ACCEPT
ip6tables -P OUTPUT ACCEPT
ip6tables -P FORWARD ACCEPT