Skip to content

Add CTF Workspace and Artifact Analyzer (binary analysis, transforms, detectors)#17

Closed
T3pp31 wants to merge 4 commits into
mainfrom
codex/refactor-project-to-focus-on-ctf-solving
Closed

Add CTF Workspace and Artifact Analyzer (binary analysis, transforms, detectors)#17
T3pp31 wants to merge 4 commits into
mainfrom
codex/refactor-project-to-focus-on-ctf-solving

Conversation

@T3pp31

@T3pp31 T3pp31 commented May 13, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Consolidate and re-scope the app toward a local-first CTF Solver Workbench focused on safely analyzing artifacts, extracting flag candidates and generating writeups.
  • Provide richer binary/file analysis (magic bytes, hashes, printable strings, entropy, flag heuristics) and client-side utilities for common CTF transformations and detections.

Description

  • Add a binary analysis pipeline in the backend: new config section binary_analysis, dependency sha2, updated src-tauri config and Cargo.toml/Cargo.lock, and read_binary_file Tauri command now takes AppState and passes analysis config to utils::binary::read_file.
  • Implement src-tauri/src/utils/binary.rs to stream-read up to max_read_bytes, produce hex preview, decoded text preview, magic bytes, file type guess, SHA256, printable strings, flag candidate extraction, entropy calculation and warnings.
  • Introduce a CTF feature module in the frontend under src/features/ctf with types, transforms (CTF_TRANSFORMS), detectors, flag patterns, operation history helpers and writeup Markdown generator, and wire new UI pages/components (CtfPage, enhanced BinaryPage, updated HomePage and Sidebar) to expose the workbench workflow.
  • Update type definitions in src/types for the richer BinaryContent shape and add unit tests that exercise detectors, transforms and writeup generation, plus adjust an existing Tauri invoke test to the new binary response shape.

Testing

  • Ran the vitest unit test suite which includes the new tests/ctfWorkbench.test.ts and adjusted tests/tauriInvokeArgs.test.tsx, and all tests passed.
  • Frontend compile/type checks were validated via the local dev build during development (npx vite/TypeScript compile) with no reported type errors.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9527f5b371

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src-tauri/src/config.rs
pub network: NetworkConfig,
pub feature_flags: FeatureFlagsConfig,
pub paths: PathsConfig,
pub binary_analysis: BinaryAnalysisConfig,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Make new config section optional

When an installed app is upgraded with an existing config/default.toml that lacks the new [binary_analysis] table, this required field makes toml::from_str fail with a missing-field error; run() then falls back to AppConfig::default(), silently discarding all user-tuned scan/vendor/path settings. Add a serde default for this field (and the nested struct) or merge defaults so older config files keep loading.

Useful? React with 👍 / 👎.

T3pp31 commented May 14, 2026

Copy link
Copy Markdown
Owner Author

確認しましたが、この PR は現状マージしません。

理由:

対応案:

  1. main に rebase/merge して CI 削除差分を消す。
  2. README と UI を CTF Solver Workbench 中心に再構成 #18-CTFワークスペースを追加 #22 のうち、この PR に吸収するものと閉じるものを明確にする。
  3. CTF workspace と Binary analysis の設計を 1 系統に絞ったうえで、再度 npm run lintnpm run build、可能な範囲の test を通してください。

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1e3774edaf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

let decoded_slice = &data[..data.len().min(config.decoded_text_preview_bytes)];
let decoded_text = String::from_utf8_lossy(decoded_slice).to_string();
let magic_bytes = format_magic_bytes(&data);
let file_type_guess = guess_file_type(&data);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Hash the full artifact before truncating analysis input

When a selected file exceeds max_read_bytes, data contains only the prefix read through Take, but this line still reports that digest in the UI as SHA256 for the file. Large challenge artifacts will therefore show a hash that does not match the actual file even though file_size is the full size; either compute the digest from the full stream or clearly label it as a truncated-prefix hash.

Useful? React with 👍 / 👎.


const makeResult = (label: string, output: string, note?: string): CtfTransformResult => ({
label,
output: toPreview(output),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve full transform output separately from previews

For any transform result longer than 4000 characters, this stores the truncated preview string as the actual output. Chaining the result back into the input, collecting flags from operation outputs, and exporting the writeup will all use the shortened text with the ...省略 marker, so multi-step decoding of larger blobs silently corrupts the workspace state; keep the full output and truncate only at render/preview boundaries.

Useful? React with 👍 / 👎.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 94b7ea66e8

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src-tauri/src/config.rs
Comment on lines +59 to +63
pub max_read_bytes: usize,
pub hex_preview_bytes: usize,
pub decoded_text_preview_bytes: usize,
pub max_strings: usize,
pub min_string_length: usize,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Default missing binary analysis fields

The current code defaults the binary_analysis table itself, but these nested fields are still required once the table is present. If a user adds only one documented override such as [binary_analysis] max_read_bytes = ..., toml::from_str fails on the other missing keys and run() falls back to AppConfig::default(), discarding the rest of the user's scan/vendor/path settings; add per-field serde defaults or deserialize this section by merging with BinaryAnalysisConfig::default().

Useful? React with 👍 / 👎.

T3pp31 commented May 14, 2026

Copy link
Copy Markdown
Owner Author

この PR は現在の main に対して conflict しており、内容も #18 / #19 / #20 / #21 / #22 で分割して取り込んだ変更と大部分が重複しています。

特に CTF feature module、BinaryPage/CtfPage、binary analysis、writeup/history まわりは既に main 側へ反映済みで、この PR をさらにマージすると同じ領域を別実装で上書きするリスクが高いです。そのため、この PR は superseded と判断して閉じます。

@T3pp31 T3pp31 closed this May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant