Stabilize VIP pay against 504s and document the 129 incident.
Keep payjsapi off the event-loop/PB public path, harden triggerPay navigation, and add regression tests plus honeypot/security notes from the 2026-11-26 outage. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
60606e53a7
commit
88c028ea28
@ -11,12 +11,19 @@
|
||||
| LIVE / 拉黑 API(nomadmini) | `:8010` | `nomadmini/` ← `/opt/nomadmini` |
|
||||
| 支付后端 payjsapi | (pay 回调) | `payjsapi/` ← `/www/wwwroot/payjsapi` |
|
||||
| 埋点 vip-track | `:4011` | `vip-track/` ← `/opt/vip-track` |
|
||||
| HTTP/SSH 蜜罐(隔离) | 回环 `:4012` / 假 SSH `:2222` | `honeypot/` ← `/opt/hackrobot-honeypot` |
|
||||
| PocketBase | `:8090` | `pocketbase/`(`data.db` + schema,不含 storage 大文件) |
|
||||
|
||||
`apps/admin` = **admin.nomadro.cn**,**禁止**部署到 `admin.hackrobot.cn`。
|
||||
|
||||
VIP API 路由清单:`BACKEND_API_ROUTES.txt`(ops / pay / auth / vip)。
|
||||
|
||||
2026-11-26 支付阻塞修复、异常进程处理及回滚记录见 [支付与稳定性修复](docs/payment-stability-2026-11-26.md)。后端及前端已在本轮授权后发布,含手机浏览器表单导航与 303 收银台跳转修复。
|
||||
|
||||
同日服务器入侵取证、SSH 密钥加固、用户/IP 关联与证据索引见 [安全事件报告](docs/security/129-2026-11-26/安全事件报告.md)。129 已关闭 SSH 密码登录,本机使用 `ssh hackrobot-129`;`deploy/_ssh.py` 支持本机专用密钥和固定主机公钥。不要把历史拉黑用户直接认定为服务器入侵者。
|
||||
|
||||
HTTP/SSH 诱捕及每 5 分钟更新的全用户/IP 关联已部署,见 [蜜罐运行说明](honeypot/README.md)。已确认攻击源访问公网 22 时定向进入假 SSH;正常管理员仍使用真实密钥服务,蜜罐从不放行认证或执行命令。
|
||||
|
||||
## 同步(线上 → 本地)
|
||||
|
||||
```bash
|
||||
|
||||
@ -2,14 +2,22 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import paramiko
|
||||
from pathlib import Path
|
||||
|
||||
HOST, USER, PASS = "129.204.21.129", "ubuntu", "Xiao4669805"
|
||||
|
||||
|
||||
def connect() -> paramiko.SSHClient:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(HOST, username=USER, password=PASS, timeout=60, allow_agent=False, look_for_keys=False)
|
||||
pinned_hosts = Path.home() / ".ssh/hackrobot_129_known_hosts"
|
||||
if pinned_hosts.exists():
|
||||
c.load_host_keys(str(pinned_hosts))
|
||||
c.set_missing_host_key_policy(paramiko.RejectPolicy())
|
||||
else:
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
incident_key = Path.home() / ".ssh/hackrobot_129_incident_20261126_ed25519"
|
||||
auth = {"key_filename": str(incident_key)} if incident_key.exists() else {"password": PASS}
|
||||
c.connect(HOST, username=USER, timeout=60, allow_agent=False, look_for_keys=False, **auth)
|
||||
return c
|
||||
|
||||
|
||||
|
||||
@ -52,6 +52,24 @@ if [[ -d /www/wwwroot/payjsapi ]]; then
|
||||
--exclude='payjsapi/.env' --exclude='payjsapi/.env.local' payjsapi 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Honeypot code and isolation config; live decoy data and host keys stay in
|
||||
# /var/lib, with evidence separately archived under the root-only security dir.
|
||||
if [[ -d /opt/hackrobot-honeypot ]]; then
|
||||
tar -C /opt -czf "$DEST/hackrobot-honeypot-src.tgz" \
|
||||
--exclude='hackrobot-honeypot/deps' --exclude='hackrobot-honeypot/__pycache__' \
|
||||
hackrobot-honeypot
|
||||
mkdir -p "$DEST/honeypot-config"
|
||||
for config in /etc/systemd/system/hackrobot-honeypot* \
|
||||
/usr/local/sbin/hackrobot-security-firewall \
|
||||
/www/server/panel/vhost/nginx/00-hackrobot-honeypot-zones.conf \
|
||||
/www/server/panel/vhost/nginx/extension/vip.hackrobot.cn/honeypot-decoys.conf \
|
||||
/www/server/panel/vhost/nginx/extension/admin.hackrobot.cn/honeypot-decoys.conf; do
|
||||
if [[ -f "$config" ]]; then
|
||||
cp --parents "$config" "$DEST/honeypot-config/"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
# PocketBase schema + data.db (no storage blobs)
|
||||
if [[ -d /home/ubuntu/pb_data ]]; then
|
||||
mkdir -p "$DEST/pb"
|
||||
|
||||
65
apps/hackrobot/docs/payment-stability-2026-11-26.md
Normal file
65
apps/hackrobot/docs/payment-stability-2026-11-26.md
Normal file
@ -0,0 +1,65 @@
|
||||
# VIP 支付与服务器稳定性修复(2026-11-26)
|
||||
|
||||
范围仅限 `vip.hackrobot.cn` / `129.204.21.129`;未部署 Nomadro 站点、运营台或小程序。
|
||||
|
||||
## 已上线:支付后端
|
||||
|
||||
- 支付服务显式配置 `PB_INTERNAL_URL` / `POCKETBASE_INTERNAL_URL` 为 `http://127.0.0.1:8090`,避免绕公网连接同机 PocketBase。公开支付回调地址保持公网域名。
|
||||
- 同步数据库、订单查询和创建订单操作使用 FastAPI 工作线程,不再阻塞事件循环。工作线程并发限制为 8;VIP 查询缓存最多 2048 条。
|
||||
- 预热超时后不在事件循环中等待线程退出;PocketBase 首次认证加锁,仅在认证成功后发布客户端,失败允许重试。
|
||||
- 支付回调的业务处理在线程中执行,并加锁重新检查订单去重,保留验签、金额校验和权益处理流程。
|
||||
|
||||
日志中的一笔支付请求从 11:55:26 等待到 11:58:50 才开始处理。根因包括数据库公网连接超时和异步路由内执行同步网络操作。修复后微信 `/api/pay` 在一次外部测量中 0.516 秒返回 XorPay 收银台表单,金额为 298.00 元;故意传入的客户端 1 分定价未生效。PC 测量为 1.344 秒返回支付二维码页。
|
||||
|
||||
## 已发布:前端
|
||||
|
||||
`app/lib/triggerPay.ts` 将普通手机浏览器改为表单导航,避免将后端返回的收银台 HTML 当成 JSON 解析。所有使用共享 `triggerPay()` 的加入、报名按钮一起生效。身份查询最长等待 3 秒;浏览器禁用 localStorage 时仍可发起支付。待支付订单继续由服务端 cookie 保存。
|
||||
|
||||
`app/HomeClient.tsx` 调用同步更新,取消不再使用的 H5 fetch 回调。
|
||||
|
||||
用户本轮明确授权后已发布。最终 BUILD_ID 为 `MHv7ZyFfkagtO7KpYQGi6`,正式端口仍为 4007。另修复了手机收银台 307 重发 POST 的问题,改为 303 以 GET 打开收银台。
|
||||
|
||||
## 服务器异常进程
|
||||
|
||||
发现并终止 1 个在 `/dev/shm` 隐藏目录执行、建立约 2005 条外部 SSH 连接的 `ksmd` 扫描进程,以及 7 个伪装成 `[kworker/2:51S]` 的用户态 Perl 进程。真实内核线程不会执行 `/usr/bin/perl`。原始扫描程序已保存为无执行权限的证据,原路径也移除了执行权限。
|
||||
|
||||
取证目录位于 `/opt/hackrobot-backup/security/`,只保存到服务器,未下载凭据或向外传输。后续检查未见这些进程复活。清理后的采样 CPU 空闲率约 96–99%,1 分钟负载由 3.33 降为 0.80。未执行重启服务器、swapoff 或删除数据库。
|
||||
|
||||
这构成服务器入侵迹象。尚未完成入侵入口、全部持久化机制和系统文件完整性审计,不能据此认定主机可信或承诺永不宕机。应另行安排可信主机迁移/重建和相关凭据轮换。
|
||||
|
||||
## 验证与边界
|
||||
|
||||
- 隔离候选目录运行 4 项后端回归测试:数据库阻塞时健康检查及收银台保持响应;无效回调不能开通权益;并发重复通知仅处理一次;数据库认证失败能重试。
|
||||
- 本地 6 项支付入口测试:PC、手机浏览器、微信内,各覆盖存储可用/被禁用场景;完整 VIP TypeScript 检查通过。
|
||||
- 后端部署监测首页 3 次均为 200;后续外部首页检查为 200,约 0.34–0.39 秒;本机 Nginx HTTPS 首页约 0.04 秒。
|
||||
- 同机服务健康检查约 2 毫秒,未触发自动重启。服务器访问自身公网域名仍出现过一次 5 秒网络超时,同时外部访问及本机 Nginx 正常;业务内部连接应继续使用回环地址。
|
||||
- 已验证接口和表单,未在真实微信客户端完成付款、收银台拉起及支付后权益的人工端到端验证。普通手机浏览器的线上前端修复已发布。
|
||||
|
||||
本地仓库根目录执行:
|
||||
|
||||
```powershell
|
||||
node apps/hackrobot/vip/tests/trigger-pay.cjs
|
||||
node node_modules/typescript/bin/tsc -p apps/hackrobot/vip/tsconfig.json --noEmit --incremental false
|
||||
```
|
||||
|
||||
具备支付服务依赖的环境,在 `apps/hackrobot/payjsapi` 下执行:
|
||||
|
||||
```bash
|
||||
python3 -m unittest discover -s tests -v
|
||||
```
|
||||
|
||||
## 备份与后端回滚
|
||||
|
||||
发版前完整快照:`/opt/hackrobot-backup/snapshots/20261126_120007_pre_payment_stability_20261126/`。
|
||||
|
||||
该快照的 `payment-stability-rollback/` 目录额外保存原始 `app/main.py`、`app/routers/nomadvip.py`、`app/sdk/pocketbase.py` 和原始 `.env.local`,目录仅 root 可访问。需要回滚时将这四个文件恢复至 `/www/wwwroot/payjsapi/` 对应位置,再重启 `payjsapi.service` 并验证健康检查及首页。不要回滚或覆盖 VIP `.next`、其他域名或运营台。
|
||||
|
||||
## 前端发布与验证
|
||||
|
||||
本地完成生产构建和类型检查,36 页生成成功;服务器未运行构建。新版本先在回环端口 4008 启动并限制资源,验证后临时交接 Nginx,再替换正式 4007 的产物并恢复原代理配置。备用进程已停止,旧静态资源保留以兼容已打开页面。
|
||||
|
||||
303 修复后的最终切换,12 次外部首页检测全部为 200,约 0.34–0.38 秒。公开域名 Chromium 检测 PC、H5、微信 UA 首页及课程支付入口均通过,无页面 JavaScript 错误。测试在外部网关前截获导航,不代表真实微信客户端完成付款。
|
||||
|
||||
前端快照:`/opt/hackrobot-backup/snapshots/20261126_123011_pre_vip_frontend_20261126/`。`frontend-rollout/next.original` 保留本轮前的完整线上产物;`frontend-rollout-v2/next.original` 保留第一次发布产物。各目录保存对应源码、Nginx 原配置和发布记录。
|
||||
|
||||
新增回归测试(仓库根目录):`node apps/hackrobot/vip/tests/pay-redirect.cjs`,验证 303、订单 cookie 和服务端定价。服务器后续安全加固与用户关联见 [安全事件报告](security/129-2026-11-26/安全事件报告.md)。
|
||||
@ -0,0 +1,23 @@
|
||||
{
|
||||
"user-ip-correlation.csv": "cd2e39009e7f97ca4c469e2115917a0a63f0d3625efa248dd9b226db085e15c3",
|
||||
"\u4e91\u5382\u5546\u65e5\u5fd7\u4fdd\u5168\u7533\u8bf7.md": "57c7f10a1f3b3aedb1655bd20b25437444bad0d03f6761e8d5d99e0fe60ad25a",
|
||||
"\u5b89\u5168\u4e8b\u4ef6\u62a5\u544a.md": "fa7170d74bb38fd2228c359d29a8982f7093dc6f54c927ad7c7e8a299bc85b28",
|
||||
"evidence/account-creation-evidence.txt": "db23fd2a3e58a4c78a8b343c5bfb3288b18858e1f1cc0de8331ec4f393f3de3b",
|
||||
"evidence/collection-notes.json": "64f3099a653b3ed1fbca741c03d59d57235eefbfa1c5ab9e942af514d52e12b2",
|
||||
"evidence/confirmed-backdoor-logins.json": "7a6b9b50a313386b1bb4d78e30547b8f9d1943e61e2840d0b353546ad9b432de",
|
||||
"evidence/dependency-advisories.json": "76b6971a546b946d5f4b8c848b2b080eb3871ef986af0371bd4e962d5ab0b065",
|
||||
"evidence/EXPORT_SHA256.json": "a6fd113c1c9a0c0d5bb1754d2972081aa68eb3abe692643aac55e5d3bbc97aea",
|
||||
"evidence/hardening-account-ssh.json": "ec189b0034b86bf3ba1f2d39a228e441482ec87950c2a0163f692461142a3932",
|
||||
"evidence/hardening-edge.json": "f114ea05938d133fc8187b491eedfc7d2c00bfda8e4d5a2c3b6393d160d4a458",
|
||||
"evidence/hardening-firewall.json": "a5c8a0281cdc2ec906e2f1e7c76a274d389a115a737ed551f3d619aefca6e6c7",
|
||||
"evidence/malware-file-hashes.json": "ee217b757e8c3f478d06bc0e4ee5852a5a35fbbaf6e0af761fc0d457a10febfc",
|
||||
"evidence/malware-static-hosts.json": "4c5ca269031a66ced3a44a1cddfd3a2c2a14dedab494b17f48a62ce8e08891f8",
|
||||
"evidence/monitor-latest.json": "786df39e2eb767a8839f79a2d170d64fef651e4e13c8abc2254caa824a91d771",
|
||||
"evidence/rdap-attribution.json": "6fe20308364dc6ad586a1f123deba14aab21bcab35eccd0ad430a0fbc0139c4f",
|
||||
"evidence/SHA256SUMS.json": "1db6dbbeef6d2b60b199d2200db9115db5b2fcc694128a2d251395b942d9addf",
|
||||
"evidence/summary.json": "3d1db857883be3a54c329225f89db60035c6c0f36dd7c1ca0a7723b08c42a24a",
|
||||
"evidence/target-user-records.json": "5956aa4131abdc7a4ce4541162dd04c236a90a8f90a0ed4f834da9ee18383afc",
|
||||
"evidence/user-ip-correlation.json": "0a1c268de420a8721dd66815b64ae608bff185ca6be234601d2f05896a853829",
|
||||
"evidence/user-ip-event-evidence.json": "37a66c465b26f6ee25e4e7a7f51a833dbcd0fec154b8b14e257ef747d4400b86",
|
||||
"evidence/web-entry-windows.summary.json": "5c918fd6184ad8954fd021251a9066ea4da8719e347a4f24e261dd81237368e8"
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
{
|
||||
"account-creation-evidence.txt": "db23fd2a3e58a4c78a8b343c5bfb3288b18858e1f1cc0de8331ec4f393f3de3b",
|
||||
"collection-notes.json": "64f3099a653b3ed1fbca741c03d59d57235eefbfa1c5ab9e942af514d52e12b2",
|
||||
"confirmed-backdoor-logins.json": "7a6b9b50a313386b1bb4d78e30547b8f9d1943e61e2840d0b353546ad9b432de",
|
||||
"dependency-advisories.json": "76b6971a546b946d5f4b8c848b2b080eb3871ef986af0371bd4e962d5ab0b065",
|
||||
"hardening-account-ssh.json": "ec189b0034b86bf3ba1f2d39a228e441482ec87950c2a0163f692461142a3932",
|
||||
"hardening-edge.json": "f114ea05938d133fc8187b491eedfc7d2c00bfda8e4d5a2c3b6393d160d4a458",
|
||||
"hardening-firewall.json": "a5c8a0281cdc2ec906e2f1e7c76a274d389a115a737ed551f3d619aefca6e6c7",
|
||||
"malware-file-hashes.json": "ee217b757e8c3f478d06bc0e4ee5852a5a35fbbaf6e0af761fc0d457a10febfc",
|
||||
"malware-static-hosts.json": "4c5ca269031a66ced3a44a1cddfd3a2c2a14dedab494b17f48a62ce8e08891f8",
|
||||
"monitor-latest.json": "786df39e2eb767a8839f79a2d170d64fef651e4e13c8abc2254caa824a91d771",
|
||||
"rdap-attribution.json": "6fe20308364dc6ad586a1f123deba14aab21bcab35eccd0ad430a0fbc0139c4f",
|
||||
"SHA256SUMS.json": "1db6dbbeef6d2b60b199d2200db9115db5b2fcc694128a2d251395b942d9addf",
|
||||
"summary.json": "3d1db857883be3a54c329225f89db60035c6c0f36dd7c1ca0a7723b08c42a24a",
|
||||
"target-user-records.json": "5956aa4131abdc7a4ce4541162dd04c236a90a8f90a0ed4f834da9ee18383afc",
|
||||
"user-ip-correlation.json": "0a1c268de420a8721dd66815b64ae608bff185ca6be234601d2f05896a853829",
|
||||
"user-ip-event-evidence.json": "37a66c465b26f6ee25e4e7a7f51a833dbcd0fec154b8b14e257ef747d4400b86",
|
||||
"web-entry-windows.summary.json": "5c918fd6184ad8954fd021251a9066ea4da8719e347a4f24e261dd81237368e8"
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
{
|
||||
"/etc/passwd": "c1719a136aae6a4269e59d2a18648f8301e04c844aae1f926140f6ae1da6f2ab",
|
||||
"/etc/shadow": "32e5e550ffdf331f19f1be12d36f7691b7521fc9cb5b7390fedca53d48551b95",
|
||||
"/etc/group": "d8d3637788ea88dc7506d4de6381412ca723f813352b6ec8c92fb6d0b9d74bfb",
|
||||
"/etc/gshadow": "c1c755b4878d2a59d4f403d13036e0af0dc0c4c7463f54e59140e1e2bcbe82f1",
|
||||
"/etc/ssh/sshd_config": "8343d6a4d67b3c9461453b968e4cb5c0c23ce04c22e31693444e556b7b8b2e42",
|
||||
"/var/log/wtmp": "5feb38dcbb04f0b0db73b100955556a304c040ee11dd7be95b7d26d6e276456f",
|
||||
"/var/log/btmp": "5361d87f04c6ee076db4ddb5bb68d20e9fbd5f74ed2e4fb12751660e330d7b7b",
|
||||
"/var/log/lastlog": "b3fb0f7222cfef730ad1f78626a5a65638abc795a2485c708be4c7f94ef796e4",
|
||||
"/root/.bash_history": "42afe7bc8efe3a0e347a51f5ba319a373bc5a6fcc786821c8c0b5d41d54f729b",
|
||||
"/var/log/auth.log.4.gz": "23a7df7b687f4057fb9bdb145374e2c39af70c809ae72b1dd5f13b756d18f84c",
|
||||
"/var/log/auth.log.1": "7439242498a8645904893d4badf30c4f114f3d108b8b30dfb0384f485afa40b9",
|
||||
"/var/log/auth.log.2.gz": "7fe279c5514618285bb51302a15335fe2a1d9ea2db2946111578d1affb80094f",
|
||||
"/var/log/auth.log": "b81b4553bb3de33e63739fca8006e7d14011aefb1014b73ee94a98da98fdb2cd",
|
||||
"/var/log/auth.log.3.gz": "b5a35ce7308bd63b471207de8de77190894ac241d09223fa061d70d1aa6420e5",
|
||||
"/etc/ssh/sshd_config.d/50-cloud-init.conf": "6bf43c7543d384fe7c3442bd97b1c91b9da62b51521184b6c1e421a7ef8bac1d",
|
||||
"/etc/sudoers.d/admini": "6685c6973d58ab6641b08b82702fe072dcc6a241ce50f451a3d810a8fb1c16aa",
|
||||
"/etc/sudoers.d/README": "b428c9b673c3c806370f2aa28a98293a9cb578c70c3a8a2d1a39031861b3dbd8",
|
||||
"/etc/sudoers.d/90-cloud-init-users": "dcde3fa3c1e59fde27a275753a3b7950df2b5541c07298c6c57713551ce2e3e6",
|
||||
"/etc/sudoers.d/99-pakchoi": "5e2fbebb6a4a0d7231e14fa90beca23982b2a2ae0d98c37a2cb57a2f5fa35d59",
|
||||
"/var/spool/cron/crontabs/root": "56f34d1b188abc6a4a998afd788e5e8ea38e35d75193609ba8517f8d3bfb2924",
|
||||
"/etc/systemd/system/sys-health.service": "dd08830a29b90c689473264bcc6ebe24b3a96c8dd25fe8a4a95e1c3241c405c2",
|
||||
"/etc/systemd/system/sys-health.timer": "d9db7f9ff91aedd921a53fc102529d7ab21c3079bd46dd206901b56eae92b45f",
|
||||
"raw/processes.txt": "eba24f5e879d54b65874a9849bfedd2a6e75bfd28324678d490e0cfb1cd56bf6",
|
||||
"raw/connections.txt": "8bed72005bcd80fbd7cba0d530296523109666e862a80401a5df5b697850c57d",
|
||||
"raw/listeners.txt": "c6d5283989ce9373778b769eb816f168962b8e3fa9dce2c1cf901e2d3ba8b897",
|
||||
"raw/iptables.txt": "eb30dadb4887a5083c308abe0f9ad965485ed7afebb198876382403edaa93bfe",
|
||||
"raw/ip6tables.txt": "8b142a4ef8fbd77b16bc1481ea30e736cbc389336ff664f96ff9d54254525e91",
|
||||
"raw/docker-inspect.txt": "9e3f3cf55bf44aba6fe3036d00b03aa594d6ca59d0db5fe9e075611e1f277310",
|
||||
"raw/docker-list.txt": "1b3b9e9cdc3f432a1252e12fea203b06ec96af8a904535dcbd70c2758df7fe4a",
|
||||
"raw/sshd-effective.txt": "f10f416a7a089101d734b7d6d3c7b2b14efb3b9120bf7404380481ad8329dae5"
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
2026-11-12T22:36:16.033928+08:00 localhost useradd[1727416]: new group: name=pakchoi, GID=7891
|
||||
2026-11-12T22:36:16.034053+08:00 localhost useradd[1727416]: new user: name=pakchoi, UID=1005, GID=7891, home=/home/pakchoi, shell=/bin/bash, from=none
|
||||
2026-11-12T22:36:16.134366+08:00 localhost chpasswd[1727425]: pam_unix(chpasswd:chauthtok): password changed for pakchoi
|
||||
2026-11-12T22:36:16.178979+08:00 localhost usermod[1727429]: add 'pakchoi' to group 'sudo'
|
||||
2026-11-12T22:36:16.179400+08:00 localhost usermod[1727429]: add 'pakchoi' to shadow group 'sudo'
|
||||
2026-11-12T22:36:16.208600+08:00 localhost usermod[1727437]: add 'pakchoi' to group 'adm'
|
||||
2026-11-12T22:36:16.210394+08:00 localhost usermod[1727437]: add 'pakchoi' to shadow group 'adm'
|
||||
2026-11-12T22:36:16.246986+08:00 localhost usermod[1727444]: add 'pakchoi' to group 'root'
|
||||
2026-11-12T22:36:16.247609+08:00 localhost usermod[1727444]: add 'pakchoi' to shadow group 'root'
|
||||
2026-11-12T22:36:19.704406+08:00 localhost useradd[1727538]: failed adding user 'pakchoi', exit code: 9
|
||||
2026-11-12T22:36:19.737364+08:00 localhost chpasswd[1727540]: pam_unix(chpasswd:chauthtok): password changed for pakchoi
|
||||
2026-11-12T22:36:19.747203+08:00 localhost useradd[1727544]: failed adding user 'pakchoi', exit code: 9
|
||||
2026-11-12T22:36:19.777710+08:00 localhost chpasswd[1727546]: pam_unix(chpasswd:chauthtok): password changed for pakchoi
|
||||
2026-11-13T04:50:01.299278+08:00 localhost chpasswd[1920139]: pam_unix(chpasswd:chauthtok): password changed for pakchoi
|
||||
2026-11-13T04:50:02.601936+08:00 localhost useradd[1920225]: failed adding user 'pakchoi', exit code: 9
|
||||
2026-11-13T04:50:02.633015+08:00 localhost chpasswd[1920227]: pam_unix(chpasswd:chauthtok): password changed for pakchoi
|
||||
2026-11-13T04:50:02.640843+08:00 localhost useradd[1920231]: failed adding user 'pakchoi', exit code: 9
|
||||
2026-11-13T04:50:02.669881+08:00 localhost chpasswd[1920233]: pam_unix(chpasswd:chauthtok): password changed for pakchoi
|
||||
@ -0,0 +1,8 @@
|
||||
{
|
||||
"collected_at": "2026-11-26 13:09:52 +0800",
|
||||
"timezone": "Asia/Shanghai UTC+08:00",
|
||||
"raw_evidence_dir": "/opt/hackrobot-backup/security/incident-20261126/raw",
|
||||
"raw_shadow_and_history_excluded_from_export": true,
|
||||
"malware_samples_excluded_from_export": true,
|
||||
"root_compromise_limits_log_trust": true
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
[
|
||||
{
|
||||
"time": "2026-11-22T18:57:58.735396+08:00",
|
||||
"method": "password",
|
||||
"user": "pakchoi",
|
||||
"ip": "101.33.68.140",
|
||||
"port": 60618,
|
||||
"source": "auth.log",
|
||||
"raw_log_line": "2026-11-22T18:57:58.735396+08:00 localhost sshd[1149038]: Accepted password for pakchoi from 101.33.68.140 port 60618 ssh2"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-23T15:03:20.788456+08:00",
|
||||
"method": "password",
|
||||
"user": "pakchoi",
|
||||
"ip": "101.33.196.102",
|
||||
"port": 40454,
|
||||
"source": "auth.log",
|
||||
"raw_log_line": "2026-11-23T15:03:20.788456+08:00 localhost sshd[1819909]: Accepted password for pakchoi from 101.33.196.102 port 40454 ssh2"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-24T21:54:15.193632+08:00",
|
||||
"method": "password",
|
||||
"user": "pakchoi",
|
||||
"ip": "118.178.120.173",
|
||||
"port": 55866,
|
||||
"source": "auth.log",
|
||||
"raw_log_line": "2026-11-24T21:54:15.193632+08:00 localhost sshd[2847773]: Accepted password for pakchoi from 118.178.120.173 port 55866 ssh2"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-25T00:25:24.861422+08:00",
|
||||
"method": "password",
|
||||
"user": "pakchoi",
|
||||
"ip": "47.102.136.164",
|
||||
"port": 58572,
|
||||
"source": "auth.log",
|
||||
"raw_log_line": "2026-11-25T00:25:24.861422+08:00 localhost sshd[2931731]: Accepted password for pakchoi from 47.102.136.164 port 58572 ssh2"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-25T23:07:30.998896+08:00",
|
||||
"method": "password",
|
||||
"user": "pakchoi",
|
||||
"ip": "43.157.226.233",
|
||||
"port": 34856,
|
||||
"source": "auth.log",
|
||||
"raw_log_line": "2026-11-25T23:07:30.998896+08:00 localhost sshd[3692660]: Accepted password for pakchoi from 43.157.226.233 port 34856 ssh2"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-25T23:14:57.514663+08:00",
|
||||
"method": "password",
|
||||
"user": "pakchoi",
|
||||
"ip": "43.157.226.233",
|
||||
"port": 40196,
|
||||
"source": "auth.log",
|
||||
"raw_log_line": "2026-11-25T23:14:57.514663+08:00 localhost sshd[3696949]: Accepted password for pakchoi from 43.157.226.233 port 40196 ssh2"
|
||||
},
|
||||
{
|
||||
"time": "2026-11-25T23:16:09.533008+08:00",
|
||||
"method": "password",
|
||||
"user": "pakchoi",
|
||||
"ip": "43.157.226.233",
|
||||
"port": 41990,
|
||||
"source": "auth.log",
|
||||
"raw_log_line": "2026-11-25T23:16:09.533008+08:00 localhost sshd[3697660]: Accepted password for pakchoi from 43.157.226.233 port 41990 ssh2"
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,594 @@
|
||||
{
|
||||
"next": [
|
||||
{
|
||||
"id": 1117930,
|
||||
"url": "https://github.com/advisories/GHSA-8h8q-6873-q5fj",
|
||||
"title": "Next.js Vulnerable to Denial of Service with Server Components",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-770"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 7.5,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118941,
|
||||
"url": "https://github.com/advisories/GHSA-3g8h-86w9-wvmq",
|
||||
"title": "Next.js's Middleware / Proxy redirects can be cache-poisoned",
|
||||
"severity": "low",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-349"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 3.7,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118943,
|
||||
"url": "https://github.com/advisories/GHSA-ffhc-5mcf-pf4q",
|
||||
"title": "Next.js vulnerable to cross-site scripting in App Router applications using CSP nonces",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-79"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 4.7,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:L/I:L/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118945,
|
||||
"url": "https://github.com/advisories/GHSA-vfv6-92ff-j949",
|
||||
"title": "Next.js vulnerable to cache poisoning via collisions in React Server Component cache-busting",
|
||||
"severity": "low",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-328"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 3.7,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118947,
|
||||
"url": "https://github.com/advisories/GHSA-gx5p-jg67-6x7h",
|
||||
"title": "Next.js has cross-site scripting in beforeInteractive scripts with untrusted input",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-79"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 6.1,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118949,
|
||||
"url": "https://github.com/advisories/GHSA-mg66-mrh9-m8jx",
|
||||
"title": "Next.js vulnerable to Denial of Service via connection exhaustion in applications using Cache Components",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-770"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 7.5,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118951,
|
||||
"url": "https://github.com/advisories/GHSA-h64f-5h5j-jqjh",
|
||||
"title": "Next.js has a Denial of Service in the Image Optimization API",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-770"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 5.9,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118953,
|
||||
"url": "https://github.com/advisories/GHSA-c4j6-fc7j-m34r",
|
||||
"title": "Next.js vulnerable to server-side request forgery in applications using WebSocket upgrades",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-918"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 8.6,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:N/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118955,
|
||||
"url": "https://github.com/advisories/GHSA-492v-c6pp-mqqv",
|
||||
"title": "Next.js has a Middleware / Proxy bypass through dynamic route parameter injection",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-288"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 8.1,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118957,
|
||||
"url": "https://github.com/advisories/GHSA-wfc6-r584-vfw7",
|
||||
"title": "Next.js vulnerable to cache poisoning in React Server Component responses",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-436"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 5.4,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:L/A:L"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118959,
|
||||
"url": "https://github.com/advisories/GHSA-267c-6grr-h53f",
|
||||
"title": "Next.js has a Middleware / Proxy bypass in App Router applications via segment-prefetch routes",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-288"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 7.5,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1118961,
|
||||
"url": "https://github.com/advisories/GHSA-36qx-fr4f-26g5",
|
||||
"title": "Next.js has a Middleware / Proxy bypass in Pages Router applications using i18n",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.5",
|
||||
"cwe": [
|
||||
"CWE-863"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 7.5,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1114898,
|
||||
"url": "https://github.com/advisories/GHSA-ggv3-7p47-pfv8",
|
||||
"title": "Next.js: HTTP request smuggling in rewrites",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0-beta.0 <16.1.7",
|
||||
"cwe": [
|
||||
"CWE-444"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1114941,
|
||||
"url": "https://github.com/advisories/GHSA-3x4c-7xq6-9pq8",
|
||||
"title": "Next.js: Unbounded next/image disk cache growth can exhaust storage",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0-beta.0 <16.1.7",
|
||||
"cwe": [
|
||||
"CWE-400"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1114942,
|
||||
"url": "https://github.com/advisories/GHSA-h27x-g6w4-24gq",
|
||||
"title": "Next.js: Unbounded postponed resume buffering can lead to DoS",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.1 <16.1.7",
|
||||
"cwe": [
|
||||
"CWE-770"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1114943,
|
||||
"url": "https://github.com/advisories/GHSA-mq59-m269-xvcx",
|
||||
"title": "Next.js: null origin can bypass Server Actions CSRF checks",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.1 <16.1.7",
|
||||
"cwe": [
|
||||
"CWE-352"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1115360,
|
||||
"url": "https://github.com/advisories/GHSA-jcc7-9wpm-mj36",
|
||||
"title": "Next.js: null origin can bypass dev HMR websocket CSRF checks",
|
||||
"severity": "low",
|
||||
"vulnerable_versions": ">=16.0.1 <16.1.7",
|
||||
"cwe": [
|
||||
"CWE-1385"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1116375,
|
||||
"url": "https://github.com/advisories/GHSA-q4gf-8mx6-v5v3",
|
||||
"title": "Next.js has a Denial of Service with Server Components",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0-beta.0 <16.2.3",
|
||||
"cwe": [
|
||||
"CWE-770"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 7.5,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1124184,
|
||||
"url": "https://github.com/advisories/GHSA-89xv-2m56-2m9x",
|
||||
"title": "Next.js: Server-Side Request Forgery in Server Actions on custom servers",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.11",
|
||||
"cwe": [
|
||||
"CWE-918"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1124186,
|
||||
"url": "https://github.com/advisories/GHSA-68g3-v927-f742",
|
||||
"title": "Next.js: Cache confusion of response bodies for requests with bodies",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.11",
|
||||
"cwe": [
|
||||
"CWE-524"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1124170,
|
||||
"url": "https://github.com/advisories/GHSA-6gpp-xcg3-4w24",
|
||||
"title": "Next.js: Middleware / Proxy bypass in App Router applications using Turbopack and single locale",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.11",
|
||||
"cwe": [
|
||||
"CWE-285"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1124171,
|
||||
"url": "https://github.com/advisories/GHSA-m99w-x7hq-7vfj",
|
||||
"title": "Next.js: Denial of Service in App Router using Server Actions",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.11",
|
||||
"cwe": [
|
||||
"CWE-834"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1124188,
|
||||
"url": "https://github.com/advisories/GHSA-4633-3j49-mh5q",
|
||||
"title": "Next.js: Cache confusion of response bodies for requests with bodies containing invalid UTF-8 byte sequences",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.11",
|
||||
"cwe": [
|
||||
"CWE-116"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1124190,
|
||||
"url": "https://github.com/advisories/GHSA-4c39-4ccg-62r3",
|
||||
"title": "Next.js: Unbounded Server Action payload in Edge runtime",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.11",
|
||||
"cwe": [
|
||||
"CWE-770"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1124192,
|
||||
"url": "https://github.com/advisories/GHSA-p9j2-gv94-2wf4",
|
||||
"title": "Next.js: Server-Side Request Forgery in rewrites via attacker-controlled destination hostname",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.11",
|
||||
"cwe": [
|
||||
"CWE-918"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1124194,
|
||||
"url": "https://github.com/advisories/GHSA-q8wf-6r8g-63ch",
|
||||
"title": "Next.js: Denial of Service in the Image Optimization API using SVGs",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.11",
|
||||
"cwe": [
|
||||
"CWE-407"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1124196,
|
||||
"url": "https://github.com/advisories/GHSA-955p-x3mx-jcvp",
|
||||
"title": "Next.js: Unauthenticated disclosure of internal Server Function endpoints",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.11",
|
||||
"cwe": [
|
||||
"CWE-201"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1241496,
|
||||
"url": "https://github.com/advisories/GHSA-cjq9-62q9-8jv4",
|
||||
"title": "Next.js has Server-Side Request Forgery in Image Optimization",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.3.8",
|
||||
"cwe": [
|
||||
"CWE-918"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 6.5,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:L/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1193676,
|
||||
"url": "https://github.com/advisories/GHSA-p293-qw3h-jr36",
|
||||
"title": "Next.js: Unauthenticated Remote Code Execution on windows-hosted servers",
|
||||
"severity": "critical",
|
||||
"vulnerable_versions": ">=16.0.0 <16.3.3",
|
||||
"cwe": [
|
||||
"CWE-22"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 9,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1193732,
|
||||
"url": "https://github.com/advisories/GHSA-2xp9-vwfh-vxw4",
|
||||
"title": "Next.js: Unauthenticated Remote Code Execution in Image Optimization API when AVIF files are used",
|
||||
"severity": "critical",
|
||||
"vulnerable_versions": ">=16.0.0 <16.3.3",
|
||||
"cwe": [
|
||||
"CWE-1395"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1241493,
|
||||
"url": "https://github.com/advisories/GHSA-f87g-xv8r-7p7x",
|
||||
"title": "Next.js has information disclosure in App Router metadata image routes via dynamicParams bypass",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.3.8",
|
||||
"cwe": [
|
||||
"CWE-346"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 5.3,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1241495,
|
||||
"url": "https://github.com/advisories/GHSA-mcj8-r9mp-w47p",
|
||||
"title": "Next.js has cache poisoning in SSG/ISR rendering that leads to cross-user content substitution and persistent denial of service",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.3.8",
|
||||
"cwe": [
|
||||
"CWE-524"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 4.8,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:L/A:L"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1241490,
|
||||
"url": "https://github.com/advisories/GHSA-4jqv-mc3x-m676",
|
||||
"title": "Next.js has cache poisoning of SSG and ISR pages in self-hosted applications",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <16.3.8",
|
||||
"cwe": [
|
||||
"CWE-524"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 5.3,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1241492,
|
||||
"url": "https://github.com/advisories/GHSA-39w2-rjm5-chcv",
|
||||
"title": "Next.js has information disclosure in development server's Model Context Protocol endpoint",
|
||||
"severity": "low",
|
||||
"vulnerable_versions": ">=16.0.0 <16.3.8",
|
||||
"cwe": [
|
||||
"CWE-346"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 5.4,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1242818,
|
||||
"url": "https://github.com/advisories/GHSA-p3m5-59mp-jv5r",
|
||||
"title": "Next.js: Denial of Service in App Router using Server Actions",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <=16.4.0",
|
||||
"cwe": [
|
||||
"CWE-770"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1242816,
|
||||
"url": "https://github.com/advisories/GHSA-2464-fhr4-w9xw",
|
||||
"title": "Next.js: Unauthenticated Remote Code Execution in Image Optimization API when SVG files are used",
|
||||
"severity": "critical",
|
||||
"vulnerable_versions": ">=16.0.0 <=16.4.0",
|
||||
"cwe": [
|
||||
"CWE-1395"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1242859,
|
||||
"url": "https://github.com/advisories/GHSA-673q-mjm6-r5xr",
|
||||
"title": "Next.js: Unauthenticated Remote Code Execution in `use cache` functions returning typed arrays",
|
||||
"severity": "critical",
|
||||
"vulnerable_versions": ">=16.0.0 <=16.4.0",
|
||||
"cwe": [
|
||||
"CWE-502"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1244535,
|
||||
"url": "https://github.com/advisories/GHSA-26hh-7cqf-hhc6",
|
||||
"title": "Next.js has a Middleware / Proxy bypass in App Router applications via segment-prefetch routes - Incomplete Fix Follow-Up",
|
||||
"severity": "high",
|
||||
"vulnerable_versions": ">=16.0.0 <16.2.6",
|
||||
"cwe": [
|
||||
"CWE-288",
|
||||
"CWE-358"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 7.5,
|
||||
"vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1248078,
|
||||
"url": "https://github.com/advisories/GHSA-7qx7-33qx-rqx2",
|
||||
"title": "Next.js: SVG rejection bypass in the image optimization",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <=16.4.4",
|
||||
"cwe": [
|
||||
"CWE-1287"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1248080,
|
||||
"url": "https://github.com/advisories/GHSA-f3mh-rxg3-f5g2",
|
||||
"title": "Next.js: HttpOnly cookie exposure through internal response header on Next.js Edge runtime routes",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <=16.4.4",
|
||||
"cwe": [
|
||||
"CWE-200",
|
||||
"CWE-201"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1248083,
|
||||
"url": "https://github.com/advisories/GHSA-pc58-hwjq-p385",
|
||||
"title": "Next.js: Cross-client response injection and disclosure in self-hosted Next.js applications forwarding fetched responses",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <=16.4.4",
|
||||
"cwe": [
|
||||
"CWE-444"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": 1248084,
|
||||
"url": "https://github.com/advisories/GHSA-rhh4-g77r-r9qj",
|
||||
"title": "Next.js: Cross-user cache disclosure and poisoning in Next.js use cache with binary arguments",
|
||||
"severity": "moderate",
|
||||
"vulnerable_versions": ">=16.0.0 <=16.4.4",
|
||||
"cwe": [
|
||||
"CWE-694"
|
||||
],
|
||||
"cvss": {
|
||||
"score": 0,
|
||||
"vectorString": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
{
|
||||
"applied_at": "2026-11-26 12:56:09 +0800",
|
||||
"uid0_remaining": [
|
||||
"root"
|
||||
],
|
||||
"locked_aliases": [
|
||||
"guest",
|
||||
"none",
|
||||
"shellcrash",
|
||||
"pakchoi"
|
||||
],
|
||||
"root_cron_removed": 4,
|
||||
"preserved_shellcrash_cron": true,
|
||||
"ssh_key_only": true,
|
||||
"rollback_timer": "hackrobot-ssh-rollback.timer",
|
||||
"backup": "/opt/hackrobot-backup/security/incident-20261126/pre-hardening"
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"applied_at": "2026-11-26 13:01:03 +0800",
|
||||
"scope": "vip.hackrobot.cn",
|
||||
"unused_next_action_requests": 405,
|
||||
"unused_image_optimizer": 404,
|
||||
"source_search_confirmed_no_usage": true,
|
||||
"framework_upgrade_required": true,
|
||||
"config": "/www/server/panel/vhost/nginx/extension/vip.hackrobot.cn/incident-unused-next-endpoints.conf"
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
{
|
||||
"applied_at": "2026-11-26 12:57:58 +0800",
|
||||
"blocked_successful_backdoor_sources": [
|
||||
"101.33.68.140",
|
||||
"101.33.196.102",
|
||||
"118.178.120.173",
|
||||
"47.102.136.164",
|
||||
"43.157.226.233"
|
||||
],
|
||||
"protected_backend_ports": [
|
||||
3306,
|
||||
4007,
|
||||
8007
|
||||
],
|
||||
"preserved_known_cross_host_source": "82.157.112.245",
|
||||
"protected_web_ports_unchanged": [
|
||||
80,
|
||||
443
|
||||
],
|
||||
"no_forward_or_docker_rules_changed": true
|
||||
}
|
||||
@ -0,0 +1,80 @@
|
||||
[
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/laso",
|
||||
"bytes": 17621,
|
||||
"sha256": "6cdc37cf5484260d7a610c8aec8423abf3eaf498c751d23645e915b67e900857",
|
||||
"mtime": "2026-11-26 01:25:47 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/epis",
|
||||
"bytes": 26002,
|
||||
"sha256": "10b9cce5d7551b9c99e72d1c8a393546990bdd57d2fd59456d46298d48927faa",
|
||||
"mtime": "2026-11-26 01:20:33 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/codo",
|
||||
"bytes": 8615,
|
||||
"sha256": "fbb65b437efe65504363d2f170d74e9fb5770908eee427f70fbcca47030d4ec8",
|
||||
"mtime": "2026-11-26 00:05:18 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/300k",
|
||||
"bytes": 6384868,
|
||||
"sha256": "e2a6025b49ccc18562c83b9a62e9ff71eae6877aad27d014b6c2d94d07185d6b",
|
||||
"mtime": "2026-11-25 23:27:55 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/dosi",
|
||||
"bytes": 26002,
|
||||
"sha256": "74bee765dc0b71f1921bbe5b3cd8248fe49f51592aaa8f50ccbfefee524039ae",
|
||||
"mtime": "2026-11-25 23:26:37 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/ksmd",
|
||||
"bytes": 6790872,
|
||||
"sha256": "05dcf40cd29837b3d3cc2231b75a9219cd0e0c0677498362b724112dc33c555e",
|
||||
"mtime": "2026-11-25 23:22:38 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/39",
|
||||
"bytes": 11419537,
|
||||
"sha256": "bc09bff56d9601b2f9535ad0918cc300291b5de9feb16a5b87a34c759fb23788",
|
||||
"mtime": "2026-11-24 21:24:37 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/deds",
|
||||
"bytes": 6905,
|
||||
"sha256": "12bd83628e960a50d8abf601f95a40aa8c93b2f38bdf31b7377d7f6dab6eb8ed",
|
||||
"mtime": "2026-11-24 19:48:12 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/pass.txt",
|
||||
"bytes": 8615,
|
||||
"sha256": "2f302ef6cc9d53226a760c7f5fa15694c449052eca401db9e859981e0815403f",
|
||||
"mtime": "2026-11-26 02:59:20 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/ips.txt",
|
||||
"bytes": 6384868,
|
||||
"sha256": "e2a6025b49ccc18562c83b9a62e9ff71eae6877aad27d014b6c2d94d07185d6b",
|
||||
"mtime": "2026-11-25 23:30:02 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/ispp",
|
||||
"bytes": 3092480,
|
||||
"sha256": "d69a195429e6d5ae9ce7675b061ef9050ab13b08bdf4fff67eb6ed8a21bbb871",
|
||||
"mtime": "2026-11-24 19:39:02 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/isp",
|
||||
"bytes": 2146304,
|
||||
"sha256": "40507d1ef299a93e775e27ed0a558554c19db87f157b8c0557a57c1dcbd62cad",
|
||||
"mtime": "2026-11-24 19:22:07 +0800"
|
||||
},
|
||||
{
|
||||
"path": "/dev/shm/.jmhxxkxjqweqweqg/is/ikp",
|
||||
"bytes": 17629,
|
||||
"sha256": "a12721971284db0bb21110968ac10ce17a53555cc410dc9c9d95db0847ee517b",
|
||||
"mtime": "2026-11-24 18:56:00 +0800"
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,78 @@
|
||||
[
|
||||
{
|
||||
"name": "codo",
|
||||
"magic": "61646d69",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "dosi",
|
||||
"magic": "7a787a3a",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "deds",
|
||||
"magic": "77726a3a",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "epis",
|
||||
"magic": "61646d69",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "isp",
|
||||
"magic": "33312e32",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "pass.txt",
|
||||
"magic": "646d6462",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "laso",
|
||||
"magic": "77726a3a",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "ikp",
|
||||
"magic": "61646d69",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "ksmd",
|
||||
"magic": "7f454c46",
|
||||
"url_hosts": [
|
||||
"8.138.141.118",
|
||||
"api.c99.nl",
|
||||
"api.reverseipdomain.com",
|
||||
"docs.rs",
|
||||
"ftp.apnic.net",
|
||||
"ftp.lacnic.net",
|
||||
"ftp.ripe.net",
|
||||
"github.com",
|
||||
"rapiddns.io",
|
||||
"stat.ripe.net"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "300k",
|
||||
"magic": "3130362e",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "39",
|
||||
"magic": "39312e31",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "ips.txt",
|
||||
"magic": "3130362e",
|
||||
"url_hosts": []
|
||||
},
|
||||
{
|
||||
"name": "ispp",
|
||||
"magic": "3133392e",
|
||||
"url_hosts": []
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,4 @@
|
||||
{
|
||||
"checked_at": "2026-11-26 13:09:02 +0800",
|
||||
"alerts": []
|
||||
}
|
||||
@ -0,0 +1,125 @@
|
||||
[
|
||||
{
|
||||
"ip": "101.33.68.140",
|
||||
"rdap_url": "https://rdap.apnic.net/ip/101.33.68.140",
|
||||
"name": "ACEVILLEPTELTD-SG",
|
||||
"country": "KR",
|
||||
"startAddress": "101.33.64.0",
|
||||
"endAddress": "101.33.99.255",
|
||||
"entities": [
|
||||
{
|
||||
"handle": "APA7-AP",
|
||||
"roles": [
|
||||
"administrative",
|
||||
"technical"
|
||||
]
|
||||
},
|
||||
{
|
||||
"handle": "IRT-ACEVILLEPTELTD-SG",
|
||||
"roles": [
|
||||
"abuse"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ip": "101.33.196.102",
|
||||
"rdap_url": "https://rdap.apnic.net/ip/101.33.196.102",
|
||||
"name": "TENCENT-CN",
|
||||
"country": "CN",
|
||||
"startAddress": "101.33.128.0",
|
||||
"endAddress": "101.33.255.255",
|
||||
"entities": [
|
||||
{
|
||||
"handle": "IRT-TENCENT-CN",
|
||||
"roles": [
|
||||
"abuse"
|
||||
]
|
||||
},
|
||||
{
|
||||
"handle": "TCA15-AP",
|
||||
"roles": [
|
||||
"administrative",
|
||||
"technical"
|
||||
]
|
||||
},
|
||||
{
|
||||
"handle": "ORG-TCCC1-AP",
|
||||
"roles": [
|
||||
"registrant"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ip": "118.178.120.173",
|
||||
"rdap_url": "https://rdap.apnic.net/ip/118.178.120.173",
|
||||
"name": "ALISOFT",
|
||||
"country": "CN",
|
||||
"startAddress": "118.178.0.0",
|
||||
"endAddress": "118.178.255.255",
|
||||
"entities": [
|
||||
{
|
||||
"handle": "ZM1015-AP",
|
||||
"roles": [
|
||||
"administrative"
|
||||
]
|
||||
},
|
||||
{
|
||||
"handle": "ZM877-AP",
|
||||
"roles": [
|
||||
"technical"
|
||||
]
|
||||
},
|
||||
{
|
||||
"handle": "ZM875-AP",
|
||||
"roles": [
|
||||
"technical"
|
||||
]
|
||||
},
|
||||
{
|
||||
"handle": "ZM876-AP",
|
||||
"roles": [
|
||||
"technical"
|
||||
]
|
||||
},
|
||||
{
|
||||
"handle": "IRT-ALISOFT-CN",
|
||||
"roles": [
|
||||
"abuse"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"ip": "47.102.136.164",
|
||||
"rdap_url": "https://rdap.apnic.net/ip/47.102.136.164",
|
||||
"name": "ALISOFT",
|
||||
"country": "CN",
|
||||
"startAddress": "47.100.0.0",
|
||||
"endAddress": "47.103.255.255"
|
||||
},
|
||||
{
|
||||
"ip": "43.157.226.233",
|
||||
"rdap_url": "https://rdap.apnic.net/ip/43.157.226.233",
|
||||
"name": "ACEVILLEPTELTD-SG",
|
||||
"country": "ID",
|
||||
"startAddress": "43.157.192.0",
|
||||
"endAddress": "43.157.255.255",
|
||||
"entities": [
|
||||
{
|
||||
"handle": "APA7-AP",
|
||||
"roles": [
|
||||
"administrative",
|
||||
"technical"
|
||||
]
|
||||
},
|
||||
{
|
||||
"handle": "IRT-ACEVILLEPTELTD-SG",
|
||||
"roles": [
|
||||
"abuse"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
@ -0,0 +1,122 @@
|
||||
{
|
||||
"collected_at": "2026-11-26 12:52:05 +0800",
|
||||
"ssh_connection": "",
|
||||
"accepted_count": 438,
|
||||
"accepted_by_ip_user": [
|
||||
{
|
||||
"ip": "183.93.112.24",
|
||||
"user": "ubuntu",
|
||||
"count": 224
|
||||
},
|
||||
{
|
||||
"ip": "183.93.112.39",
|
||||
"user": "ubuntu",
|
||||
"count": 132
|
||||
},
|
||||
{
|
||||
"ip": "183.93.112.226",
|
||||
"user": "ubuntu",
|
||||
"count": 55
|
||||
},
|
||||
{
|
||||
"ip": "183.93.112.180",
|
||||
"user": "ubuntu",
|
||||
"count": 20
|
||||
},
|
||||
{
|
||||
"ip": "43.157.226.233",
|
||||
"user": "pakchoi",
|
||||
"count": 3
|
||||
},
|
||||
{
|
||||
"ip": "101.33.68.140",
|
||||
"user": "pakchoi",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"ip": "101.33.196.102",
|
||||
"user": "pakchoi",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"ip": "118.178.120.173",
|
||||
"user": "pakchoi",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"ip": "47.102.136.164",
|
||||
"user": "pakchoi",
|
||||
"count": 1
|
||||
}
|
||||
],
|
||||
"failed_top": [
|
||||
[
|
||||
"212.18.52.25",
|
||||
1474
|
||||
],
|
||||
[
|
||||
"149.56.217.226",
|
||||
734
|
||||
],
|
||||
[
|
||||
"43.160.247.134",
|
||||
729
|
||||
],
|
||||
[
|
||||
"43.143.212.248",
|
||||
704
|
||||
],
|
||||
[
|
||||
"129.211.204.25",
|
||||
685
|
||||
],
|
||||
[
|
||||
"176.236.127.114",
|
||||
455
|
||||
],
|
||||
[
|
||||
"101.33.203.92",
|
||||
405
|
||||
],
|
||||
[
|
||||
"119.28.179.141",
|
||||
350
|
||||
],
|
||||
[
|
||||
"81.70.219.27",
|
||||
350
|
||||
],
|
||||
[
|
||||
"43.156.39.113",
|
||||
233
|
||||
],
|
||||
[
|
||||
"220.249.78.82",
|
||||
140
|
||||
],
|
||||
[
|
||||
"49.51.184.212",
|
||||
90
|
||||
],
|
||||
[
|
||||
"36.95.15.107",
|
||||
80
|
||||
],
|
||||
[
|
||||
"94.80.179.157",
|
||||
79
|
||||
],
|
||||
[
|
||||
"103.130.90.169",
|
||||
72
|
||||
]
|
||||
],
|
||||
"uid0_accounts": [
|
||||
"root",
|
||||
"guest",
|
||||
"none",
|
||||
"shellcrash",
|
||||
"pakchoi"
|
||||
],
|
||||
"evidence_dir": "/opt/hackrobot-backup/security/incident-20261126"
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
{
|
||||
"collection": "users",
|
||||
"status": 200,
|
||||
"records": [
|
||||
{
|
||||
"id": "ckq2xyqb7o64ww0",
|
||||
"email": "1366587718@qq.com",
|
||||
"name": "",
|
||||
"created": "2026-11-11 01:00:17.627Z",
|
||||
"updated": "2026-11-11 01:00:17.627Z",
|
||||
"verified": false
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,24 @@
|
||||
IP,Confirmed_backdoor_login,SSH_failed_password_count,Site_events,Identifiers,Display_names,Block_state,Shared_identifiers_with_confirmed_backdoor_sources
|
||||
101.33.196.102,True,4,0,,,,
|
||||
101.33.203.92,False,405,0,,,,
|
||||
101.33.68.140,True,35,0,,,,
|
||||
103.130.90.169,False,72,0,,,,
|
||||
114.226.234.105,False,0,710,1366587718@qq.com;ckq2xyqb7o64ww0;oBVe71V5Sal-S5-UNZKgY9GHf6vY;user1794106344853;user1794356326176,1366587718@qq.com;user1794106344853;user1794356326176,historical:user1794356326176;historical:ckq2xyqb7o64ww0;historical:114.226.234.105,
|
||||
115.206.252.211,False,0,208,oBVe71c3H6IdEZJozXgoOIYe8RXY;user1786380683635;user1794675896370;user1794676564740;user1794676804258,user1786380683635;user1794675896370;user1794676564740;user1794676804258;༺ۣۖ心ۣۖ༒ۣ缘ۣۖ༻,historical:user1786380683635;historical:115.206.252.211,
|
||||
118.178.120.173,True,0,0,,,,
|
||||
119.28.179.141,False,350,0,,,,
|
||||
129.211.204.25,False,685,0,,,,
|
||||
149.56.217.226,False,734,0,,,,
|
||||
176.236.127.114,False,455,0,,,,
|
||||
183.93.112.39,False,2,183,oBVe71TMQc1kK059sWTtfam51c6M;oBVe71Tkmqhy4xC2UF1uwcOPjKFU;oBVe71eBDD0jBZjOSXSoFV8ERV3c;user1774657779491;user1794204998119;user1794410185707;user1794410237347;user1795137985002;user1795662711541,AAA恩特供应链;Eric;oBVe71Tkmqhy4xC2UF1uwcOPjKFU;oBVe71eBDD0jBZjOSXSoFV8ERV3c;user1794204998119;user1794410185707;user1794410237347;user1795137985002;user1795662711541;异度世界,,
|
||||
212.18.52.25,False,1474,0,,,,
|
||||
220.249.78.82,False,140,0,,,,
|
||||
36.95.15.107,False,80,0,,,,
|
||||
43.143.212.248,False,704,0,,,,
|
||||
43.156.39.113,False,233,0,,,,
|
||||
43.157.226.233,True,0,0,,,,
|
||||
43.160.247.134,False,729,0,,,,
|
||||
47.102.136.164,True,0,0,,,,
|
||||
49.51.184.212,False,90,0,,,,
|
||||
81.70.219.27,False,350,0,,,,
|
||||
94.80.179.157,False,79,0,,,,
|
||||
|
25
apps/hackrobot/docs/security/129-2026-11-26/云厂商日志保全申请.md
Normal file
25
apps/hackrobot/docs/security/129-2026-11-26/云厂商日志保全申请.md
Normal file
@ -0,0 +1,25 @@
|
||||
# 云主机入侵事件日志保全申请草稿
|
||||
|
||||
本文件仅为草稿,尚未发送给任何人。
|
||||
|
||||
受影响主机:`129.204.21.129`;事件日期:2026 年 11 月 12 日至 26 日。
|
||||
|
||||
我们在自有主机的 SSH 认证日志中发现,以下来源通过未授权后门账号 `pakchoi` 成功认证。请保全对应时间段来源 IP 的分配记录、云主机租户及控制台登录/操作日志、网络连接记录,以及可能涉及的转发或代理记录。全部时间为北京时间 UTC+08:00,请特别避免与 UTC 混淆。
|
||||
|
||||
| 来源 IP | 日期与时间 | 源端口 | 目标 |
|
||||
|---|---|---:|---|
|
||||
| 101.33.68.140 | 2026-11-22 18:57:58.735396 | 60618 | 129.204.21.129:22 |
|
||||
| 101.33.196.102 | 2026-11-23 15:03:20.788456 | 40454 | 129.204.21.129:22 |
|
||||
| 118.178.120.173 | 2026-11-24 21:54:15.193632 | 55866 | 129.204.21.129:22 |
|
||||
| 47.102.136.164 | 2026-11-25 00:25:24.861422 | 58572 | 129.204.21.129:22 |
|
||||
| 43.157.226.233 | 2026-11-25 23:07:30.998896 | 34856 | 129.204.21.129:22 |
|
||||
| 43.157.226.233 | 2026-11-25 23:14:57.514663 | 40196 | 129.204.21.129:22 |
|
||||
| 43.157.226.233 | 2026-11-25 23:16:09.533008 | 41990 | 129.204.21.129:22 |
|
||||
|
||||
请求按每条记录前后至少 30 分钟保全数据,并记录日志保存期限。如实际 IP 不由贵方提供,请告知负责的网络运营主体或正确的滥用投诉渠道。
|
||||
|
||||
对受影响主机所在云平台,另请求保全 2026-11-12 22:00 至 23:00、2026-11-13 04:00 至 05:30 的控制台/CAM/云助手命令执行、主机安全告警和安全组修改记录,及 11 月 12 日之前可用的相关日志。现存主机日志显示 11-12 22:36:16 创建后门账号,11-13 04:50 再次修改账号和 SSH 配置,原始入口尚未确定。
|
||||
|
||||
随附材料建议:安全事件报告、`confirmed-backdoor-logins.json`、`account-creation-evidence.txt`、样本 SHA-256 及 `EXPORT_SHA256.json`。分享时不附主机密码、私钥、shadow 文件或恶意程序本体。
|
||||
|
||||
这些来源可能是被入侵跳板,不预先断言其云主机租户就是实际攻击者。涉及个人实名或通信记录的信息,请通过合法执法协查程序提供。
|
||||
150
apps/hackrobot/docs/security/129-2026-11-26/安全事件报告.md
Normal file
150
apps/hackrobot/docs/security/129-2026-11-26/安全事件报告.md
Normal file
@ -0,0 +1,150 @@
|
||||
# 129 服务器安全事件与用户关联报告
|
||||
|
||||
报告日期:2026-11-26。所有时间如未特别说明均为北京时间(UTC+08:00)。
|
||||
|
||||
对象:`129.204.21.129`、`vip.hackrobot.cn`、VIP 运营台 `admin.hackrobot.cn`。未将 `admin.nomadro.cn` 或 `admin.nomadro.com` 的用户混入分析。
|
||||
|
||||
## 可确认的结论
|
||||
|
||||
1. **服务器已发生 root 权限级别的入侵或未授权修改。**发现 `guest`、`none`、`shellcrash`、`pakchoi` 四个额外 UID=0 账号;root 定时任务会自动创建 `pakchoi`、设置固定密码并写入免密 sudo 规则。
|
||||
2. 保存的 SSH 认证日志包含 **5 个外部 IP、7 次使用 `pakchoi` 密码成功登录**的记录。此前发现的 7 个用户态 Perl 进程伪装为内核 `kworker`,进程编号与这 7 次登录的时间顺序高度对应。另有隐藏的 `ksmd` 二进制向大量外部主机发起 SSH 连接。
|
||||
3. **目前不能把入侵归属到某位站内用户或自然人。**对全部用户访问记录的比对中,这 5 个成功后门登录源均没有站内埋点或 Nginx 请求命中。
|
||||
4. 用户要求重点调查的 `114.226.234.105` 可以关联到站内账号和微信联系人,但**没有发现它与成功后门登录源的交集**。不能据此认定该用户发动了本次服务器入侵。
|
||||
|
||||
这些结论依据主机现存日志与样本。攻击者曾有 root 权限,日志可能不完整、被删除或修改;校验值证明采集后的副本一致性,不证明采集前从未被篡改。
|
||||
|
||||
## 成功使用后门的连接来源
|
||||
|
||||
下表依据原始 `auth.log` 的 `Accepted password for pakchoi`,不是把失败扫描当作成功入侵。
|
||||
|
||||
| 来源 IP | 成功认证时间 | 源端口 | 账号 | RDAP 注册网络 |
|
||||
|---|---|---:|---|---|
|
||||
| 101.33.68.140 | 11-22 18:57:58.735396 | 60618 | pakchoi | ACEVILLEPTELTD-SG |
|
||||
| 101.33.196.102 | 11-23 15:03:20.788456 | 40454 | pakchoi | TENCENT-CN |
|
||||
| 118.178.120.173 | 11-24 21:54:15.193632 | 55866 | pakchoi | ALISOFT |
|
||||
| 47.102.136.164 | 11-25 00:25:24.861422 | 58572 | pakchoi | ALISOFT |
|
||||
| 43.157.226.233 | 11-25 23:07:30.998896 | 34856 | pakchoi | ACEVILLEPTELTD-SG |
|
||||
| 43.157.226.233 | 11-25 23:14:57.514663 | 40196 | pakchoi | ACEVILLEPTELTD-SG |
|
||||
| 43.157.226.233 | 11-25 23:16:09.533008 | 41990 | pakchoi | ACEVILLEPTELTD-SG |
|
||||
|
||||
RDAP 查询来自 APNIC,详见 `evidence/rdap-attribution.json`。网络注册信息不等于攻击者居住地。上述主机可能是跳板、被入侵主机、代理或租用云主机;需要云厂商保存对应时间的租户、分配及登录日志,才能继续归属。
|
||||
|
||||
## 与运营台全部用户交叉关联
|
||||
|
||||
检查了 **9,893 条站内事件、237 个带用户标识的访问 IP**,没有仅筛选已拉黑用户。额外比对全部保留的 SSH 失败来源与站内 IP 交集、成功后门源、主要失败扫描源及历史封禁地址,共 23 个候选地址。数据库查询只读,没有更改拉黑状态、会员权限或用户资料。
|
||||
|
||||
| 成功后门来源 IP | 站内事件 | 保留的 Nginx 请求 | 匹配到的站内身份 |
|
||||
|---|---:|---:|---|
|
||||
| 101.33.68.140 | 0 | 0 | 无 |
|
||||
| 101.33.196.102 | 0 | 0 | 无 |
|
||||
| 118.178.120.173 | 0 | 0 | 无 |
|
||||
| 47.102.136.164 | 0 | 0 | 无 |
|
||||
| 43.157.226.233 | 0 | 0 | 无 |
|
||||
|
||||
“无匹配”仅说明当前保存的数据不能建立直接联系,不排除某位用户使用不同网络或云主机。也不能以“可能换 IP”为理由反向认定某人有罪。
|
||||
|
||||
交叉比对还命中了历史访问源 `183.93.112.39` 的 2 次 SSH 密码失败,该地址同时有大量 ubuntu 正常运维成功登录,不能把输错密码或重试自动当作攻击。另一个历史封禁 IP `115.206.252.211` 有 208 条站内事件,但没有成功后门登录关联。全部候选结果见 `user-ip-correlation.csv`。
|
||||
|
||||
### 114.226.234.105 的关联结果
|
||||
|
||||
| 项目 | 结果 |
|
||||
|---|---|
|
||||
| 首次/最后可见站内事件 | 11-08 10:52:59 至 11-11 14:53:41 |
|
||||
| 埋点数 | 710 |
|
||||
| Nginx 请求数 | 4,076,跨多个同机业务域名日志;不是全部为 VIP 页面,也不是攻击次数 |
|
||||
| 服务端站内账号 | `ckq2xyqb7o64ww0` |
|
||||
| 账号表邮箱 | `136***@qq.com`;完整值仅保留在证据 JSON |
|
||||
| 邮箱验证状态 | `verified=false`,不能据此认定邮箱所有人身份 |
|
||||
| 客户端访客标识 | `user1794106344853`、`user1794356326176` |
|
||||
| 微信链接参数标识 | `oBVe71V5Sal-S5-UNZKgY9GHf6vY` |
|
||||
| 服务端微信联系人 | `wechat_private_users` 中同 userid 的昵称为 **“溯”**,记录 ID `hdeefhrvujtxyei` |
|
||||
| 历史封禁 | 11-11 10:00:06,同时封禁该 IP、`user1794356326176`、`ckq2xyqb7o64ww0` |
|
||||
| 后台填写的封禁原因 | “1元漏洞滥用”;属于运营记录,不等于本次系统入侵证据 |
|
||||
| 解除封禁 | 11-15 01:37:36 至 01:37:38,由 `hackrobot` 操作 |
|
||||
| 全部保留 SSH 日志中的该 IP | 成功认证 0,失败密码认证 0 |
|
||||
| 与 5 个后门源共享用户标识 | 未发现 |
|
||||
|
||||
该账号在 PocketBase 的 `users` 表中确实存在,创建于 11-11 09:00:17;因此邮箱和账号 ID 的对应有服务端记录支持。不过“这个账号曾用该 IP 访问”和“账号实际由哪个自然人控制”是两个问题。
|
||||
|
||||
710 条事件中包含 17 次 `pay_start`、21 次 `login_submit`,其余主要为浏览、点击、心跳和页面性能记录。HTTP 日志中有支付创建、支付确认、登录与 Memos 请求;**200 响应只表示接口返回成功,不能证明服务器命令执行,也不能证明具体实付金额**。当前精确筛选的支付表未检出这些标识的历史付款记录,不能独立重建“1元”支付细节。
|
||||
|
||||
客户端上报、URL 参数和本地存储标识均可被伪造或转发。即便联系人昵称存在于服务端,也不足以把所有携带该链接的访问无条件归给昵称对应的人。
|
||||
|
||||
## 已知时间线与原始入口边界
|
||||
|
||||
| 时间 | 证据 |
|
||||
|---|---|
|
||||
| 11-12 22:36:16 | `useradd` 创建 `pakchoi`(最初 UID=1005),随后设置密码,加入 sudo、adm、root 组 |
|
||||
| 11-12 22:36:16 | SSH 服务被重新启动,出现本机针对 `pakchoi` 和 root 的认证连接 |
|
||||
| 11-13 04:50:01–02 | 再次修改密码和 SSH 配置;当前异常账号文件及相关定时任务的修改时间集中在此时 |
|
||||
| 11-22 至 11-25 | 上表 7 次成功后门认证 |
|
||||
| 11-24 18:55 起 | 发现的隐藏扫描目录有文件时间记录,不能据 mtime 单独证明创建者 |
|
||||
| 11-25 23:22:38 | 保存的 `ksmd` 文件修改时间 |
|
||||
| 11-26 11:59 至 12:08 | 暂停并终止扫描进程与 7 个伪装 Perl 进程,保存原始证据 |
|
||||
| 11-26 12:56 | 锁定异常账号、取消额外 UID=0,关闭 SSH 密码和 root 登录,移除重建任务 |
|
||||
| 11-26 12:57 起 | 应用定向防火墙、隔离样本、增加监测和 VIP 边缘防护 |
|
||||
|
||||
已检查 53 份当前 Nginx 日志中两次创建/修改后门附近的时间窗。期间有 `183.93.112.24` 对 GPS 站的 POST,也有同 IP 的历史 ubuntu 运维记录。用户说明常用电脑为本机,但不能确认当时的出口;动态 IP 和代理会改变出口,**该地址归属仍待确认,未作为攻击源封禁**。同一时刻的 Web 访问本身不能证明导致了后门创建。
|
||||
|
||||
现有证据尚不能确定最初入口是应用漏洞、外泄凭据、供应链安装脚本、云控制台命令或其他渠道。原始请求体未被 Nginx 记录,早期进程父链也已不存在。不得把上述某一种假设写成已证实根因。
|
||||
|
||||
## 恶意程序与证据保全
|
||||
|
||||
- 原目录:`/dev/shm/.jmhxxkxjqweqweqg/is/`,包含 ELF 扫描程序和 IP/凭据列表等 13 个文件,现已整体移出共享内存并隔离,未执行样本。
|
||||
- 主程序 `ksmd` SHA-256:`05dcf40cd29837b3d3cc2231b75a9219cd0e0c0677498362b724112dc33c555e`。
|
||||
- 检查时 `ksmd` 有约 2,005 条面向外部 SSH 的连接记录。这些目标 IP 是扫描对象,不能直接列为攻击者。
|
||||
- 静态字符串出现 `8.138.141.118` 和若干公共 API/代码站地址;未证明其为控制端,不将所有字符串中的地址等同攻击源。
|
||||
- 服务器证据根目录:`/opt/hackrobot-backup/security/incident-20261126/`,仅 root 可读。
|
||||
- 原始认证日志、账号文件、配置、进程、连接、规则快照保存在 `raw/`;包含敏感账号数据的原件没有放入可分享证据包。
|
||||
- 站内事件库使用 SQLite backup API 留存一致性副本;运营台控制文件也已封存。
|
||||
- 本地 `evidence/EXPORT_SHA256.json` 校验导出文件;`evidence/SHA256SUMS.json` 保存首次取证时原始副本哈希。后续原始文件另有用途/更新时间,不用当前在线文件替代封存副本。
|
||||
|
||||
## 已实施的加固
|
||||
|
||||
| 措施 | 结果与兼容性 |
|
||||
|---|---|
|
||||
| 管理员访问 | 本机生成独立 Ed25519 密钥,校验新会话与 sudo 成功后关闭密码登录;固定主机公钥,防止静默连接到不同主机 |
|
||||
| SSH | 禁止 root 直登;禁止四个异常账号;最多 3 次认证;关闭 X11;提高认证日志级别;仅 reload,未停止站点 |
|
||||
| 账号 | 四个异常账号锁密码、改为 nologin、分配非零独立 UID;清除其 sudo/root/adm 组成员关系,移除 `99-pakchoi` 免密规则;现在仅 root 为 UID=0 |
|
||||
| 主目录权限 | `/home/ubuntu` 原权限为 777,已改为 755;`.ssh` 700、授权公钥文件 600 |
|
||||
| 持久化 | 清除 2 条重建 pakchoi 和 2 条重启异常 amco 容器的 cron;禁用指向同一不存在容器的 `sys-health.timer` |
|
||||
| 用户主动安装服务 | 保留 ShellCrash 的原有 cron 和 FRP 服务,FRP 检测为 active;未更改 Docker 转发链 |
|
||||
| 防火墙 | 持久化定向 IPv4/IPv6 INPUT 规则;封禁 5 个成功后门源;限制公网直接访问 3306/4007/8007,保留回环、内网及已知业务调用端;80/443 保持开放 |
|
||||
| VIP 边缘 | 确认源码未使用 Server Actions 和 next/image 后,分别拒绝相应请求头及图片优化路由;不阻止正常支付 POST |
|
||||
| 样本 | 原始目录整体隔离,样本移除执行权限,证据仍保留 |
|
||||
| 持续检查 | 每 5 分钟检查额外 UID=0、已知异常进程特征、SSH 退回密码模式、cron 后门和主目录权限;64MB 内存/10% CPU 上限,告警保存在本机 journal 和 `monitor-latest.json`,未向任何外部人员发送消息 |
|
||||
|
||||
SSH 新会话已验证服务端只接受 `publickey`。本机可用:
|
||||
|
||||
```powershell
|
||||
ssh hackrobot-129
|
||||
```
|
||||
|
||||
私钥在本机 `C:\Users\Administrator\.ssh\hackrobot_129_incident_20261126_ed25519`,已限制 ACL;它不在报告或分享包内。其他电脑和仅会密码登录的旧脚本需另行配置密钥,旧密码现在不能用于 SSH 登录。账号记录未因证据调查被再次拉黑或解封。
|
||||
|
||||
## 验证与尚未完成的工作
|
||||
|
||||
加固后公开网站及 PC、H5、微信 UA 首页、课程入口四条浏览器支付链路通过,H5 为 303、微信路径提交到 XorPay。真实微信客户端付款仍没有执行。FRP 正常,原业务服务未整体重启,已有正式构建未被这轮账号加固替换。
|
||||
|
||||
13:12 的最终采样:VIP 首页 200 / 0.344 秒,运营台首页 200 / 0.340 秒,运营控制接口未认证返回 401;禁用的图片优化入口为 404、带 Next-Action 头的请求为 405。监测无告警,FRP、支付服务、防火墙及巡检 timer 均正常;负载 0.02 / 0.10 / 0.16,可用内存约 601MB。
|
||||
|
||||
**这次完成的是取证、遏制和在线加固,不能把曾被 root 控制的系统宣称为完全可信。**仍需:
|
||||
|
||||
1. 在可信新镜像上重建主机并迁移经过核验的业务数据,恢复后再切 DNS/流量;避免直接复制旧主机的系统目录、启动脚本、密钥和整个 node_modules。
|
||||
2. 分批轮换云账号/API、支付商户、PocketBase、MinIO、FRP、运营台等曾落地到主机的凭据与会话密钥,完成依赖验证;不能把“SSH 关闭密码”误当作这些凭据已全部轮换。本轮没有擅自更改外部支付商户密钥。
|
||||
3. 升级当前 Next.js `16.1.6` 及其他同机应用依赖。NPM 官方安全查询返回多项公开高危/严重漏洞;目前 VIP 已封禁未使用的相关入口,但**边缘缓解不能代替框架升级**,其他应用也需独立构建回归。
|
||||
4. 调取腾讯云控制台操作审计、云助手执行历史、主机安全历史告警、安全组变更,以及管理电脑相应日期的运维记录。现有主机权限不能替代云控制面审计权限,尚未取得这些日志。
|
||||
5. 向来源主机的云厂商提出日志保全请求,必要时由警方依法获取租户实名和控制链路。不能仅凭 IP 和昵称定位自然人,也不能据本报告公开指认某位用户。
|
||||
|
||||
## 证据索引
|
||||
|
||||
- `evidence/confirmed-backdoor-logins.json`:7 次成功认证及原始日志行。
|
||||
- `evidence/account-creation-evidence.txt`:创建、改密和提权日志。
|
||||
- `evidence/user-ip-correlation.json`:全部用户范围下的候选 IP 比对、历史封禁和身份关联。
|
||||
- `evidence/target-user-records.json`:目标账号在服务端的对应记录,含邮箱未验证状态。
|
||||
- `evidence/user-ip-event-evidence.json`:候选地址的事件 ID、时间、会话与上报身份,不含密码、聊天内容。
|
||||
- `evidence/malware-file-hashes.json`:13 个文件元数据与 SHA-256。
|
||||
- `evidence/rdap-attribution.json`:注册网络查询结果。
|
||||
- `evidence/dependency-advisories.json`:官方安全通报查询结果;不作为原始入侵路径已证实的依据。
|
||||
|
||||
分享包包含账号关联信息,应仅用于自己的事件调查和交给有权处理的云厂商/执法机关,不宜公开上传。
|
||||
BIN
apps/hackrobot/docs/security/hackrobot-129-20261126-report.zip
Normal file
BIN
apps/hackrobot/docs/security/hackrobot-129-20261126-report.zip
Normal file
Binary file not shown.
@ -0,0 +1,84 @@
|
||||
{
|
||||
"generated_at": "2026-11-26T13:35:11.309912+08:00",
|
||||
"retained_events": 14,
|
||||
"source_count": 2,
|
||||
"archive": {
|
||||
"newly_archived": 14,
|
||||
"last_id": 14,
|
||||
"chain": "137eefb29b2ab6fb6806b7984d7ca5b674a7992fff543a00cac48fd69935a8c6"
|
||||
},
|
||||
"sources": [
|
||||
{
|
||||
"ip": "183.93.112.226",
|
||||
"trap_events": 13,
|
||||
"protocols": {
|
||||
"http": 11,
|
||||
"ssh": 2
|
||||
},
|
||||
"first": 1795670679.4763875,
|
||||
"last": 1795671102.9405503,
|
||||
"last_event_ids": [
|
||||
14,
|
||||
13,
|
||||
12,
|
||||
11,
|
||||
10,
|
||||
9,
|
||||
8,
|
||||
7,
|
||||
6,
|
||||
5
|
||||
],
|
||||
"verified_selftest_events": 13,
|
||||
"site_identifiers_same_ip": [
|
||||
"oBVe71TMQc1kK059sWTtfam51c6M",
|
||||
"oBVe71a4Y7rzQrECpODJgWHXgG_M",
|
||||
"user1788751124082",
|
||||
"user1794204998119",
|
||||
"user1794712509791",
|
||||
"user1795137985002",
|
||||
"user1795667234555"
|
||||
],
|
||||
"self_claimed_identifiers": [
|
||||
"Nomadro-Honeypot-Selftest-6c9c3079a47d"
|
||||
],
|
||||
"historical_ips_for_claimed_identifier": {
|
||||
"Nomadro-Honeypot-Selftest-6c9c3079a47d": []
|
||||
},
|
||||
"active_blocks": [],
|
||||
"historical_blocks": [],
|
||||
"site_first_ts": 1795664131.5821488,
|
||||
"site_last_ts": 1795670887.1890862,
|
||||
"association_level": "same_network_observed",
|
||||
"non_selftest_events": 0,
|
||||
"attribution": "unconfirmed; a probe/IP match does not establish a person or successful intrusion"
|
||||
},
|
||||
{
|
||||
"ip": "127.0.0.1",
|
||||
"trap_events": 1,
|
||||
"protocols": {
|
||||
"http": 1
|
||||
},
|
||||
"first": 1795670635.6968615,
|
||||
"last": 1795670635.6968615,
|
||||
"last_event_ids": [
|
||||
1
|
||||
],
|
||||
"verified_selftest_events": 1,
|
||||
"site_identifiers_same_ip": [
|
||||
"dbg",
|
||||
"hot",
|
||||
"oBVe71TMQc1kK059sWTtfam51c6M"
|
||||
],
|
||||
"self_claimed_identifiers": [],
|
||||
"historical_ips_for_claimed_identifier": {},
|
||||
"active_blocks": [],
|
||||
"historical_blocks": [],
|
||||
"site_first_ts": 1793608427.040728,
|
||||
"site_last_ts": 1795665781.9783242,
|
||||
"association_level": "same_network_observed",
|
||||
"non_selftest_events": 0,
|
||||
"attribution": "unconfirmed; a probe/IP match does not establish a person or successful intrusion"
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
{
|
||||
"date": "2026-11-26",
|
||||
"target": "129.204.21.129",
|
||||
"domains": ["vip.hackrobot.cn", "admin.hackrobot.cn"],
|
||||
"http_fake_login_status": 401,
|
||||
"http_fake_configuration_status": 200,
|
||||
"configuration_contains_only_decoy_values": true,
|
||||
"forged_client_ip_header_did_not_override_peer": true,
|
||||
"ssh22_targeted_redirect_test": "public test reached reject-only SSH; temporary operator rule removed",
|
||||
"normal_pinned_administrator_ssh_after_test": "passed",
|
||||
"sandbox_uid": 995,
|
||||
"sandbox_production_configuration_read": "denied",
|
||||
"sandbox_production_event_database_read": "denied",
|
||||
"sandbox_evidence_directory_read": "denied",
|
||||
"sandbox_new_loopback_database_connection": "denied",
|
||||
"sandbox_new_public_connection": "denied",
|
||||
"memory_max_bytes": 134217728,
|
||||
"memory_swap_max_bytes": 0,
|
||||
"cpu_quota_one_core_percent": 20,
|
||||
"observed_memory_bytes": 26750976,
|
||||
"restart_count": 0,
|
||||
"nginx_bounded_12_request_burst_status_counts": {"200": 7, "429": 5},
|
||||
"business_homepage_after_burst_status": 200,
|
||||
"business_homepage_after_burst_seconds": 0.343,
|
||||
"pc_h5_wechat_home_course_browser_payment_cases": "4 passed",
|
||||
"automated_regression_cases": "4 passed",
|
||||
"initial_retained_events": 14,
|
||||
"initial_verified_selftest_events": 14,
|
||||
"initial_real_attacker_capture_claimed": false,
|
||||
"root_archive_chain_verified_events": 14,
|
||||
"root_archive_chain_sha256": "137eefb29b2ab6fb6806b7984d7ca5b674a7992fff543a00cac48fd69935a8c6",
|
||||
"report_interval_seconds": 300,
|
||||
"direct_public_2222_reachability": "upstream-blocked; known-hostile sources use targeted redirect from already-open public 22",
|
||||
"business_frontend_rebuilt_or_replaced_this_task": false
|
||||
}
|
||||
67
apps/hackrobot/honeypot/README.md
Normal file
67
apps/hackrobot/honeypot/README.md
Normal file
@ -0,0 +1,67 @@
|
||||
# Hackrobot 蜜罐
|
||||
|
||||
部署对象仅为 129 服务器及 `vip.hackrobot.cn` / `admin.hackrobot.cn`,与 Nomadro 后台隔离。2026-11-26 已部署并完成外部验证。
|
||||
|
||||
## 诱捕入口
|
||||
|
||||
- 两个域名各 8 个精确路径:`/.env`、`/.git/config`、`/wp-login.php`、`/phpmyadmin/`、`/phpmyadmin/index.php`、`/actuator/env`、`/backup.sql`、`/api/debug`。只有这些路径转到蜜罐,不改变正常业务 API。
|
||||
- 假配置只含诱饵值,假登录永远拒绝,不发放任何真实权限。
|
||||
- 拒绝式 SSH 服务监听 `2222`。独立公网访问该端口在验证时被上游拦截,因此没有宣称它对整个公网开放。
|
||||
- 已确认的 5 个后门源再次访问公网 `22` 时,主机 NAT 将其转到 `2222` 的假 SSH;正常管理来源仍进入原来的 SSH 密钥服务。只针对已确认来源,不因某个站内用户曾拉黑就切换其 SSH。
|
||||
- 通过短时、自动回滚的定向测试,在实际公网 22 端口验证了假 SSH 的横幅和认证拒绝;移除测试规则后,管理员固定主机公钥的密钥登录仍成功。
|
||||
|
||||
## 隔离与资源
|
||||
|
||||
`hackrobot-honeypot.service` 使用专用无登录权限账号,非 root、无额外 capability,不能读取 `/www`、业务数据库目录、管理主目录或取证目录。IPv4/IPv6 OUTPUT 规则拒绝该 UID 的所有新连接,包括到回环数据库的连接。已在服务的实际 mount namespace 内验证读文件被拒,以及本机数据库和公网连接被拒。
|
||||
|
||||
Nginx 不向蜜罐转发 Authorization、PB 会话、管理 token 或其他任意原始请求头;只传服务器确认的源 IP/端口、Host、UA、正文类型/长度及两个非认证关联 cookie。外部伪造 `X-Honeypot-Client-IP` 不能覆盖真实来源。
|
||||
|
||||
资源上限:128MB 内存、禁止 Swap、20% 单核 CPU、32 任务、128 文件描述符。HTTP 与 SSH 各最多 4 个工作连接,单次正文最多 16KB。HTTP 入口另限制每 IP 每秒 2 次、突发 4 次、并发 2 个,超限返回 429;12 次受控短突发中 5 次被限流,随后业务首页正常返回 200。
|
||||
|
||||
记录使用有界队列,单 IP 每分钟最多 60 条。数据库保留最近约 5,000 条(每 100 条批次淘汰,最多暂超 99 条);单事件限制大小,单文件 32MB 上限。高压下会丢弃超额记录,不能将记录数当作全部网络攻击次数。
|
||||
|
||||
## 用户/IP 自动关联
|
||||
|
||||
每 5 分钟运行独立的 `hackrobot-honeypot-report.service`,只读扫描全量站内事件及运营控制文件,匹配所有用户,包括未拉黑用户。蜜罐进程本身不获得这些数据的访问权限。
|
||||
|
||||
报告区分:
|
||||
|
||||
- `same_network_observed`:探测来源 IP 与站内访问 IP 相同。
|
||||
- `self_claimed_only`:只有请求中自称的账号/访客标识,不能当作登录证明。
|
||||
- `no_known_user_match`:没有当前可见的站内关联。
|
||||
- `active_blocks` / `historical_blocks`:当前封禁及历史封禁记录。
|
||||
- `verified_selftest_events`:由管理员核实、单独登记的上线测试事件,不能作为真实黑客命中。
|
||||
|
||||
同一 IP、昵称、客户端 cookie 或输入的用户名均不能独立证明自然人身份、入侵成功或与过往入侵者是同一人。报告不会自动拉黑、撤销会员或认定某位用户是攻击者。
|
||||
|
||||
## 记录与查看
|
||||
|
||||
原始诱捕库:`/var/lib/hackrobot-honeypot/events.db`。密码、真实会话和完整正文不落明文;密码使用蜜罐独立随机密钥的 HMAC-SHA256 指纹,蜜罐 SSH 主机私钥与业务 SSH 完全分开。
|
||||
|
||||
自动关联报告:`/opt/hackrobot-backup/security/honeypot/latest-report.json`,仅 root 可读。该报告不通过公网或未认证接口公开,也未向外部人员自动发送消息。
|
||||
|
||||
每次更新还将增量记录保存到同目录的 `events.archive.jsonl`,串联 SHA-256 校验并保存检查点。诱捕进程无法读写此目录,因而不能直接修改已归档的记录。归档每约 25MB 轮转,保留当前文件和前两份;一次批次最多 5,000 条,文件可能暂超阈值。不把这种同机归档描述为能抵御整台主机再次获得 root 的攻击。
|
||||
|
||||
本机查看:
|
||||
|
||||
```powershell
|
||||
ssh hackrobot-129 "sudo cat /opt/hackrobot-backup/security/honeypot/latest-report.json"
|
||||
```
|
||||
|
||||
立即更新报告:
|
||||
|
||||
```powershell
|
||||
ssh hackrobot-129 "sudo systemctl start hackrobot-honeypot-report.service"
|
||||
```
|
||||
|
||||
低交互蜜罐从启用后收集新证据,不能反向证明过去的攻击归属;它也不能代替曾遭 root 入侵主机的可信重建。
|
||||
|
||||
## 测试、部署和回滚
|
||||
|
||||
仓库根目录运行 `python -m unittest discover -s apps/hackrobot/honeypot -p 'test_*.py' -v`。4 项回归覆盖凭据脱敏、SSH 拒绝和无命令会话、限额、全用户关联与自称身份区分。
|
||||
|
||||
生产源码在 `/opt/hackrobot-honeypot/`,依赖隔离在 `deps/`。首次部署脚本 `deploy.py` 要求依赖已独立安装并已有发版前快照;检测到同日安装快照后会停止,防止误覆盖。不要为更新代码盲目重复首次部署流程。
|
||||
|
||||
发版前完整快照:`/opt/hackrobot-backup/snapshots/20261126_131704_pre_honeypot_20261126/`。蜜罐配置与防火墙备份:`/opt/hackrobot-backup/security/honeypot-install-20261126/`。
|
||||
|
||||
需要停用时,从仓库根目录执行 `python apps/hackrobot/honeypot/rollback.py`:只撤销蜜罐精确路径、定向 NAT、蜜罐额外规则和服务,不放开 SSH 密码、不恢复后门账号、不删除证据或改动现有业务包。
|
||||
124
apps/hackrobot/honeypot/deploy.py
Normal file
124
apps/hackrobot/honeypot/deploy.py
Normal file
@ -0,0 +1,124 @@
|
||||
"""Deploy decoys only to hackrobot 129. No production frontend changes."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "deploy"))
|
||||
from _ssh import connect
|
||||
|
||||
REMOTE_INSTALL = r'''
|
||||
from pathlib import Path
|
||||
import hashlib,json,os,pwd,shutil,subprocess,time,urllib.request
|
||||
root=Path('/opt/hackrobot-honeypot')
|
||||
snapshot=Path('/opt/hackrobot-backup/security/honeypot-install-20261126')
|
||||
assert not snapshot.exists(), 'install already attempted; inspect before retry'
|
||||
snapshot.mkdir(mode=0o700)
|
||||
run=lambda args: subprocess.run(args,check=True,capture_output=True,text=True,timeout=25)
|
||||
try: user=pwd.getpwnam('hackrobot-honeypot')
|
||||
except KeyError:
|
||||
run(['useradd','--system','--no-create-home','--home-dir','/nonexistent','--shell','/usr/sbin/nologin','hackrobot-honeypot'])
|
||||
user=pwd.getpwnam('hackrobot-honeypot')
|
||||
assert user.pw_uid!=0
|
||||
for name in ['server.py','report.py','requirements.txt']:
|
||||
shutil.copy2(Path('/tmp/hackrobot-honeypot-stage')/name,root/name);os.chmod(root/name,0o644)
|
||||
Path('/opt/hackrobot-backup/security/honeypot').mkdir(mode=0o700,exist_ok=True)
|
||||
unit=Path('/etc/systemd/system/hackrobot-honeypot.service')
|
||||
assert not unit.exists()
|
||||
shutil.copy2('/tmp/hackrobot-honeypot-stage/hackrobot-honeypot.service',unit)
|
||||
Path('/etc/systemd/system/hackrobot-honeypot-report.service').write_text('[Unit]\nDescription=Correlate decoy sources against all VIP users\n[Service]\nType=oneshot\nExecStart=/usr/bin/python3 /opt/hackrobot-honeypot/report.py\nNice=15\nMemoryMax=64M\nCPUQuota=10%\nNoNewPrivileges=yes\nProtectSystem=strict\nReadWritePaths=/opt/hackrobot-backup/security/honeypot\n')
|
||||
Path('/etc/systemd/system/hackrobot-honeypot-report.timer').write_text('[Unit]\nDescription=Update honeypot user-IP association every five minutes\n[Timer]\nOnBootSec=2m\nOnUnitActiveSec=5m\n[Install]\nWantedBy=timers.target\n')
|
||||
# Block every NEW outbound connection by the dedicated decoy UID, including
|
||||
# connections to loopback business databases. Established replies still work.
|
||||
firewall=Path('/usr/local/sbin/hackrobot-security-firewall')
|
||||
shutil.copy2(firewall,snapshot/'firewall.before')
|
||||
text=firewall.read_text()
|
||||
assert 'honeypot egress isolation' not in text
|
||||
text+='\n# honeypot egress isolation\n'
|
||||
for tool in ['iptables','ip6tables']:
|
||||
rule=['OUTPUT','-m','owner','--uid-owner',str(user.pw_uid),'-m','conntrack','--ctstate','NEW','-j','REJECT']
|
||||
import shlex
|
||||
text+=shlex.join([tool,'-w','-C']+rule)+' 2>/dev/null || '+shlex.join([tool,'-w','-I','OUTPUT','1']+rule[1:])+'\n'
|
||||
# The known hostile sources remain blocked from business ports but may enter
|
||||
# the isolated SSH decoy. Do not open their access to SSH 22 or the web app.
|
||||
text+='iptables -w -C HACKROBOT_IR -p tcp --dport 2222 -j ACCEPT 2>/dev/null || iptables -w -I HACKROBOT_IR 1 -p tcp --dport 2222 -j ACCEPT\n'
|
||||
text+='iptables -w -t nat -N HACKROBOT_HP 2>/dev/null || true\niptables -w -t nat -F HACKROBOT_HP\n'
|
||||
for ip in ['101.33.68.140','101.33.196.102','118.178.120.173','47.102.136.164','43.157.226.233']:
|
||||
text+='iptables -w -t nat -A HACKROBOT_HP -s '+ip+' -p tcp --dport 22 -j REDIRECT --to-ports 2222\n'
|
||||
text+='iptables -w -t nat -C PREROUTING -p tcp --dport 22 -j HACKROBOT_HP 2>/dev/null || iptables -w -t nat -I PREROUTING 1 -p tcp --dport 22 -j HACKROBOT_HP\n'
|
||||
firewall.write_text(text);os.chmod(firewall,0o700)
|
||||
run([str(firewall)])
|
||||
run(['systemctl','daemon-reload'])
|
||||
run(['systemctl','enable','--now','hackrobot-honeypot.service'])
|
||||
for attempt in range(40):
|
||||
try:
|
||||
with urllib.request.urlopen('http://127.0.0.1:4012/.env',timeout=1) as response:
|
||||
assert response.status==200
|
||||
break
|
||||
except Exception:
|
||||
if attempt==39:raise
|
||||
time.sleep(.5)
|
||||
paths=['/.env','/.git/config','/wp-login.php','/phpmyadmin/','/phpmyadmin/index.php','/actuator/env','/backup.sql','/api/debug']
|
||||
zones=Path('/www/server/panel/vhost/nginx/00-hackrobot-honeypot-zones.conf')
|
||||
assert not zones.exists()
|
||||
zones.write_text('limit_req_zone $binary_remote_addr zone=hackrobot_honeypot_req:1m rate=2r/s;\nlimit_conn_zone $binary_remote_addr zone=hackrobot_honeypot_conn:1m;\n')
|
||||
configs=[]
|
||||
for host in ['vip.hackrobot.cn','admin.hackrobot.cn']:
|
||||
path=Path('/www/server/panel/vhost/nginx/extension')/host/'honeypot-decoys.conf'
|
||||
assert not path.exists()
|
||||
blocks=[]
|
||||
for target in paths:
|
||||
blocks.append('location = '+target+' {\n'+""" proxy_pass http://127.0.0.1:4012;
|
||||
proxy_pass_request_headers off;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Honeypot-Client-IP $remote_addr;
|
||||
proxy_set_header X-Honeypot-Client-Port $remote_port;
|
||||
proxy_set_header User-Agent $http_user_agent;
|
||||
proxy_set_header Content-Type $content_type;
|
||||
proxy_set_header Content-Length $content_length;
|
||||
proxy_set_header Cookie "nomadvip_anon_uid=$cookie_nomadvip_anon_uid; hp_session=$cookie_hp_session";
|
||||
proxy_set_header Connection close;
|
||||
proxy_cache off;
|
||||
proxy_no_cache 1;
|
||||
limit_req zone=hackrobot_honeypot_req burst=4 nodelay;
|
||||
limit_req_status 429;
|
||||
limit_conn hackrobot_honeypot_conn 2;
|
||||
limit_conn_status 429;
|
||||
client_max_body_size 16k;
|
||||
proxy_connect_timeout 1s;
|
||||
proxy_send_timeout 3s;
|
||||
proxy_read_timeout 3s;
|
||||
add_header Cache-Control "no-store" always;
|
||||
}""")
|
||||
path.write_text('\n'.join(blocks)+'\n');configs.append(path)
|
||||
try:
|
||||
run(['/www/server/nginx/sbin/nginx','-t'])
|
||||
run(['/www/server/nginx/sbin/nginx','-s','reload'])
|
||||
except BaseException:
|
||||
for path in configs:path.unlink(missing_ok=True)
|
||||
zones.unlink(missing_ok=True)
|
||||
raise
|
||||
run(['systemctl','enable','--now','hackrobot-honeypot-report.timer'])
|
||||
run(['systemctl','start','hackrobot-honeypot-report.service'])
|
||||
record={'installed_at':time.strftime('%Y-%m-%d %H:%M:%S %z'),'service_uid':user.pw_uid,'http_bind':'127.0.0.1:4012','ssh_bind':'0.0.0.0:2222','paths':paths,'domains':['vip.hackrobot.cn','admin.hackrobot.cn'],'outbound_new_connections':'rejected IPv4 and IPv6','code_sha256':hashlib.sha256((root/'server.py').read_bytes()).hexdigest(),'snapshot':str(snapshot)}
|
||||
(snapshot/'INSTALLED.json').write_text(json.dumps(record,indent=2))
|
||||
print(json.dumps(record))
|
||||
'''
|
||||
|
||||
|
||||
def main():
|
||||
root=Path(__file__).resolve().parent
|
||||
c=connect()
|
||||
s=c.open_sftp()
|
||||
try:s.mkdir('/tmp/hackrobot-honeypot-stage')
|
||||
except OSError:pass
|
||||
for name in ['server.py','report.py','requirements.txt','hackrobot-honeypot.service']:
|
||||
s.put(str(root/name),'/tmp/hackrobot-honeypot-stage/'+name)
|
||||
with s.file('/tmp/install-hackrobot-honeypot.py','w') as f:f.write(REMOTE_INSTALL)
|
||||
s.close()
|
||||
_,o,e=c.exec_command('sudo python3 /tmp/install-hackrobot-honeypot.py',timeout=100)
|
||||
print(o.read().decode('utf-8','replace'));print(e.read().decode('utf-8','replace'))
|
||||
status=o.channel.recv_exit_status();c.close()
|
||||
raise SystemExit(status)
|
||||
|
||||
|
||||
if __name__=='__main__':main()
|
||||
48
apps/hackrobot/honeypot/hackrobot-honeypot.service
Normal file
48
apps/hackrobot/honeypot/hackrobot-honeypot.service
Normal file
@ -0,0 +1,48 @@
|
||||
[Unit]
|
||||
Description=Hackrobot bounded reject-only HTTP and SSH decoys
|
||||
After=network-online.target hackrobot-security-firewall.service
|
||||
Wants=network-online.target
|
||||
Requires=hackrobot-security-firewall.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=hackrobot-honeypot
|
||||
Group=hackrobot-honeypot
|
||||
WorkingDirectory=/opt/hackrobot-honeypot
|
||||
Environment=PYTHONPATH=/opt/hackrobot-honeypot/deps
|
||||
Environment=PYTHONDONTWRITEBYTECODE=1
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
ExecStart=/usr/bin/python3 /opt/hackrobot-honeypot/server.py
|
||||
StateDirectory=hackrobot-honeypot
|
||||
StateDirectoryMode=0700
|
||||
UMask=0077
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
MemoryMax=128M
|
||||
MemorySwapMax=0
|
||||
CPUQuota=20%
|
||||
TasksMax=32
|
||||
LimitNOFILE=128
|
||||
LimitFSIZE=32M
|
||||
Nice=10
|
||||
NoNewPrivileges=yes
|
||||
CapabilityBoundingSet=
|
||||
ProtectSystem=strict
|
||||
ProtectHome=yes
|
||||
ReadWritePaths=/var/lib/hackrobot-honeypot
|
||||
InaccessiblePaths=/www /home /root /opt/nomadmini /opt/vip-track /opt/hackrobot-backup
|
||||
PrivateTmp=yes
|
||||
PrivateDevices=yes
|
||||
ProtectKernelTunables=yes
|
||||
ProtectKernelModules=yes
|
||||
ProtectControlGroups=yes
|
||||
ProtectProc=invisible
|
||||
ProcSubset=pid
|
||||
LockPersonality=yes
|
||||
RestrictSUIDSGID=yes
|
||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
||||
SystemCallArchitectures=native
|
||||
SystemCallFilter=~@mount @reboot @swap @privileged
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
137
apps/hackrobot/honeypot/report.py
Normal file
137
apps/hackrobot/honeypot/report.py
Normal file
@ -0,0 +1,137 @@
|
||||
"""Privileged, read-only correlation job; not loaded by the decoy process."""
|
||||
from __future__ import annotations
|
||||
|
||||
import collections
|
||||
import datetime
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import sqlite3
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
|
||||
STATE = Path("/var/lib/hackrobot-honeypot")
|
||||
OUTPUT = Path("/opt/hackrobot-backup/security/honeypot")
|
||||
CONTROL_PATH = Path("/www/wwwroot/nomadvip/data/ops-control.json")
|
||||
TRACK_DB = Path("/opt/vip-track/events.db")
|
||||
|
||||
|
||||
def archive_events(rows):
|
||||
"""Checkpoint evidence outside the decoy UID's readable/writable tree."""
|
||||
checkpoint = OUTPUT / "archive-checkpoint.json"
|
||||
previous = json.loads(checkpoint.read_text()) if checkpoint.exists() else {"last_id": 0, "chain": "0" * 64}
|
||||
highest = max((row[0] for row in rows), default=0)
|
||||
if highest < previous["last_id"]:
|
||||
return {"warning": "event ID rollback detected; review decoy database integrity"}
|
||||
archive = OUTPUT / "events.archive.jsonl"
|
||||
if archive.exists() and archive.stat().st_size > 25 * 1024 * 1024:
|
||||
oldest = OUTPUT / "events.archive.2.jsonl"
|
||||
oldest.unlink(missing_ok=True)
|
||||
older = OUTPUT / "events.archive.1.jsonl"
|
||||
if older.exists():
|
||||
os.replace(older, oldest)
|
||||
os.replace(archive, older)
|
||||
chain, last_id, added = previous["chain"], previous["last_id"], 0
|
||||
with archive.open("a", encoding="utf-8") as out:
|
||||
archive.chmod(0o600)
|
||||
for event_id, ts, protocol, ip, raw in reversed(rows):
|
||||
if event_id <= last_id:
|
||||
continue
|
||||
record = {"id": event_id, "ts": ts, "protocol": protocol, "ip": ip, "detail": json.loads(raw), "previous_hash": chain}
|
||||
chain = hashlib.sha256(json.dumps(record, sort_keys=True, ensure_ascii=True).encode()).hexdigest()
|
||||
out.write(json.dumps({"record": record, "sha256": chain}, ensure_ascii=True) + "\n")
|
||||
last_id, added = event_id, added + 1
|
||||
out.flush()
|
||||
os.fsync(out.fileno())
|
||||
temp = OUTPUT / "archive-checkpoint.tmp"
|
||||
temp.write_text(json.dumps({"last_id": last_id, "chain": chain}))
|
||||
temp.chmod(0o600)
|
||||
os.replace(temp, checkpoint)
|
||||
return {"newly_archived": added, "last_id": last_id, "chain": chain}
|
||||
|
||||
|
||||
def report():
|
||||
OUTPUT.mkdir(parents=True, mode=0o700, exist_ok=True)
|
||||
now = datetime.datetime.now(datetime.timezone(datetime.timedelta(hours=8))).isoformat()
|
||||
db = sqlite3.connect(f"file:{STATE / 'events.db'}?mode=ro", uri=True, timeout=2)
|
||||
rows = db.execute("SELECT id,ts,protocol,ip,detail FROM events ORDER BY id DESC LIMIT 5000").fetchall()
|
||||
db.close()
|
||||
archive = archive_events(rows)
|
||||
tests_path = OUTPUT / "verified-selftest-event-ids.json"
|
||||
verified_tests = set(json.loads(tests_path.read_text())) if tests_path.exists() else set()
|
||||
ips = {row[3] for row in rows}
|
||||
requested = set()
|
||||
for row in rows:
|
||||
detail = json.loads(row[4])
|
||||
requested.update(str(detail[key]) for key in ["claimed_user_id", "claimed_username"] if detail.get(key))
|
||||
control = json.loads(CONTROL_PATH.read_text())
|
||||
blocked = {row["userId"]: row for row in control.get("blocks", [])}
|
||||
archived = collections.defaultdict(list)
|
||||
for item in control.get("archives", []):
|
||||
archived[item["userId"]].append(item)
|
||||
ip_users = collections.defaultdict(set)
|
||||
ip_dates = collections.defaultdict(list)
|
||||
uid_ips = collections.defaultdict(set)
|
||||
site = sqlite3.connect(f"file:{TRACK_DB}?mode=ro", uri=True, timeout=2)
|
||||
for ip, openid, raw, ts in site.execute("SELECT ip,openid,props,ts FROM events"):
|
||||
try:
|
||||
props = json.loads(raw or "{}")
|
||||
if not isinstance(props, dict):
|
||||
continue
|
||||
ids = {str(props[key]) for key in ["user_id", "userId", "wechat_userid", "userid", "email"] if props.get(key)}
|
||||
if openid:
|
||||
ids.add(openid)
|
||||
href = str(props.get("href") or "")
|
||||
query = parse_qs(urlsplit(href).query, max_num_fields=100)
|
||||
ids.update(value for key in ["userid", "user_id", "openid"] for value in query.get(key, []) if value)
|
||||
except (ValueError, TypeError):
|
||||
continue
|
||||
if ip in ips:
|
||||
ip_users[ip].update(ids)
|
||||
ip_dates[ip].append(float(ts))
|
||||
for uid in ids & requested:
|
||||
uid_ips[uid].add(ip)
|
||||
site.close()
|
||||
summary = {}
|
||||
for event_id, ts, protocol, ip, raw in rows:
|
||||
detail = json.loads(raw)
|
||||
item = summary.setdefault(ip, {
|
||||
"ip": ip, "trap_events": 0, "protocols": collections.Counter(),
|
||||
"first": ts, "last": ts, "last_event_ids": [],
|
||||
"verified_selftest_events": 0,
|
||||
"site_identifiers_same_ip": sorted(ip_users[ip]),
|
||||
"self_claimed_identifiers": set(), "historical_ips_for_claimed_identifier": {},
|
||||
})
|
||||
item["trap_events"] += 1
|
||||
item["verified_selftest_events"] += int(event_id in verified_tests)
|
||||
item["protocols"][protocol] += 1
|
||||
item["first"] = min(item["first"], ts)
|
||||
item["last"] = max(item["last"], ts)
|
||||
if len(item["last_event_ids"]) < 10:
|
||||
item["last_event_ids"].append(event_id)
|
||||
for key in ["claimed_user_id", "claimed_username"]:
|
||||
if detail.get(key):
|
||||
uid = str(detail[key])
|
||||
item["self_claimed_identifiers"].add(uid)
|
||||
item["historical_ips_for_claimed_identifier"][uid] = sorted(uid_ips[uid])
|
||||
for ip, item in summary.items():
|
||||
ids = set(item["site_identifiers_same_ip"]) | item["self_claimed_identifiers"] | {ip}
|
||||
item["self_claimed_identifiers"] = sorted(item["self_claimed_identifiers"])
|
||||
item["active_blocks"] = [{"identifier": uid, "reason": blocked[uid].get("reason", "")} for uid in sorted(ids) if uid in blocked]
|
||||
item["historical_blocks"] = [{"identifier": uid, "reason": row.get("reason", ""), "createdAt": row.get("createdAt"), "unblockedAt": row.get("unblockedAt")} for uid in sorted(ids) for row in archived[uid]]
|
||||
if ip_dates[ip]:
|
||||
item["site_first_ts"] = min(ip_dates[ip])
|
||||
item["site_last_ts"] = max(ip_dates[ip])
|
||||
item["association_level"] = "same_network_observed" if ip_users[ip] else "self_claimed_only" if item["self_claimed_identifiers"] else "no_known_user_match"
|
||||
item["non_selftest_events"] = item["trap_events"] - item["verified_selftest_events"]
|
||||
item["attribution"] = "unconfirmed; a probe/IP match does not establish a person or successful intrusion"
|
||||
result = {"generated_at": now, "retained_events": len(rows), "source_count": len(summary), "archive": archive, "sources": sorted(summary.values(), key=lambda row: row["last"], reverse=True)}
|
||||
temp = OUTPUT / "latest-report.tmp"
|
||||
temp.write_text(json.dumps(result, ensure_ascii=False, indent=2))
|
||||
temp.chmod(0o600)
|
||||
os.replace(temp, OUTPUT / "latest-report.json")
|
||||
print(json.dumps({"sources": len(summary), "events": len(rows), "report": str(OUTPUT / 'latest-report.json')}))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
report()
|
||||
1
apps/hackrobot/honeypot/requirements.txt
Normal file
1
apps/hackrobot/honeypot/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
paramiko==4.0.0
|
||||
37
apps/hackrobot/honeypot/rollback.py
Normal file
37
apps/hackrobot/honeypot/rollback.py
Normal file
@ -0,0 +1,37 @@
|
||||
"""Remove only honeypot routing/listeners; retain logs and existing security."""
|
||||
from pathlib import Path
|
||||
import sys
|
||||
sys.path.insert(0,str(Path(__file__).resolve().parents[1]/'deploy'))
|
||||
from _ssh import connect
|
||||
|
||||
SCRIPT=r'''
|
||||
from pathlib import Path
|
||||
import pwd,shutil,subprocess
|
||||
run=lambda args: subprocess.run(args,check=False,capture_output=True,text=True,timeout=20)
|
||||
for host in ['vip.hackrobot.cn','admin.hackrobot.cn']:
|
||||
path=Path('/www/server/panel/vhost/nginx/extension')/host/'honeypot-decoys.conf'
|
||||
if path.exists():path.rename(path.with_suffix('.conf.disabled'))
|
||||
zones=Path('/www/server/panel/vhost/nginx/00-hackrobot-honeypot-zones.conf')
|
||||
if zones.exists():zones.rename(zones.with_suffix('.conf.disabled'))
|
||||
result=run(['/www/server/nginx/sbin/nginx','-t']);assert result.returncode==0,result.stderr
|
||||
assert run(['/www/server/nginx/sbin/nginx','-s','reload']).returncode==0
|
||||
run(['systemctl','disable','--now','hackrobot-honeypot-report.timer','hackrobot-honeypot.service'])
|
||||
run(['iptables','-w','-t','nat','-D','PREROUTING','-p','tcp','--dport','22','-j','HACKROBOT_HP'])
|
||||
run(['iptables','-w','-t','nat','-F','HACKROBOT_HP'])
|
||||
run(['iptables','-w','-t','nat','-X','HACKROBOT_HP'])
|
||||
uid=pwd.getpwnam('hackrobot-honeypot').pw_uid
|
||||
for tool in ['iptables','ip6tables']:
|
||||
run([tool,'-w','-D','OUTPUT','-m','owner','--uid-owner',str(uid),'-m','conntrack','--ctstate','NEW','-j','REJECT'])
|
||||
backup=Path('/opt/hackrobot-backup/security/honeypot-install-20261126/firewall.before')
|
||||
assert backup.exists()
|
||||
shutil.copy2(backup,'/usr/local/sbin/hackrobot-security-firewall')
|
||||
assert run(['/usr/local/sbin/hackrobot-security-firewall']).returncode==0
|
||||
print('Honeypot disabled. Business SSH, original containment firewall and all evidence retained.')
|
||||
'''
|
||||
|
||||
if __name__=='__main__':
|
||||
c=connect();s=c.open_sftp()
|
||||
with s.file('/tmp/rollback-hackrobot-honeypot.py','w') as f:f.write(SCRIPT)
|
||||
s.close();_,o,e=c.exec_command('sudo python3 /tmp/rollback-hackrobot-honeypot.py',timeout=60)
|
||||
print(o.read().decode('utf-8','replace'));print(e.read().decode('utf-8','replace'))
|
||||
status=o.channel.recv_exit_status();c.close();raise SystemExit(status)
|
||||
329
apps/hackrobot/honeypot/server.py
Normal file
329
apps/hackrobot/honeypot/server.py
Normal file
@ -0,0 +1,329 @@
|
||||
"""Bounded HTTP/SSH decoys. No shell, command execution, or business access."""
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
from contextlib import closing
|
||||
import hmac
|
||||
import ipaddress
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from pathlib import Path
|
||||
import queue
|
||||
import secrets
|
||||
import signal
|
||||
import socket
|
||||
import socketserver
|
||||
import sqlite3
|
||||
import threading
|
||||
import time
|
||||
from http.cookies import SimpleCookie
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
from urllib.parse import parse_qs, urlsplit
|
||||
|
||||
STATE = Path(os.environ.get("HONEYPOT_STATE", "/var/lib/hackrobot-honeypot"))
|
||||
MAX_BODY = 16384
|
||||
MAX_EVENTS = 5000
|
||||
|
||||
|
||||
def short(value: object, limit: int = 256) -> str:
|
||||
return str(value or "").replace("\x00", "")[:limit]
|
||||
|
||||
|
||||
class EventStore:
|
||||
def __init__(self, state: Path):
|
||||
self.state = state
|
||||
state.mkdir(parents=True, exist_ok=True)
|
||||
key = state / "fingerprint.key"
|
||||
if not key.exists():
|
||||
key.write_bytes(secrets.token_bytes(32))
|
||||
key.chmod(0o600)
|
||||
self.key = key.read_bytes()
|
||||
self.pending: queue.Queue = queue.Queue(maxsize=256)
|
||||
self.buckets: dict[str, tuple[int, int]] = {}
|
||||
self.lock = threading.Lock()
|
||||
self.dropped = 0
|
||||
self.database = state / "events.db"
|
||||
with closing(sqlite3.connect(self.database)) as db:
|
||||
db.execute("PRAGMA journal_mode=WAL")
|
||||
db.execute("CREATE TABLE IF NOT EXISTS events(id INTEGER PRIMARY KEY, ts REAL NOT NULL, protocol TEXT NOT NULL, ip TEXT NOT NULL, detail TEXT NOT NULL)")
|
||||
db.execute("CREATE INDEX IF NOT EXISTS events_ip_ts ON events(ip,ts)")
|
||||
db.commit()
|
||||
self.database.chmod(0o600)
|
||||
self.writer = threading.Thread(target=self._write, daemon=True)
|
||||
self.writer.start()
|
||||
|
||||
def fingerprint(self, value: str) -> str:
|
||||
return hmac.new(self.key, value.encode("utf-8", "replace"), hashlib.sha256).hexdigest()
|
||||
|
||||
def emit(self, protocol: str, ip: str, **detail):
|
||||
now = time.time()
|
||||
with self.lock:
|
||||
window, count = self.buckets.get(ip, (0, 0))
|
||||
current = int(now // 60)
|
||||
if window != current:
|
||||
window, count = current, 0
|
||||
self.buckets[ip] = (window, count + 1)
|
||||
if len(self.buckets) > 2048:
|
||||
self.buckets = {key: value for key, value in self.buckets.items() if value[0] == current}
|
||||
if len(self.buckets) > 2048:
|
||||
self.buckets.pop(next(iter(self.buckets)))
|
||||
if count >= 60:
|
||||
self.dropped += 1
|
||||
return
|
||||
try:
|
||||
serialized = json.dumps(detail, ensure_ascii=True)
|
||||
if len(serialized) > 4096:
|
||||
serialized = json.dumps({
|
||||
"event": short(detail.get("event"), 64), "truncated": True,
|
||||
"claimed_username": short(detail.get("claimed_username"), 64),
|
||||
"path": short(detail.get("path"), 256),
|
||||
"detail_fingerprint": self.fingerprint(serialized),
|
||||
})
|
||||
self.pending.put_nowait((now, protocol, ip, serialized))
|
||||
except queue.Full:
|
||||
with self.lock:
|
||||
self.dropped += 1
|
||||
|
||||
def _write(self):
|
||||
db = sqlite3.connect(self.database, timeout=2)
|
||||
db.execute("PRAGMA synchronous=NORMAL")
|
||||
written = 0
|
||||
while True:
|
||||
row = self.pending.get()
|
||||
if row is None:
|
||||
self.pending.task_done()
|
||||
break
|
||||
try:
|
||||
db.execute("INSERT INTO events(ts,protocol,ip,detail) VALUES(?,?,?,?)", row)
|
||||
written += 1
|
||||
if written % 100 == 0:
|
||||
db.execute("DELETE FROM events WHERE id <= (SELECT COALESCE(MAX(id),0)-? FROM events)", (MAX_EVENTS,))
|
||||
db.commit()
|
||||
except sqlite3.Error:
|
||||
db.rollback()
|
||||
logging.exception("honeypot event write failed")
|
||||
finally:
|
||||
self.pending.task_done()
|
||||
db.close()
|
||||
|
||||
def close(self):
|
||||
self.pending.join()
|
||||
self.pending.put(None)
|
||||
self.writer.join(timeout=5)
|
||||
|
||||
|
||||
class LimitedThreads(socketserver.ThreadingMixIn):
|
||||
daemon_threads = True
|
||||
request_queue_size = 8
|
||||
|
||||
def process_request(self, request, client_address):
|
||||
if not self.slots.acquire(blocking=False):
|
||||
self.shutdown_request(request)
|
||||
return
|
||||
try:
|
||||
super().process_request(request, client_address)
|
||||
except BaseException:
|
||||
self.slots.release()
|
||||
raise
|
||||
|
||||
def process_request_thread(self, request, client_address):
|
||||
try:
|
||||
super().process_request_thread(request, client_address)
|
||||
finally:
|
||||
self.slots.release()
|
||||
|
||||
|
||||
class DecoyHTTPServer(LimitedThreads, HTTPServer):
|
||||
def __init__(self, address, store: EventStore):
|
||||
self.store = store
|
||||
self.slots = threading.BoundedSemaphore(4)
|
||||
super().__init__(address, DecoyHTTP)
|
||||
|
||||
|
||||
class DecoyHTTP(BaseHTTPRequestHandler):
|
||||
server_version = "nginx"
|
||||
sys_version = ""
|
||||
|
||||
def setup(self):
|
||||
super().setup()
|
||||
self.connection.settimeout(5)
|
||||
|
||||
def log_message(self, *args):
|
||||
pass
|
||||
|
||||
def _handle(self):
|
||||
store: EventStore = self.server.store
|
||||
# Only the loopback nginx proxy may supply the authoritative peer IP.
|
||||
ip = self.client_address[0]
|
||||
try:
|
||||
if ipaddress.ip_address(ip).is_loopback:
|
||||
candidate = self.headers.get("X-Honeypot-Client-IP", "")
|
||||
ip = str(ipaddress.ip_address(candidate))
|
||||
except ValueError:
|
||||
pass
|
||||
try:
|
||||
length = int(self.headers.get("Content-Length", "0"))
|
||||
except ValueError:
|
||||
self.send_error(400)
|
||||
return
|
||||
if length < 0 or length > MAX_BODY or self.headers.get("Transfer-Encoding"):
|
||||
store.emit("http", ip, method=self.command, event="oversized_or_chunked", path=urlsplit(self.path).path[:512])
|
||||
self.send_error(413)
|
||||
return
|
||||
body = self.rfile.read(length) if length else b""
|
||||
fields = {}
|
||||
content_type = self.headers.get("Content-Type", "").split(";", 1)[0]
|
||||
try:
|
||||
if content_type == "application/x-www-form-urlencoded":
|
||||
fields = {key: values[0] for key, values in parse_qs(body.decode("utf-8", "replace"), max_num_fields=50).items()}
|
||||
elif content_type == "application/json":
|
||||
decoded = json.loads(body)
|
||||
fields = decoded if isinstance(decoded, dict) else {}
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
cookies = SimpleCookie()
|
||||
try:
|
||||
cookies.load(self.headers.get("Cookie", "")[:4096])
|
||||
except Exception:
|
||||
pass
|
||||
session = cookies.get("hp_session")
|
||||
nonce = session.value if session and len(session.value) == 32 and all(c in "0123456789abcdef" for c in session.value) else secrets.token_hex(16)
|
||||
anonymous = cookies.get("nomadvip_anon_uid")
|
||||
claimed_uid = anonymous.value if anonymous and anonymous.value.startswith("user") and anonymous.value[4:].isdigit() else ""
|
||||
username = next((short(fields.get(key), 128) for key in ["username", "user", "login", "log", "email"] if fields.get(key)), "")
|
||||
password = next((short(fields.get(key), MAX_BODY) for key in ["password", "pass", "pwd"] if fields.get(key)), "")
|
||||
parsed = urlsplit(self.path)
|
||||
store.emit(
|
||||
"http", ip, event="decoy_request", method=self.command,
|
||||
host=short(self.headers.get("Host"), 128), path=short(parsed.path, 512),
|
||||
query_keys=[short(key, 64) for key in sorted(parse_qs(parsed.query, max_num_fields=50))[:30]],
|
||||
source_port=short(self.headers.get("X-Honeypot-Client-Port"), 8),
|
||||
user_agent=short(self.headers.get("User-Agent")),
|
||||
claimed_user_id=short(claimed_uid, 64), claimed_username=username,
|
||||
password_fingerprint=store.fingerprint(password) if password else "",
|
||||
payload_fingerprint=hmac.new(store.key, body, hashlib.sha256).hexdigest() if body else "",
|
||||
cookie_fingerprint=store.fingerprint(nonce),
|
||||
)
|
||||
if parsed.path == "/.env":
|
||||
payload = b"APP_ENV=production\nDB_HOST=127.0.0.1\nDB_USER=backup_reader\nDB_PASSWORD=backup-reader-disabled\nSSH_PORT=22\n"
|
||||
status, mime = 200, "text/plain; charset=utf-8"
|
||||
elif parsed.path in ("/wp-login.php", "/phpmyadmin/", "/phpmyadmin/index.php"):
|
||||
payload = b'<html><head><title>Sign in</title></head><body><form method="post"><input name="username" autocomplete="off"><input name="password" type="password" autocomplete="off"><button>Sign in</button></form></body></html>'
|
||||
status, mime = (401 if self.command == "POST" else 200), "text/html; charset=utf-8"
|
||||
elif parsed.path == "/backup.sql":
|
||||
payload = b"-- Backup unavailable\n-- Contact system administrator\n"
|
||||
status, mime = 200, "text/plain; charset=utf-8"
|
||||
else:
|
||||
payload, status, mime = b'{"error":"access denied"}', 403, "application/json"
|
||||
self.send_response(status)
|
||||
self.send_header("Content-Type", mime)
|
||||
self.send_header("Content-Length", str(len(payload)))
|
||||
self.send_header("Cache-Control", "no-store")
|
||||
self.send_header("X-Content-Type-Options", "nosniff")
|
||||
self.send_header("Content-Security-Policy", "default-src 'none'; form-action 'self'; frame-ancestors 'none'")
|
||||
self.send_header("Set-Cookie", f"hp_session={nonce}; Path=/; Max-Age=86400; Secure; HttpOnly; SameSite=Lax")
|
||||
self.send_header("Connection", "close")
|
||||
self.end_headers()
|
||||
if self.command != "HEAD":
|
||||
self.wfile.write(payload)
|
||||
self.close_connection = True
|
||||
|
||||
def handle_one_request(self):
|
||||
try:
|
||||
return super().handle_one_request()
|
||||
except (ValueError, OSError):
|
||||
self.close_connection = True
|
||||
|
||||
do_GET = do_POST = do_HEAD = do_PUT = do_DELETE = do_OPTIONS = _handle
|
||||
|
||||
|
||||
def ssh_server(store: EventStore, port: int):
|
||||
import paramiko
|
||||
|
||||
host_key = STATE / "ssh_host_rsa_key"
|
||||
if not host_key.exists():
|
||||
paramiko.RSAKey.generate(2048).write_private_key_file(str(host_key))
|
||||
host_key.chmod(0o600)
|
||||
key = paramiko.RSAKey.from_private_key_file(str(host_key))
|
||||
|
||||
class AuthenticationTrap(paramiko.ServerInterface):
|
||||
def __init__(self, ip):
|
||||
self.ip = ip
|
||||
|
||||
def get_allowed_auths(self, username):
|
||||
return "password,publickey"
|
||||
|
||||
def check_auth_password(self, username, password):
|
||||
store.emit("ssh", self.ip, event="password_attempt", claimed_username=short(username, 128), password_fingerprint=store.fingerprint(password))
|
||||
return paramiko.AUTH_FAILED
|
||||
|
||||
def check_auth_publickey(self, username, public_key):
|
||||
store.emit("ssh", self.ip, event="publickey_attempt", claimed_username=short(username, 128), key_fingerprint=hashlib.sha256(public_key.asbytes()).hexdigest())
|
||||
return paramiko.AUTH_FAILED
|
||||
|
||||
def check_channel_request(self, kind, channel_id):
|
||||
return paramiko.OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
|
||||
|
||||
def check_channel_exec_request(self, channel, command):
|
||||
return False
|
||||
|
||||
def check_channel_shell_request(self, channel):
|
||||
return False
|
||||
|
||||
def check_channel_direct_tcpip_request(self, channel_id, origin, destination):
|
||||
return paramiko.OPEN_FAILED_ADMINISTRATIVELY_PROHIBITED
|
||||
|
||||
def check_port_forward_request(self, address, forward_port):
|
||||
return False
|
||||
|
||||
class SSHHandler(socketserver.BaseRequestHandler):
|
||||
def handle(self):
|
||||
ip, source_port = self.client_address[:2]
|
||||
self.request.settimeout(8)
|
||||
store.emit("ssh", ip, event="connection", source_port=source_port)
|
||||
transport = paramiko.Transport(self.request)
|
||||
transport.local_version = "SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.6"
|
||||
transport.banner_timeout = 5
|
||||
transport.auth_timeout = 10
|
||||
transport.add_server_key(key)
|
||||
try:
|
||||
transport.start_server(server=AuthenticationTrap(ip))
|
||||
deadline = time.monotonic() + 15
|
||||
while transport.is_active() and time.monotonic() < deadline:
|
||||
time.sleep(0.1)
|
||||
except (OSError, EOFError, paramiko.SSHException):
|
||||
pass
|
||||
finally:
|
||||
transport.close()
|
||||
|
||||
class SSHServer(LimitedThreads, socketserver.TCPServer):
|
||||
allow_reuse_address = True
|
||||
|
||||
server = SSHServer(("0.0.0.0", port), SSHHandler)
|
||||
server.slots = threading.BoundedSemaphore(4)
|
||||
return server
|
||||
|
||||
|
||||
def main():
|
||||
logging.basicConfig(level=logging.WARNING)
|
||||
logging.getLogger("paramiko").setLevel(logging.CRITICAL)
|
||||
os.umask(0o077)
|
||||
store = EventStore(STATE)
|
||||
http = DecoyHTTPServer(("127.0.0.1", int(os.environ.get("HONEYPOT_HTTP_PORT", "4012"))), store)
|
||||
ssh = ssh_server(store, int(os.environ.get("HONEYPOT_SSH_PORT", "2222")))
|
||||
for server in [http, ssh]:
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
print("Decoys ready: HTTP loopback and SSH reject-only", flush=True)
|
||||
stop = threading.Event()
|
||||
signal.signal(signal.SIGTERM, lambda *_: stop.set())
|
||||
signal.signal(signal.SIGINT, lambda *_: stop.set())
|
||||
stop.wait()
|
||||
for server in [http, ssh]:
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
store.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
142
apps/hackrobot/honeypot/test_honeypot.py
Normal file
142
apps/hackrobot/honeypot/test_honeypot.py
Normal file
@ -0,0 +1,142 @@
|
||||
import http.client
|
||||
from contextlib import closing
|
||||
import importlib.util
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sqlite3
|
||||
import tempfile
|
||||
import threading
|
||||
import unittest
|
||||
import io
|
||||
import hashlib
|
||||
from contextlib import redirect_stdout
|
||||
|
||||
import paramiko
|
||||
|
||||
spec = importlib.util.spec_from_file_location("honeypot", Path(__file__).with_name("server.py"))
|
||||
hp = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(hp)
|
||||
|
||||
|
||||
class HoneypotTests(unittest.TestCase):
|
||||
def test_http_redacts_credentials_and_returns_only_fake_data(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
store = hp.EventStore(Path(directory))
|
||||
server = hp.DecoyHTTPServer(("127.0.0.1", 0), store)
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
try:
|
||||
client = http.client.HTTPConnection(*server.server_address)
|
||||
client.request("POST", "/wp-login.php?token=private-query", "username=test-user&password=DO-NOT-LOG-THIS", {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
"X-Honeypot-Client-IP": "192.0.2.15",
|
||||
"Cookie": "pb_session=SECRET-JWT; nomadvip_anon_uid=user1234",
|
||||
})
|
||||
response = client.getresponse()
|
||||
self.assertEqual(response.status, 401)
|
||||
response.read()
|
||||
store.pending.join()
|
||||
with closing(sqlite3.connect(store.database)) as db:
|
||||
ip, raw = db.execute("SELECT ip,detail FROM events").fetchone()
|
||||
detail = json.loads(raw)
|
||||
self.assertEqual(ip, "192.0.2.15")
|
||||
self.assertEqual(detail["claimed_user_id"], "user1234")
|
||||
self.assertEqual(detail["claimed_username"], "test-user")
|
||||
self.assertEqual(detail["query_keys"], ["token"])
|
||||
for secret in ["DO-NOT-LOG-THIS", "SECRET-JWT", "private-query"]:
|
||||
self.assertNotIn(secret, raw)
|
||||
self.assertEqual(len(detail["password_fingerprint"]), 64)
|
||||
client = http.client.HTTPConnection(*server.server_address)
|
||||
client.request("GET", "/.env")
|
||||
response = client.getresponse()
|
||||
payload = response.read()
|
||||
self.assertEqual(response.status, 200)
|
||||
self.assertIn(b"SSH_PORT=22", payload)
|
||||
self.assertNotIn(b"POCKETBASE", payload)
|
||||
finally:
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
store.close()
|
||||
|
||||
def test_ssh_never_authenticates_or_executes(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
hp.STATE = Path(directory)
|
||||
store = hp.EventStore(hp.STATE)
|
||||
server = hp.ssh_server(store, 0)
|
||||
threading.Thread(target=server.serve_forever, daemon=True).start()
|
||||
client = paramiko.SSHClient()
|
||||
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
try:
|
||||
with self.assertRaises(paramiko.AuthenticationException):
|
||||
client.connect("127.0.0.1", port=server.server_address[1], username="root", password="PRIVATE-TEST", allow_agent=False, look_for_keys=False, timeout=5)
|
||||
store.pending.join()
|
||||
with closing(sqlite3.connect(store.database)) as db:
|
||||
rows = db.execute("SELECT detail FROM events").fetchall()
|
||||
self.assertTrue(any(json.loads(row[0]).get("event") == "password_attempt" for row in rows))
|
||||
self.assertNotIn("PRIVATE-TEST", str(rows))
|
||||
self.assertFalse(client.get_transport().is_authenticated())
|
||||
finally:
|
||||
client.close()
|
||||
server.shutdown()
|
||||
server.server_close()
|
||||
store.close()
|
||||
|
||||
def test_one_source_cannot_flood_the_queue(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
store = hp.EventStore(Path(directory))
|
||||
for _ in range(1000):
|
||||
store.emit("http", "192.0.2.1", event="probe")
|
||||
store.pending.join()
|
||||
with closing(sqlite3.connect(store.database)) as db:
|
||||
self.assertLessEqual(db.execute("SELECT COUNT(*) FROM events").fetchone()[0], 60)
|
||||
self.assertGreaterEqual(store.dropped, 940)
|
||||
store.close()
|
||||
|
||||
def test_correlates_all_users_and_distinguishes_claimed_identity(self):
|
||||
spec = importlib.util.spec_from_file_location("honeypot_report", Path(__file__).with_name("report.py"))
|
||||
report = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(report)
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
report.STATE = root / "state"
|
||||
report.OUTPUT = root / "report"
|
||||
report.CONTROL_PATH = root / "control.json"
|
||||
report.TRACK_DB = root / "track.db"
|
||||
report.CONTROL_PATH.write_text(json.dumps({"blocks": [{"userId": "user456", "reason": "test"}], "archives": []}))
|
||||
with closing(sqlite3.connect(report.TRACK_DB)) as db:
|
||||
db.execute("CREATE TABLE events(ip TEXT,openid TEXT,props TEXT,ts REAL)")
|
||||
db.executemany("INSERT INTO events VALUES(?,?,?,?)", [
|
||||
("192.0.2.10", "user123", '{"user_id":"user123"}', 100),
|
||||
("192.0.2.11", "user456", '{"user_id":"user456"}', 101),
|
||||
])
|
||||
db.commit()
|
||||
store = hp.EventStore(report.STATE)
|
||||
try:
|
||||
store.emit("http", "192.0.2.10", event="probe")
|
||||
store.emit("ssh", "192.0.2.11", event="password_attempt", claimed_username="user456")
|
||||
store.emit("ssh", "192.0.2.12", event="password_attempt", claimed_username="user123")
|
||||
store.pending.join()
|
||||
with redirect_stdout(io.StringIO()):
|
||||
report.report()
|
||||
result = json.loads((report.OUTPUT / "latest-report.json").read_text())
|
||||
by_ip = {row["ip"]: row for row in result["sources"]}
|
||||
self.assertEqual(by_ip["192.0.2.10"]["site_identifiers_same_ip"], ["user123"])
|
||||
self.assertEqual(by_ip["192.0.2.10"]["active_blocks"], [])
|
||||
self.assertEqual(by_ip["192.0.2.11"]["active_blocks"][0]["identifier"], "user456")
|
||||
self.assertEqual(by_ip["192.0.2.12"]["association_level"], "self_claimed_only")
|
||||
self.assertEqual(by_ip["192.0.2.12"]["site_identifiers_same_ip"], [])
|
||||
previous_hash = "0" * 64
|
||||
for line in (report.OUTPUT / "events.archive.jsonl").read_text().splitlines():
|
||||
event = json.loads(line)
|
||||
self.assertEqual(event["record"]["previous_hash"], previous_hash)
|
||||
previous_hash = hashlib.sha256(json.dumps(event["record"], sort_keys=True, ensure_ascii=True).encode()).hexdigest()
|
||||
self.assertEqual(event["sha256"], previous_hash)
|
||||
self.assertEqual(result["archive"]["last_id"], 3)
|
||||
with redirect_stdout(io.StringIO()):
|
||||
report.report()
|
||||
self.assertEqual(len((report.OUTPUT / "events.archive.jsonl").read_text().splitlines()), 3)
|
||||
finally:
|
||||
store.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@ -117,14 +117,29 @@ def _check_base_url():
|
||||
@app.on_event("startup")
|
||||
async def startup_event():
|
||||
_check_base_url()
|
||||
# 预热 PocketBase 连接,减少首个业务请求冷启动延迟
|
||||
try:
|
||||
# 预热 PocketBase:必须后台+超时,避免 PB/DNS 卡住导致 uvicorn 一直
|
||||
# “Waiting for application startup” 不接流量(表现为 /api/pay 504)。
|
||||
import asyncio
|
||||
import anyio.to_thread
|
||||
|
||||
# Bound synchronous DB/provider work on the 2-core, 2GB production host.
|
||||
anyio.to_thread.current_default_thread_limiter().total_tokens = 8
|
||||
|
||||
def _warmup_pb() -> None:
|
||||
from .services.pb import get_pb_client
|
||||
|
||||
get_pb_client()
|
||||
logging.info("PocketBase client warmup done")
|
||||
except Exception as error:
|
||||
logging.warning("PocketBase client warmup failed: %s", error)
|
||||
|
||||
async def _warmup_pb_bg() -> None:
|
||||
try:
|
||||
# An executor context manager would join a timed-out worker on the
|
||||
# event loop, freezing payments and even /health until PB returns.
|
||||
await asyncio.wait_for(asyncio.to_thread(_warmup_pb), timeout=8)
|
||||
logging.info("PocketBase client warmup done")
|
||||
except Exception as error:
|
||||
logging.warning("PocketBase client warmup failed/skipped: %s", error)
|
||||
|
||||
asyncio.create_task(_warmup_pb_bg())
|
||||
|
||||
|
||||
@app.get("/health")
|
||||
|
||||
@ -10,6 +10,7 @@ import requests
|
||||
from fastapi import APIRouter, File, HTTPException, Request, UploadFile
|
||||
from fastapi.responses import JSONResponse, RedirectResponse
|
||||
from requests.adapters import HTTPAdapter
|
||||
from starlette.concurrency import run_in_threadpool
|
||||
|
||||
|
||||
from ..services.wechat_private_user_pb import (
|
||||
@ -42,6 +43,19 @@ _admin_token_cache_expire_at = 0.0
|
||||
_vip_cache_lock = threading.Lock()
|
||||
_vip_check_cache: dict[str, tuple[float, dict]] = {}
|
||||
_VIP_CACHE_TTL_SECONDS = 20
|
||||
_VIP_CACHE_MAX_ENTRIES = 2048
|
||||
_payment_callback_lock = threading.Lock()
|
||||
|
||||
|
||||
def _handle_vip_payment_callback(order_id: str, pay_price: str, provider_name: str):
|
||||
# Callbacks now run in worker threads. Preserve serial fulfillment and
|
||||
# recheck deduplication inside the lock before writing payment records.
|
||||
with _payment_callback_lock:
|
||||
if order_id in processed_orders:
|
||||
return
|
||||
handle_payment_success(
|
||||
order_id, pay_price, provider_name, use_memos=True, site_id="vip"
|
||||
)
|
||||
|
||||
|
||||
def _cache_get(key: str):
|
||||
@ -59,6 +73,12 @@ def _cache_get(key: str):
|
||||
|
||||
def _cache_set(key: str, value: dict, ttl: int = _VIP_CACHE_TTL_SECONDS):
|
||||
with _vip_cache_lock:
|
||||
if len(_vip_check_cache) >= _VIP_CACHE_MAX_ENTRIES:
|
||||
now = time.time()
|
||||
for stale_key in [k for k, (expires, _) in _vip_check_cache.items() if expires <= now]:
|
||||
_vip_check_cache.pop(stale_key, None)
|
||||
if len(_vip_check_cache) >= _VIP_CACHE_MAX_ENTRIES:
|
||||
_vip_check_cache.pop(next(iter(_vip_check_cache)))
|
||||
_vip_check_cache[key] = (time.time() + ttl, value)
|
||||
|
||||
|
||||
@ -131,7 +151,7 @@ def _reject_probe_ua(request: Request) -> None:
|
||||
|
||||
|
||||
@router.post("/payh5")
|
||||
async def nomadvip_payh5(item: dict, request: Request):
|
||||
def nomadvip_payh5(item: dict, request: Request):
|
||||
"""创建支付订单。微信内用 xorpay,PC/手机用 zpay,默认微信支付,支付宝暂不提供"""
|
||||
_reject_probe_ua(request)
|
||||
req_provider = (item.get("provider") or "").strip().lower() or None
|
||||
@ -208,7 +228,7 @@ async def nomadvip_payh5(item: dict, request: Request):
|
||||
|
||||
|
||||
@router.post("/payh5/redirect")
|
||||
async def nomadvip_payh5_redirect(item: dict, request: Request):
|
||||
def nomadvip_payh5_redirect(item: dict, request: Request):
|
||||
"""ZPAY mapi 接口,PC/手机用 zpay,默认微信支付,支付宝暂不提供"""
|
||||
_reject_probe_ua(request)
|
||||
provider = get_payment_provider_by_name("zpay")
|
||||
@ -307,7 +327,7 @@ async def nomadvip_payh5_redirect(item: dict, request: Request):
|
||||
|
||||
|
||||
@router.get("/zpay_order_status")
|
||||
async def nomadvip_zpay_order_status(out_trade_no: str):
|
||||
def nomadvip_zpay_order_status(out_trade_no: str):
|
||||
"""查询 ZPAY 订单支付状态。"""
|
||||
provider = get_payment_provider()
|
||||
if not isinstance(provider, ZPayProvider):
|
||||
@ -371,7 +391,7 @@ def _uid_has_vip(pb, uid: str, site_id: str = "vip") -> bool:
|
||||
|
||||
|
||||
@router.get("/check_vip")
|
||||
async def nomadvip_check_vip(user_id: str = ""):
|
||||
def nomadvip_check_vip(user_id: str = ""):
|
||||
"""Return vip status for a user_id."""
|
||||
user_id = (user_id or "").strip()
|
||||
logging.info("[payjsapi] check_vip user_id=%s", user_id or "(empty)")
|
||||
@ -879,7 +899,7 @@ async def nomadvip_wechat_profile(item: dict):
|
||||
|
||||
|
||||
@router.post("/identity_diagnose")
|
||||
async def nomadvip_identity_diagnose(item: dict):
|
||||
def nomadvip_identity_diagnose(item: dict):
|
||||
"""
|
||||
用 user_id / email / wechat_userid 任一输入,诊断三表关联:
|
||||
payments.user_id <-> users.email <-> wechat_private_users.userid
|
||||
@ -1390,7 +1410,7 @@ def _pb_ensure_site_vip(
|
||||
|
||||
|
||||
@router.post("/check_vip_by_email")
|
||||
async def nomadvip_check_vip_by_email(item: dict):
|
||||
def nomadvip_check_vip_by_email(item: dict):
|
||||
"""Recover VIP by email/password, optionally with anonymous user_id."""
|
||||
email = (item.get("email") or "").strip().lower()
|
||||
password = (item.get("password") or "").strip()
|
||||
@ -1553,7 +1573,7 @@ async def nomadvip_check_vip_by_email(item: dict):
|
||||
return result
|
||||
|
||||
@router.get("/order_status")
|
||||
async def nomadvip_order_status(order_id: str = "", out_trade_no: str = ""):
|
||||
def nomadvip_order_status(order_id: str = "", out_trade_no: str = ""):
|
||||
"""查询订单支付状态,优先查 ZPAY,失败时回退 PocketBase。"""
|
||||
order_id = (order_id or out_trade_no or "").strip()
|
||||
logging.info("[payjsapi] order_status order_id=%s", order_id or "(空)")
|
||||
@ -1628,12 +1648,11 @@ async def nomadvip_xorpay_notify(request: Request):
|
||||
|
||||
pay_price = parsed.get("pay_price", data.get("pay_price", ""))
|
||||
try:
|
||||
handle_payment_success(
|
||||
await run_in_threadpool(
|
||||
_handle_vip_payment_callback,
|
||||
order_id,
|
||||
pay_price,
|
||||
"nomadvip-xorpay",
|
||||
use_memos=True,
|
||||
site_id="vip",
|
||||
)
|
||||
logging.info("nomadvip business done: order_id=%s", order_id)
|
||||
except Exception as error:
|
||||
@ -1673,12 +1692,11 @@ async def nomadvip_zpay_notify(request: Request):
|
||||
|
||||
pay_price = parsed.get("pay_price") or data.get("money", "")
|
||||
try:
|
||||
handle_payment_success(
|
||||
await run_in_threadpool(
|
||||
_handle_vip_payment_callback,
|
||||
order_id,
|
||||
pay_price,
|
||||
"nomadvip-zpay",
|
||||
use_memos=True,
|
||||
site_id="vip",
|
||||
)
|
||||
logging.info("nomadvip business done: order_id=%s", order_id)
|
||||
except Exception as error:
|
||||
|
||||
@ -3,6 +3,7 @@ PocketBase SDK
|
||||
数据库操作封装,支持配置注入
|
||||
"""
|
||||
from typing import Optional
|
||||
from threading import Lock
|
||||
|
||||
from pocketbase import PocketBase
|
||||
|
||||
@ -20,14 +21,18 @@ class PocketBaseSDK:
|
||||
self.admin_email = admin_email
|
||||
self.admin_password = admin_password
|
||||
self._client: Optional[PocketBase] = None
|
||||
self._client_lock = Lock()
|
||||
|
||||
def get_client(self) -> PocketBase:
|
||||
"""获取已认证的 PocketBase 客户端(首次登录时认证,后续复用)"""
|
||||
if self._client is None:
|
||||
import logging
|
||||
self._client = PocketBase(self.url)
|
||||
self._client.admins.auth_with_password(self.admin_email, self.admin_password)
|
||||
logging.getLogger(__name__).info("PocketBase admin 登录成功")
|
||||
with self._client_lock:
|
||||
if self._client is None:
|
||||
import logging
|
||||
client = PocketBase(self.url)
|
||||
client.admins.auth_with_password(self.admin_email, self.admin_password)
|
||||
self._client = client
|
||||
logging.getLogger(__name__).info("PocketBase admin 登录成功")
|
||||
return self._client
|
||||
|
||||
def collection(self, name: str):
|
||||
|
||||
106
apps/hackrobot/payjsapi/tests/test_payment_responsiveness.py
Normal file
106
apps/hackrobot/payjsapi/tests/test_payment_responsiveness.py
Normal file
@ -0,0 +1,106 @@
|
||||
"""Run with the payment service dependencies: python -m unittest discover -s tests."""
|
||||
import asyncio
|
||||
import importlib
|
||||
import time
|
||||
import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
import httpx
|
||||
|
||||
from app.main import app
|
||||
from app.sdk.pocketbase import PocketBaseSDK
|
||||
|
||||
vip = importlib.import_module("app.routers.nomadvip")
|
||||
|
||||
|
||||
class PaymentResponsivenessTests(unittest.IsolatedAsyncioTestCase):
|
||||
async def test_slow_database_does_not_block_cashier_or_health(self):
|
||||
def slow_database():
|
||||
time.sleep(0.8)
|
||||
raise TimeoutError("simulated database outage")
|
||||
|
||||
provider = MagicMock()
|
||||
provider.name = "xorpay"
|
||||
provider.create_order.return_value = {
|
||||
"params": {"price": "298.00", "pay_type": "jsapi"},
|
||||
"pay_url": "https://cashier.example.test/checkout",
|
||||
}
|
||||
transport = httpx.ASGITransport(app=app)
|
||||
with (
|
||||
patch("app.services.pb.get_pb_client", side_effect=slow_database),
|
||||
patch.object(vip, "resolve_provider", return_value=provider),
|
||||
patch.object(vip, "_resolve_nomadvip_total_fee", return_value=29800),
|
||||
):
|
||||
async with httpx.AsyncClient(transport=transport, base_url="http://test") as client:
|
||||
started = time.monotonic()
|
||||
pending = asyncio.create_task(client.get("/nomadvip/check_vip", params={"user_id": "responsiveness-test"}))
|
||||
try:
|
||||
await asyncio.sleep(0.05)
|
||||
health, cashier = await asyncio.gather(
|
||||
client.get("/health"),
|
||||
client.post("/nomadvip/payh5", json={"user_id": "test", "device": "wechat", "type": "vip"}),
|
||||
)
|
||||
self.assertEqual(health.status_code, 200)
|
||||
self.assertEqual(cashier.status_code, 200)
|
||||
self.assertEqual(cashier.json()["xorpay_params"]["price"], "298.00")
|
||||
self.assertLess(time.monotonic() - started, 0.6)
|
||||
self.assertFalse(pending.done())
|
||||
finally:
|
||||
await pending
|
||||
with vip._vip_cache_lock:
|
||||
vip._vip_check_cache.pop("check_vip:responsiveness-test", None)
|
||||
|
||||
async def test_invalid_callback_cannot_grant_vip(self):
|
||||
provider = MagicMock()
|
||||
provider.verify_notify.return_value = False
|
||||
with (
|
||||
patch.object(vip, "get_payment_provider_by_name", return_value=provider),
|
||||
patch.object(vip, "handle_payment_success") as grant,
|
||||
):
|
||||
async with httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url="http://test") as client:
|
||||
response = await client.post("/nomadvip/xorpay_notify", data={"order_id": "invalid-test", "sign": "invalid"})
|
||||
self.assertEqual(response.status_code, 400)
|
||||
grant.assert_not_called()
|
||||
|
||||
async def test_duplicate_callbacks_fulfill_once(self):
|
||||
order_id = "concurrent-test_vip_order_1"
|
||||
provider = MagicMock()
|
||||
provider.verify_notify.return_value = True
|
||||
provider.parse_notify.return_value = {"trade_status": "success", "pay_price": "298.00"}
|
||||
provider.success_response.return_value = "ok"
|
||||
|
||||
def fulfill(order, *args, **kwargs):
|
||||
time.sleep(0.1)
|
||||
vip.processed_orders.add(order)
|
||||
|
||||
with (
|
||||
patch.object(vip, "get_payment_provider_by_name", return_value=provider),
|
||||
patch.object(vip, "handle_payment_success", side_effect=fulfill) as grant,
|
||||
):
|
||||
try:
|
||||
async with httpx.AsyncClient(transport=httpx.ASGITransport(app=app), base_url="http://test") as client:
|
||||
responses = await asyncio.gather(*[
|
||||
client.post("/nomadvip/xorpay_notify", data={"order_id": order_id, "sign": "test"})
|
||||
for _ in range(2)
|
||||
])
|
||||
self.assertTrue(all(response.status_code == 200 for response in responses))
|
||||
grant.assert_called_once()
|
||||
finally:
|
||||
vip.processed_orders.discard(order_id)
|
||||
|
||||
|
||||
class PocketBaseInitializationTests(unittest.TestCase):
|
||||
def test_failed_authentication_is_retried(self):
|
||||
failed, authenticated = MagicMock(), MagicMock()
|
||||
failed.admins.auth_with_password.side_effect = TimeoutError("database unavailable")
|
||||
with patch("app.sdk.pocketbase.PocketBase", side_effect=[failed, authenticated]):
|
||||
sdk = PocketBaseSDK("http://test", "test@example.test", "test")
|
||||
with self.assertRaises(TimeoutError):
|
||||
sdk.get_client()
|
||||
self.assertIs(sdk.get_client(), authenticated)
|
||||
self.assertIs(sdk.get_client(), authenticated)
|
||||
authenticated.admins.auth_with_password.assert_called_once()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@ -654,7 +654,7 @@ export default function HomeClient() {
|
||||
}, []);
|
||||
|
||||
const handlePay = useCallback(() => {
|
||||
triggerPay(setPayPendingOrderId);
|
||||
triggerPay();
|
||||
}, []);
|
||||
|
||||
const handleVerifySuccess = useCallback(() => {
|
||||
|
||||
@ -260,7 +260,9 @@ export async function POST(request: NextRequest) {
|
||||
setAnonymousUserCookie(res, request, user_id);
|
||||
return res;
|
||||
}
|
||||
const res = NextResponse.redirect(location);
|
||||
// The cashier URL is opened with GET after our form POST. A 307
|
||||
// would resend the order form to the provider's checkout endpoint.
|
||||
const res = NextResponse.redirect(location, 303);
|
||||
if (orderId) setPayOrderCookie(res, orderId);
|
||||
setAnonymousUserCookie(res, request, user_id);
|
||||
return res;
|
||||
|
||||
@ -10,18 +10,24 @@ import { getPayEnv, getDeviceFromEnv } from "@/app/lib/payEnv";
|
||||
|
||||
const ANONYMOUS_USER_COOKIE = "nomadvip_anon_uid";
|
||||
const ANONYMOUS_USER_COOKIE_MAX_AGE = 60 * 60 * 24 * 30;
|
||||
const PAY_ORDER_COOKIE = "nomadvip_pay_order";
|
||||
const PAY_ORDER_MAX_AGE = 60 * 15;
|
||||
const PAY_LAUNCH_OVERLAY_ID = "nomadvip-pay-launch-overlay";
|
||||
|
||||
function getStorage(key: string): string | null {
|
||||
if (typeof window === "undefined") return null;
|
||||
return localStorage.getItem(key);
|
||||
try {
|
||||
return localStorage.getItem(key);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function setStorage(key: string, value: string): void {
|
||||
if (typeof window === "undefined") return;
|
||||
localStorage.setItem(key, value);
|
||||
try {
|
||||
localStorage.setItem(key, value);
|
||||
} catch {
|
||||
// The server also persists payment identity and order in cookies.
|
||||
}
|
||||
}
|
||||
|
||||
function getCookie(name: string): string | null {
|
||||
@ -39,16 +45,6 @@ function setAnonymousUserCookie(userId: string): void {
|
||||
)}; Path=/; Max-Age=${ANONYMOUS_USER_COOKIE_MAX_AGE}; SameSite=Lax${secure}`;
|
||||
}
|
||||
|
||||
function setPayOrderCookie(orderId: string): void {
|
||||
if (typeof document === "undefined") return;
|
||||
const normalizedOrderId = orderId.trim();
|
||||
if (!normalizedOrderId) return;
|
||||
const secure = window.location.protocol === "https:" ? "; Secure" : "";
|
||||
document.cookie = `${PAY_ORDER_COOKIE}=${encodeURIComponent(
|
||||
`${normalizedOrderId}|${Date.now()}`
|
||||
)}; Path=/; Max-Age=${PAY_ORDER_MAX_AGE}; SameSite=Lax${secure}`;
|
||||
}
|
||||
|
||||
function getDisplayProfile() {
|
||||
const wechatNick = (getStorage("wechatNick") || "").trim();
|
||||
const userName = (getStorage("userName") || "").trim();
|
||||
@ -84,13 +80,6 @@ function showPayLaunchOverlay(displayName: string, avatar?: string): void {
|
||||
}, 2400);
|
||||
}
|
||||
|
||||
function savePendingOrder(orderId: string): void {
|
||||
const normalizedOrderId = orderId.trim();
|
||||
if (!normalizedOrderId) return;
|
||||
setPayOrderCookie(normalizedOrderId);
|
||||
setStorage(PAY_ORDER_COOKIE, `${normalizedOrderId}|${Date.now()}`);
|
||||
}
|
||||
|
||||
function getStoredAnonymousUserId(): string | null {
|
||||
const memosAccount = getStorage("memosAccount");
|
||||
if (memosAccount && /^user\d+$/.test(memosAccount)) return memosAccount;
|
||||
@ -137,7 +126,11 @@ async function getOrCreateUserId(): Promise<string> {
|
||||
return syncId;
|
||||
}
|
||||
try {
|
||||
const meRes = await fetch("/api/auth/me", { credentials: "include", cache: "no-store" });
|
||||
const meRes = await fetch("/api/auth/me", {
|
||||
credentials: "include",
|
||||
cache: "no-store",
|
||||
signal: AbortSignal.timeout(3000),
|
||||
});
|
||||
const meData = await meRes.json();
|
||||
if (meData?.user?.id) {
|
||||
setStorage("userId", meData.user.id);
|
||||
@ -187,67 +180,6 @@ function redirectToPayZpay(params: {
|
||||
form.submit();
|
||||
}
|
||||
|
||||
async function redirectToPayZpayH5(
|
||||
params: {
|
||||
user_id: string;
|
||||
wechat_userid?: string;
|
||||
wechat_nick?: string;
|
||||
wechat_avatar?: string;
|
||||
return_url: string;
|
||||
type: string;
|
||||
channel: "alipay" | "wxpay";
|
||||
},
|
||||
onPendingOrder?: (orderId: string) => void
|
||||
): Promise<string | null> {
|
||||
const res = await fetch("/api/pay", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
...params,
|
||||
device: "h5",
|
||||
provider: "zpay",
|
||||
html: "0",
|
||||
}),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!data?.ok) {
|
||||
alert(data?.error || "支付发起失败");
|
||||
return null;
|
||||
}
|
||||
const hasRedirect = !!data?.redirect_url;
|
||||
const hasParams = !!data?.params && !!data?.payUrl;
|
||||
if (!hasRedirect && !hasParams) {
|
||||
alert(data?.error || "支付发起失败");
|
||||
return null;
|
||||
}
|
||||
const orderId = data?.order_id?.trim() || null;
|
||||
if (orderId) {
|
||||
savePendingOrder(orderId);
|
||||
onPendingOrder?.(orderId);
|
||||
}
|
||||
if (data?.redirect_url) {
|
||||
window.location.href = data.redirect_url;
|
||||
return orderId;
|
||||
}
|
||||
const form = document.createElement("form");
|
||||
form.method = "POST";
|
||||
form.action = data.payUrl;
|
||||
form.target = "_self";
|
||||
form.style.display = "none";
|
||||
for (const [k, v] of Object.entries(data.params as Record<string, string>)) {
|
||||
if (v == null) continue;
|
||||
const input = document.createElement("input");
|
||||
input.type = "hidden";
|
||||
input.name = k;
|
||||
input.value = String(v);
|
||||
form.appendChild(input);
|
||||
}
|
||||
document.body.appendChild(form);
|
||||
form.submit();
|
||||
document.body.removeChild(form);
|
||||
return orderId;
|
||||
}
|
||||
|
||||
/** 微信内:同步表单 POST 到 /api/pay,避免异步 fetch 后 form.submit 被微信拦截 */
|
||||
function payWechatXorpaySync(params: {
|
||||
user_id: string;
|
||||
@ -288,11 +220,8 @@ function payWechatXorpaySync(params: {
|
||||
|
||||
/**
|
||||
* 触发支付 - 与首页「立即加入」效果一致,直接发起支付流程
|
||||
* @param onPendingOrder 可选,H5 支付时收到 order_id 的回调(用于轮询)
|
||||
*/
|
||||
export async function triggerPay(
|
||||
onPendingOrder?: (orderId: string) => void
|
||||
): Promise<void> {
|
||||
export async function triggerPay(): Promise<void> {
|
||||
const userId =
|
||||
typeof navigator !== "undefined" && /MicroMessenger/i.test(navigator.userAgent)
|
||||
? getOrCreateUserIdSync()
|
||||
@ -326,9 +255,10 @@ export async function triggerPay(
|
||||
};
|
||||
if (device === "wechat") {
|
||||
payWechatXorpaySync(base);
|
||||
} else if (device === "h5") {
|
||||
await redirectToPayZpayH5(base, onPendingOrder);
|
||||
} else {
|
||||
// H5 may receive an HTML cashier/QR page, so use a full navigation just
|
||||
// like PC. Parsing that response as JSON used to leave the CTA inert.
|
||||
// /api/pay stores the pending order cookie before navigating away.
|
||||
redirectToPayZpay({ ...base, device });
|
||||
}
|
||||
}
|
||||
|
||||
42
apps/hackrobot/vip/tests/pay-redirect.cjs
Normal file
42
apps/hackrobot/vip/tests/pay-redirect.cjs
Normal file
@ -0,0 +1,42 @@
|
||||
const fs = require('node:fs');
|
||||
const vm = require('node:vm');
|
||||
const assert = require('node:assert/strict');
|
||||
const ts = require('typescript');
|
||||
const { NextRequest, NextResponse } = require('next/server');
|
||||
|
||||
const code = ts.transpileModule(fs.readFileSync('apps/hackrobot/vip/app/api/pay/route.ts', 'utf8'), {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
|
||||
}).outputText;
|
||||
const target = 'https://checkout.example.test/pay';
|
||||
const context = vm.createContext({
|
||||
exports: {}, console, process: { env: {} }, AbortController, setTimeout, clearTimeout,
|
||||
require(name) {
|
||||
if (name === 'next/server') return { NextRequest, NextResponse };
|
||||
if (name === '@/config/services.config') return {
|
||||
getPaymentConfig: () => ({ apiUrl: 'http://payment.test', defaultAmount: 29800 }),
|
||||
getApiUrlFromRequest: () => 'http://payment.test',
|
||||
};
|
||||
if (name === '@/app/lib/auth-cookie') return { getCookieOptions: () => ({ path: '/' }), getHostFromRequest: () => 'vip.hackrobot.cn' };
|
||||
if (name === '@/app/lib/ops-config') return { readOpsConfig: () => ({ payEnabled: true }), getVipPriceFen: () => 29800 };
|
||||
if (name === '@/app/lib/ops-control') return { isIpBlocked: () => false, isPayBlocked: () => false };
|
||||
throw new Error('Unexpected import: ' + name);
|
||||
},
|
||||
async fetch(url, options) {
|
||||
assert.equal(url, 'http://payment.test/nomadvip/payh5/redirect');
|
||||
assert.equal(JSON.parse(options.body).total_fee, 29800);
|
||||
return new Response(null, { status: 302, headers: { Location: target, 'X-Pay-Order-Id': 'redirect-test' } });
|
||||
},
|
||||
});
|
||||
vm.runInContext(code, context);
|
||||
(async () => {
|
||||
const request = new NextRequest('https://vip.hackrobot.cn/api/pay', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded', Host: 'vip.hackrobot.cn' },
|
||||
body: new URLSearchParams({ user_id: 'user999926003', device: 'h5', html: '1', total_fee: '1' }),
|
||||
});
|
||||
const response = await context.exports.POST(request);
|
||||
assert.equal(response.status, 303, 'The browser must open the checkout URL with GET after a form POST');
|
||||
assert.equal(response.headers.get('location'), target);
|
||||
assert.equal(response.cookies.get('nomadvip_pay_order').value.split('|')[0], 'redirect-test');
|
||||
console.log('PASS cashier GET redirect, order cookie and server pricing');
|
||||
})().catch(error => { console.error(error); process.exitCode = 1; });
|
||||
62
apps/hackrobot/vip/tests/trigger-pay.cjs
Normal file
62
apps/hackrobot/vip/tests/trigger-pay.cjs
Normal file
@ -0,0 +1,62 @@
|
||||
const fs = require('node:fs');
|
||||
const vm = require('node:vm');
|
||||
const assert = require('node:assert/strict');
|
||||
const ts = require('typescript');
|
||||
const transpile = path => ts.transpileModule(fs.readFileSync(path, 'utf8'), {
|
||||
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 },
|
||||
}).outputText;
|
||||
const envCode = transpile('apps/hackrobot/vip/app/lib/payEnv.ts');
|
||||
const triggerCode = transpile('apps/hackrobot/vip/app/lib/triggerPay.ts');
|
||||
|
||||
(async () => {
|
||||
for (const [label, ua, device, provider] of [
|
||||
['PC', 'Mozilla/5.0 Windows NT 10.0', 'pc', 'zpay'],
|
||||
['mobile browser', 'Mozilla/5.0 iPhone AppleWebKit Mobile', 'h5', 'zpay'],
|
||||
['WeChat', 'Mozilla/5.0 iPhone MicroMessenger/8.0', 'wechat', 'xorpay'],
|
||||
]) {
|
||||
for (const storageBlocked of [false, true]) {
|
||||
const forms = [];
|
||||
const storage = new Map();
|
||||
const context = vm.createContext({
|
||||
exports: {}, console, AbortSignal,
|
||||
navigator: { userAgent: ua },
|
||||
window: { location: { origin: 'https://vip.hackrobot.cn', protocol: 'https:' }, setTimeout() {} },
|
||||
localStorage: {
|
||||
getItem(key) { if (storageBlocked) throw new Error('storage denied'); return storage.get(key) ?? null; },
|
||||
setItem(key, value) { if (storageBlocked) throw new Error('storage denied'); storage.set(key, value); },
|
||||
},
|
||||
fetch: async url => {
|
||||
assert.equal(url, '/api/auth/me', 'payment should navigate, not parse a cashier HTML page as JSON');
|
||||
return { json: async () => ({ user: null }) };
|
||||
},
|
||||
document: {
|
||||
cookie: '',
|
||||
body: { appendChild() {} },
|
||||
createElement(tag) {
|
||||
const element = { style: {}, children: [], appendChild(child) { this.children.push(child); } };
|
||||
if (tag === 'form') element.submit = () => forms.push(element);
|
||||
return element;
|
||||
},
|
||||
},
|
||||
});
|
||||
vm.runInContext(envCode, context);
|
||||
const env = context.exports;
|
||||
context.exports = {};
|
||||
context.require = name => { assert.equal(name, '@/app/lib/payEnv'); return env; };
|
||||
vm.runInContext(triggerCode, context);
|
||||
await context.exports.triggerPay();
|
||||
assert.equal(forms.length, 1);
|
||||
const form = forms[0];
|
||||
assert.equal(form.method, 'POST');
|
||||
assert.equal(form.action, '/api/pay');
|
||||
assert.equal(form.target, '_self');
|
||||
const fields = Object.fromEntries(form.children.map(input => [input.name, input.value]));
|
||||
assert.equal(fields.device, device);
|
||||
assert.equal(fields.provider, provider);
|
||||
assert.equal(fields.channel, 'wxpay');
|
||||
assert.equal(fields.html, '1');
|
||||
assert.match(fields.user_id, /^user\d+$/);
|
||||
console.log(`PASS ${label}, storage ${storageBlocked ? 'blocked' : 'available'}`);
|
||||
}
|
||||
}
|
||||
})().catch(error => { console.error(error); process.exitCode = 1; });
|
||||
Loading…
Reference in New Issue
Block a user