FRP SSH 代理遭遇暴力攻击事件记录

Ezra Hacking UNIX/Linux

日期: 2026-05-11

涉及组件: frp (frpc + frps), OpenSSH

拓扑: 本机 (frpc) → frps (3x.xxx.xxx.xx) → 外部用户通过 xxx2 端口访问 SSH


事件经过

1. 初始症状

用户突然无法通过 frp 的 xxx2 端口 SSH 连接到本机。frpc 服务显示正常运行,代理注册成功,但连接被立即关闭。

frpc 状态: active (running)
代理注册: [ssh-xxe] [proxmox-pve] 均显示 start proxy success
本地 SSH: 127.0.0.1:22 正常监听

2. 发现异常连接

在 frps 服务器日志中发现 IP 172.239.26.194(Linode 数据中心 IP)在极短时间内对 xxx2 端口发起大量连接:

May 11 20:13:18 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38148]
May 11 20:13:18 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38154]
May 11 20:13:18 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:33318]
May 11 20:13:18 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38166]
May 11 20:13:19 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38190]
May 11 20:13:19 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38192]
May 11 20:13:19 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38198]
May 11 20:13:19 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38180]
May 11 20:13:19 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38208]
May 11 20:13:19 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38220]
May 11 20:13:19 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38224]
May 11 20:13:20 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38242]
May 11 20:13:20 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38244]
May 11 20:13:20 Hxxxxxxx frps[92977]: [ssh-xxe] get a user connection [172.239.26.194:38246]

2 秒内 14 个新连接,端口号快速递增,典型的自动化扫描行为。

同时在 frps 上查看连接状态:

ESTAB  0  0  [::ffff:1xx.xx.xxx.xx0]:xxx2  [::ffff:172.239.26.194]:38410
ESTAB  0  0  [::ffff:1xx.xx.xxx.xx0]:xxx2  [::ffff:172.239.26.194]:38520
ESTAB  0  0  [::ffff:1xx.xx.xxx.xx0]:xxx2  [::ffff:172.239.26.194]:38482
FIN-WAIT-1  0  27  [::ffff:1xx.xx.xxx.xx0]:xxx2  [::ffff:172.239.26.194]:46972
ESTAB  0  0  [::ffff:1xx.xx.xxx.xx0]:xxx2  [::ffff:172.239.26.194]:38488
ESTAB  0  0  [::ffff:1xx.xx.xxx.xx0]:xxx2  [::ffff:172.239.26.194]:46978

3. SSH 启动槽被占满

在 frpc 端查看 sshd 状态,发现大量来自 127.0.0.1 的未完成认证连接:

sshd: /usr/sbin/sshd -D [listener] 21 of 10-100 startups
├─ 43  sshd-session/sshd-auth 子进程
├─ 大量 "unknown [priv]" / "unknown [net]" 状态
└─ 用户名包括: robot, roosevelt, vagrant, tomcat, zhaomj, testbot, teamspeak3, root

sshd 日志显示暴力破解详情:

May 11 20:24:26 pve sshd-session[427445]: pam_unix(sshd:auth): authentication failure; rhost=127.0.0.1
May 11 20:24:26 pve sshd-session[427445]: pam_winbind(sshd:auth): user 'robot' denied access
May 11 20:24:26 pve sshd-session[427366]: Disconnected from invalid user robot 127.0.0.1 port 44994 [preauth]
May 11 20:24:33 pve sshd-session[427491]: Disconnected from authenticating user root 127.0.0.1 port 35066 [preauth]
May 11 20:26:35 pve sshd[416571]: drop connection #14 from [127.0.0.1]:39540 on [127.0.0.1]:22 Maxstartups
May 11 20:26:35 pve sshd-session[428622]: Failed password for root from 127.0.0.1 port 52414 ssh2

关键证据:drop connection #14 ... Maxstartups — sshd 因并发未完成认证连接过多(达到 MaxStartups 限制),开始拒绝新连接,包括正常用户的连接。

4. 攻击路径分析

攻击者 (172.239.26.194, Linode)
  → 扫描到 frps (3x.xxx.xxx.xx) 的 xxx2 端口
    → 通过 frp TCP 代理隧道
      → 到达 frpc 本机 127.0.0.1:22
        → 暴力破解 SSH(大量用户名/密码组合)
          → 占满 sshd MaxStartups
            → 正常连接被拒绝

攻击者使用的用户名字典(部分):

  • root(最常见目标)
  • robot, roosevelt, vagrant, tomcat, zhaomj, testbot, teamspeak3

这些均为自动化扫描工具的典型字典用户名。

5. frps 服务器间歇性不可用

frpc 日志还显示 frps 服务端多次出现 connection refused

May 11 20:01:20 frpc: connect to server error: dial tcp 3x.xxx.xxx.xx:xxx0: connect: connection refused
May 11 20:06:53 frpc: connect to server error: dial tcp 3x.xxx.xxx.xx:xxx0: connect: connection refused
May 11 20:08:21 frpc: connect to server error: dial tcp 3x.xxx.xxx.xx:xxx0: connect: connection refused
May 11 20:28:46 frpc: connect to server error: dial tcp 3x.xxx.xxx.xx:xxx0: connect: connection refused

frps 可能因大量并发连接导致负载过高或服务崩溃重启。

6. 解决过程

  1. 在 frps 上用 ufw deny from 172.239.26.194 封禁攻击 IP — 效果有限,因为连接已建立
  2. 在 frps 上重启 frps 服务 — 清理残留连接,但攻击很快恢复
  3. 在本机调整 sshd 配置(PermitRootLogin no, MaxStartups, PerSourceMaxStartups)— 缓解但未根治
  4. 最终方案:在 frpc 端暂时禁用 ssh-xxe 代理(注释掉配置并重启 frpc),断开所有攻击连接后再重新启用 — 成功恢复

7. 后续加固措施

  • PermitRootLogin no — 禁止 root 登录
  • LoginGraceTime 30 — 缩短认证超时
  • MaxStartups 3:50:10 — 限制并发未认证连接
  • PerSourceMaxStartups 2 — 限制单 IP 并发
  • 计划配置 fail2ban 在 frps 服务器上监控 frps 日志,自动封禁攻击者真实 IP

结论

这是一次通过暴露的 frp TCP 代理端口对 SSH 服务进行的持续自动化暴力破解攻击。攻击源来自 Linode 云服务器 IP 172.239.26.194。攻击导致 sshd 的 MaxStartups 限制被触发,正常连接被拒绝。根本原因是 frp 代理的远程端口(xxx2)暴露在互联网上且没有任何访问控制或速率限制。