Skip to content

Repository files navigation

$\texttt{\huge{\textcolor{red}{R}et\textcolor{gray}{2}\textcolor{blue}{C}onsole}}$

适用于 Ret2Shell 的命令行风格用户接口。

使用

Ret2Console 使用 uv 管理,你可以直接使用 uv 启动 Ret2Console:

$ uv run r2c

使用 auth login 进行登录。默认登录平台为 西电 CTF 终端

您也可以使用其他平台,仅需使用命令 auth endpoint https://your-ret2shell.domain/api 即可。

多 profile:每个 profile 独立保存凭证与 API endpoint,默认使用 defaultauth profile create work 新建并切换,auth profile use <名称> 切换, auth profile list 查看全部,auth profile delete <名称> 删除(最后一个 profile 不可删, default 删除后下次 use default 会重新创建)。

登录、启动或切换 profile 时会自动检测已加入队伍且在比赛时间内的赛事,并询问是否快速切换。

具体使用方式可以参见 help 命令的内容。


为带来更快捷的操作体验,我们实现了一个虚拟文件系统来与平台进行交互,其结构大致类似于:

/
├── notice                      # 全局公告
└── contests/
    └── <比赛 ID>/
        ├── info                # 比赛信息
        ├── notice              # 比赛通知
        ├── scoreboard          # 排行榜
        ├── docs/               # readme / training / rules
        ├── team                # 队伍信息
        └── challenges/
            └── <题目 ID>/
                ├── README      # 题面(Markdown 渲染)
                ├── hint        # 题目提示
                ├── files/      # 附件(用 download 下载)
                ├── instance    # 靶机实例信息
                └── flag        # flag 提交

例如,进入比赛、阅读题面、启动实例并提交 flag:

$ cd /contests/22/challenges/908
$ cat README
$ challenge start 908
$ challenge connect        # 经 wsrx 映射本地端口
$ moectf{...}              # 直接粘贴 flag 即可提交

同时,Ret2Console 也实现了较为完整的 CLI 接口,因此你可以像使用 Bash / Zsh 一样使用 Ret2Console:

$ uv run r2c -c "...; ..."

或者放在 Shebang 里面使用:

#!/path/to/r2c
...

Nix 用户请看这里

Ret2Console 具有 Nix Flakes 支持,你可以直接使用 nix run 启动 Ret2Console:

$ nix run github:AstralFlare-owo/ret2console

其余操作方式同上。

开发

本项目由 Deepseek-V4-Flash-0731 完成。

项目的设计说明位于 SPEC.md,可提供给 Agent 进行参考。

环境依赖使用 uv 进行管理,您可运行以下命令一键配置环境:

$ uv sync

构建

Warning

我们的构建脚本未提供自动设置依赖功能,请在构建前运行以下命令设置依赖:

Linux / Darwin(需 python3.12+ 开发头文件、uvpippatchelfgcc/clang):

# Ubuntu / Debian
$ sudo apt install python3-dev patchelf gcc
# Fedora
$ sudo dnf install python3-devel patchelf gcc
# Arch
$ sudo pacman -S python patchelf gcc
# macOS
$ brew install python patchelf
# 项目依赖(uv 或 pip 任选其一)
$ uv sync --all-groups
# 或:pip install -e . nuitka zstandard

Windows(需 Windows 版 Python 3.12 + uv):

$ uv sync --all-groups

对于不同的目标平台,您可以在特定的构建环境使用命令进行构建(Nuitka onefile 单文件产物):

  • Windows: powershell -ExecutionPolicy Bypass -File scripts/build.ps1(或 scripts\build.bat)→ build/win/ret2console.exe
  • Linux / macOS: scripts/build.shbuild/linux/ret2console / build/macos/ret2console

此外,Linux 构建也可以使用 Docker 进行构建:

$ ./scripts/build-in-container.sh

这将自动以 Ubuntu 22.04 (glibc 2.35) 创建 r2c-builder 容器并在其中完成构建,并将构建产物导出到 dist/ret2console

如需重建容器环境(例如换构建基线镜像后)可加 --cleanup 参数。

CI(GitHub Actions)会在推送 / 手动触发时并行构建五个目标(linux-amd64 / linux-arm64 / windows-amd64 / darwin-amd64 / darwin-arm64),产物以 ret2console-nuitka-<target> 命名上传为 artifact。

相关项目

  • Ret2Shell - 特性丰富的夺旗赛平台
  • ret2cli - Ret2Shell CTF 平台的 CLI 客户端(第三方)

开源协议 / LICENSE

本项目基于 GNU General Public License V3 授权。

About

Shell-like CLI made for Ret2Shell the CTF platform.

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Contributors

Languages