Command-line client for the ICT SRun network gateway
Go to file
2026-08-23 05:39:24 +08:00
scripts release: add portable zipapp and installer 2026-08-23 05:25:05 +08:00
src/ictlogin feat: add ICT gateway login and heartbeat CLI 2026-08-23 05:11:20 +08:00
tests feat: add ICT gateway login and heartbeat CLI 2026-08-23 05:11:20 +08:00
.gitignore release: keep binaries out of git history 2026-08-23 05:36:42 +08:00
install.sh release: keep binaries out of git history 2026-08-23 05:36:42 +08:00
pyproject.toml feat: add ICT gateway login and heartbeat CLI 2026-08-23 05:11:20 +08:00
README.md docs: simplify portable installation 2026-08-23 05:39:24 +08:00
run_ictlogin.py feat: add ICT gateway login and heartbeat CLI 2026-08-23 05:11:20 +08:00
setup.py feat: add ICT gateway login and heartbeat CLI 2026-08-23 05:11:20 +08:00

ICT 网关命令行登录工具

这是针对 https://gw.ict.ac.cn(SRun Portal)的服务器命令行客户端。它复刻网页端的挑战码、HMAC-MD5、XXTEA、定制 Base64 和 SHA-1 校验流程,不依赖第三方 Python 包,也不会保存密码。

安装

在服务器上进入本目录后执行:

python3 -m pip install --user --no-deps --no-build-isolation .

若 ictlogin 不在当前 shell 的 PATH 中,先执行 export PATH="$HOME/.local/bin:$PATH",或直接使用 ~/.local/bin/ictlogin。

如果不想安装,也可以直接运行 python3 run_ictlogin.py ...。

单文件安装

服务器上可直接从公开 Release 获取并安装单文件程序:

curl --fail --location https://gitx.roy1994.top/mancitrus/ictlogin/raw/branch/main/install.sh | sh

安装脚本默认下载 v0.2.0 Release 中的 ictlogin.pyz,验证对应的 SHA-256 后写入 ~/.local/bin/ictlogin。需要其他版本时设置 Release 标签:

ICTLOGIN_RELEASE_TAG=v0.2.0 ./install.sh

也可以先保存 install.sh,再从已有的本地文件或自定义 URL 安装:

./install.sh
./install.sh --source /path/to/ictlogin.pyz --prefix "$HOME/.local/bin"
ICTLOGIN_PYZ_URL="https://example.invalid/ictlogin.pyz" ./install.sh
ICTLOGIN_PYZ_URL="https://example.invalid/ictlogin.pyz" \
  ICTLOGIN_PYZ_SHA256_URL="https://example.invalid/ictlogin.pyz.sha256" ./install.sh

使用

先检查当前 IP:

ictlogin status

交互式登录(账号和密码不会出现在 shell 历史或进程列表中):

ictlogin login

也可以只把账号放在参数中,密码仍会安全地提示输入:

ictlogin login --username YOUR_ACCOUNT

注销和 JSON 状态输出:

ictlogin logout
ictlogin status --json

保持服务器会话活跃:

ictlogin heartbeat --interval 60

该命令会周期性请求网关的在线接口并持续运行,按 Ctrl-C 停止;先用 --once 做单次检查。若希望掉线后自动重新认证,必须显式开启并提供账号密码:

ictlogin heartbeat --auto-login --username YOUR_ACCOUNT --password-env ICT_PASSWORD

每次连续掉线期间只尝试一次自动认证,恢复在线后才会重置,避免错误密码造成反复锁定。

脚本场景可以使用标准输入或显式环境变量读取密码,避免使用 --password 这种会暴露在进程列表中的参数:

printf '%s\n' "$ICT_PASSWORD" | ictlogin login --username YOUR_ACCOUNT --password-stdin
ictlogin login --username YOUR_ACCOUNT --password-env ICT_PASSWORD

若网关要求图片验证码,CLI 会将 PNG 保存到 ~/.cache/ictlogin/(目录和文件权限为当前用户私有),然后提示输入验证码。可用 --ip、--ac-id 和 --base-url 覆盖自动探测的连接参数。

安全说明

  • 密码只在内存中用于生成认证请求,程序不会写入配置文件、日志或命令行参数。
  • 默认校验 HTTPS 证书;只有在明确确认网关证书问题时才使用 --insecure。
  • 工具每次登录只发送一次认证请求,不会重试密码,避免触发账号锁定。