基于BitSrunLoginGo实现西农校园网服务器自动认证

2025年9月10日 120点热度

BitSrunLoginGo

西北农林科技大学使用的是深澜(Srun)网络认证系统,需要客户端进行认证才能访问互联网。BitSrunLoginGo 是一个用 Go 语言编写的校园网认证客户端,特别适合在服务器环境下使用。

项目地址:https://github.com/Mmx233/BitSrunLoginGo

自动版本选择脚本

使用以下脚本自动检测系统架构并推荐最适合的 BitSrunLoginGo 版本:

#!/bin/bash
# BitSrunLoginGo 版本选择脚本
echo "正在检测系统架构和CPU特性..."
ARCH=$(uname -m)
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
# 检测CPU特性函数
check_cpu_feature() {
    if [ -f /proc/cpuinfo ]; then
        grep -q "$1" /proc/cpuinfo
        return $?
    else
        return 1
    fi
}
# 根据架构和OS选择版本
case "${OS}_${ARCH}" in
    linux_x86_64)
        if check_cpu_feature "avx512"; then
            echo "推荐: bitsrun_linux_amd64_v4.tar.gz"
        elif check_cpu_feature "avx2"; then
            echo "推荐: bitsrun_linux_amd64_v3.tar.gz"
        elif check_cpu_feature "sse4_2" && check_cpu_feature "popcnt"; then
            echo "推荐: bitsrun_linux_amd64_v2.tar.gz"
        else
            echo "推荐兼容性最好的版本: bitsrun_linux_amd64.tar.gz"
        fi
        ;;
    linux_i386|linux_i486|linux_i586|linux_i686)
        echo "推荐: bitsrun_linux_386.tar.gz"
        ;;
    linux_armv6l|linux_armv6)
        echo "推荐: bitsrun_linux_arm_v6.tar.gz"
        ;;
    linux_armv7l|linux_armv7)
        echo "推荐: bitsrun_linux_arm_v7.tar.gz"
        ;;
    linux_aarch64|linux_arm64)
        echo "推荐: bitsrun_linux_arm64.tar.gz"
        ;;
    darwin_x86_64)
        echo "推荐: bitsrun_darwin_amd64.tar.gz"
        ;;
    darwin_arm64)
        echo "推荐: bitsrun_darwin_arm64.tar.gz"
        ;;
    *)
        echo "未知架构: $OS $ARCH"
        echo "请访问 https://github.com/Mmx233/BitSrunLoginGo/releases 手动选择版本"
        ;;
esac
echo ""
echo "使用说明:"
echo "1. 访问 https://github.com/Mmx233/BitSrunLoginGo/releases"
echo "2. 下载上述推荐的版本"
echo "3. 解压: tar -xzf [文件名]"
echo "4. 配置并运行: ./bitsrun --config=config.yaml"

将上述脚本保存为 select_bitsrun.sh,然后运行:

chmod +x select_bitsrun.sh
./select_bitsrun.sh

参考配置

配置文件

创建配置文件 config.yaml,内容如下:

# 西北农林科技大学专用配置
form:
  domain: portal.nwafu.edu.cn    # 西农认证地址
  username: "您的学号"           # 例如:2024056260
  user_type: ""                  # 重要:西农账号留空,无需运营商后缀
  password: "您的密码"           # 校园网密码
meta:
  "n": "200"
  type: "1"
  acid: "1"                      # 西农固定为1
  enc: srun_bx1
  os: Windows 10
  name: windows
  info_prefix: SRBX1
  double_stack: false
settings:
  basic:
    https: true                  # 西农需要使用HTTPS
    skip_cert_verify: false
    timeout: 10
    interfaces: ""
  # 日志设置(首次使用建议开启调试)
  log:
    debug_level: true
    write_file: true
    log_path: ./
    log_name: "auth.log"
  # 必须关闭reality模式
  reality:
    enable: false

下载和运行

  1. 根据脚本推荐下载对应版本
  2. 解压下载的文件:
    tar -xzf bitsrun_linux_amd64.tar.gz
  3. 给予执行权限:
    chmod +x bitsrun
  4. 运行程序:
    ./bitsrun --config=config.yaml

常用命令参数

  • --config:指定配置文件路径
  • --debug:临时开启调试模式
  • --interface:指定网络接口
  • --auto-acid:自动获取acid参数
  • --acid:手动设置acid值
  • --auto-enc:自动获取enc算法

示例:

# 调试模式运行
./bitsrun --config=config.yaml --debug
# 指定网络接口
./bitsrun --config=config.yaml --interface eth0

注意事项

  1. 首次使用建议开启调试日志 (debug_level: true)
  2. 配置文件包含密码,请妥善保管
  3. 正常运作后可关闭调试日志减少磁盘写入
  4. 定期检查日志确认认证状态

xxs9331

这个人很懒,什么都没留下

文章评论