0%

小米路由器开启ssh和外网访问.md

基础信息

  • 型号: 小米路由器4A千兆版
  • 系统ROM版本: MiWiFi 稳定版 2.30.500

操作步骤

操作机器ip要小

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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# 1. 找一台内网机器能运行python3
ssh 192.168.31.4(nas虚拟机)
git clone https://github.com/passerma/OpenWRTInvasion
cd OpenWRTInvasion
pip3 install -r requirements.txt # Install requirements
python3 remote_command_execution_vulnerability.py # Run the script
# 2. 输入路由器ip和登录密码获取到stok,稍等一会儿就能执行telnet了
telnet 192.168.31.1

# 默认用户名密码为root/root,登录后建议修改

# 3. 修改miwificonfig文件,使得外网可以访问web界面
vim /etc/nginx/miwifi-webinitrd.conf
# 在 set $finalvar "$canproxy $isluci"; 前面添加 set $isluci "1";
set $isluci "1";
set $finalvar "$canproxy $isluci";
# 4. 重新加载配置
nginx -s reload
# 5.修改防火墙规则暴露ssh端口和web端口
vim /etc/config/firewall
# 6. 添加 ssh 和web端口转发
config redirect 'MIWEB'
option src 'wan'
option src_dport '1314'
option dest_ip '192.168.31.1'
option name 'WEB'
option ftype '1'
option dest_port '80'
option proto 'tcp'

config redirect 'MISSH'
option src 'wan'
option src_dport '13142'
option dest_ip '192.168.31.1'
option name 'ssh'
option ftype '1'
option dest_port '22'
option proto 'tcp'

# 7. 重启防火墙
/etc/init.d/firewall restart
# 8. 如果路由器上方还有光猫,则需要配置端口转发到路由器lan口对应端口上。