Skip to main content

flag_capturer

Point it at a file, a folder or a string and it digs out CTF flags, peeling off layers of encoding until something looks like flag{...}. Every hit shows the path it took.

$ flag_capturer challenge.bin
[binary] challenge.bin
[+] flag{x0r_1s_n0t_encrypt10n}
    challenge.bin  via  strings -> base64 -> xor(0x12)

Install

pip install flag-capturer

No admin rights? Use pip install --user flag-capturer. Then run flag_capturer (or the short flagcap). If the command is not found, python -m flag_capturer always works.

Use

flag_capturer                            # everything in the current folder
flag_capturer file.bin                   # one file
flag_capturer ./challenge_folder         # every file in a folder
flag_capturer -s "ZmxhZ3toaX0="          # a string
cat dump.txt | flag_capturer             # stdin
flag_capturer file -p DUCTF -p picoCTF   # extra flag prefixes (name only)
flag_capturer file -r "SECRET-[0-9]{6}"  # your own regex
flag_capturer file --loose               # also show anything shaped like WORD{...}
flag_capturer file --json                # for scripts
flag_capturer challenge.exe -e            # Ghidra steps and a CyberChef recipe under each hit

-e / --explain records the winning path's byte ranges and known addresses. Load the original input into CyberChef to apply the printed recipe. Specialized steps include manual or Python instructions. With --json --explain, each hit also has steps and cyberchef (null when the complete path needs manual work).

Built-in prefixes: flag, anything ending in CTF, HTB, THM. Flags with other prefixes are still listed as [?] suggestions.

中文快速上手

在资源管理器打开题目文件夹,地址栏输入 powershell 回车,然后运行 python -m flag_capturer .(点号 = 当前文件夹)。flag 前缀不常见的话加 -p 前缀名。PowerShell 出现 >> 时按 Ctrl+C 退出。

What it handles

Encodings and layers (stacked up to depth 5)

  • ASCII and UTF-16 strings inside binaries
  • base64 / base64url / base32 / base85 / ascii85, hex, binary, decimal, octal, URL encoding
  • rot13 and every other Caesar shift, rot47, reversed text
  • single-byte XOR (all 255 keys, pre-filtered against known prefixes)
  • gzip / zlib / bz2 / lzma streams and zip archives
  • base64/hex/binary-looking chunks cut out of longer text

File formats (the detected format is printed before each scan)

  • Windows PE (MinGW x64): constant arrays and split comparison fragments, repeating-key XOR on Base64 text, byte subtraction on flag-shaped text
  • Dropped PowerShell IOC puzzles: recognizes an indexed-XOR decoder feeding a script and a NUL-separated configuration. Tracks the buffer and byte count passed to a WriteFile wrapper and the configuration field passed to an InternetConnectA wrapper. Formats the first 16 SHA-256 hex digits of the written bytes, host and original assembly-load method spelling as a candidate.
  • Deterministic aim puzzles: recognizes a 64-bit linear congruential target generator, two coordinate ranges, a multiply-XOR coordinate hash (XOR before multiplication), and a three-shift XOR release loop. Replays the target centers using constants from the image and checks the resulting flag syntax.
  • .NET assemblies: IL string literals, including adjacent literals joined by String.Concat; read statically, never executed
  • PCAP / PCAPNG: UDP payloads and reassembled TCP streams per direction (no TLS decryption or IP fragment reassembly)
  • Linux ELF x86-64: literal IPv4 addresses passed to connect, built on the stack or read from read-only data; also from Ghidra text listings
  • Intel assembly listings: little-endian immediates

Limits

Runtime-derived candidates require a recognized computation and recoverable inputs. The two native rules above recognize specific MinGW x64 instruction patterns and use PE unwind information to locate functions. Compiler changes, different algorithms, or inputs supplied by a remote service can require manual analysis. Each result includes the extraction path.

Extending

Implement formats.base.Analyzer (identify and extract) and register the instance in formats.FORMATS. Each extracted Part carries its bytes and provenance; set nested=True for embedded files that should be identified again.

For an additional native PE puzzle family, implement recognizes(data) and extract(image) and register the rule in formats.pe_rules.RULES. The rules share a static image reader, import names and disassembled functions.

Play fair

Use it on CTFs and practice boxes that allow tools. If a competition or exam says no automated tools, leave it at home.

License

PolyForm Strict 1.0.0: free to install and use for noncommercial purposes, but no redistribution and no modified versions. See LICENSE.

Metadata

Release files for flag-capturer 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flag-capturer 0.5.0
File Size Uploaded Provenance Actions
flag_capturer-0.5.0.tar.gz 42.1 kB Without provenance Details for flag_capturer-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flag-capturer 0.5.0
File Interpreter ABI Platform Actions
flag_capturer-0.5.0-py3-none-any.whl Python 3 none any Details for flag_capturer-0.5.0-py3-none-any.whl

Total release size: 80.8 kB

Release files / flag_capturer-0.5.0.tar.gz

Download URL flag_capturer-0.5.0.tar.gz
Size 42.1 kB
Tags Source
SHA-256 checksum
How to use checksums
41352c646ccc8e8d81c177d656bf87f0a4cfc0c247f6d61ee1ab4b59b927837b
BLAKE2b-256 checksum
How to use checksums
08f820f12abaf645f824bf048407061e33b21d3dd766948745408b75debcf114
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Release files / flag_capturer-0.5.0-py3-none-any.whl

Download URL flag_capturer-0.5.0-py3-none-any.whl
Size 38.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e898fbe28118059cbb77788374711b0557ff299276e72cc0a545114154eced5
BLAKE2b-256 checksum
How to use checksums
0586e9e8283f074f65ccad1848ec6859b62d8d49b6fc5a5aa9dcb90cb67eb644
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.4

Security for flag-capturer 0.5.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page