encoding-realignment
Skill4 starsChanged 3 months agoMITView on GitHub
Solve CTF challenges where a custom alphabet or unusual string-to-bytes
In this repository80 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .cursor/rules/security-agent-skills.mdcCursor rule
- ai-mcp-securitySkill
- modern-attack-surfacesSkill
- offensive-toolkitSkill
- security-and-hardeningSkill
- security-auditSkill
- security-code-reviewSkill
- ctf-jail-escapeSkill
- ctf-kernel-exploitationSkill
- ctf-misc-toolkitSkill
- ctf-orchestratorSkill
- ctf-playbookSkill
- ctf-technique-atlasSkill
- ctf-training-loopSkill
- ctf-web-exploitationSkill
- ctf-writeup-disciplineSkill
- ctf-writeup-screenshotsSkill
- binary-exploitationSkill
- crypto-attack-patternsSkill
- crypto-ctf-attacksSkill
- cryptography-fundamentalsSkill
- crypto-toolkitSkill
- exploit-developmentSkill
- exploit-poc-builderSkill
- kernel-exploitationSkill
- zero-day-huntingSkill
- bluetooth-jammer-sweepSkill
- esp32-serial-diagSkill
- flipper-zero-backupSkill
- flipper-zero-firmwareSkill
- hardware-iot-hackingSkill
- nrf24-bitbang-spiSkill
- rf-jammer-firmware-portSkill
- rf-multi-protocol-jammerSkill
- smart-card-driver-debugSkill
- smart-card-usb-directSkill
- wifi-deauth-jammerSkill
- wifi-dualband-jammerSkill
- advanced-pentestSkill
- network-pentestSkill
- pentest-quick-checklistSkill
- pentest-tool-referenceSkill
- pentest-tool-setupSkill
- pentest-workflowSkill
- advanced-attack-chainsSkill
- autonomous-pentest-scannerSkill
- intranet-pentest-advancedSkill
- pentest-report-generatorSkill
- post-exploitation-opsSkill
- professional-pentest-guideSkill
- chatgpt-web-relaySkill
- darkweb-researchSkill
- email-osint-investigationSkill
- local-network-reconSkill
- network-device-reconSkill
- osint-frameworkSkill
- osint-recon-modelSkill
- parallel-intel-gatheringSkill
- reconnaissance-opsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 8 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 27
Use this skill for CTF puzzles that are not "broken crypto" so much as misleading encoding pipelines: custom alphabets, Java/UTF-16 string …
- Distinctive: line 40
Do not start here when the task is clearly classical crypto, RSA/ECC, or a web/pwn challenge.
- Distinctive: line 45
If the prompt leaks function names, library names, or upstream source references, reconstruct that exact pipeline first.
- Distinctive: line 60
Do not merge these too early.
- Distinctive: line 66
Before brute forcing anything, write down the exact implied pipeline:
- Distinctive: line 87
Do not substitute a "close enough" alphabet.
- Distinctive: line 110
If the direction looks right but output is garbled, systematically try:
- Distinctive: line 136
Keep a table like:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CTF Encoding Realignment
Overview
Use this skill for CTF puzzles that are not "broken crypto" so much as misleading encoding pipelines: custom alphabets, Java/UTF-16 string byte layouts, partial corruption, framing bytes, bit-offset mistakes, or nested encodings revealed only after realignment.
The key mindset is: partially readable output is evidence, not failure. If a custom decode yields a few plausible characters and a lot of junk, the route may still be correct; the remaining work is often alignment, offset, framing, or a second decode layer.
When to Use
- A challenge provides source code or symbol names that imply a specific encode/decode path
- A Base64-like alphabet is clearly nonstandard
- Direct decode gives a mix of readable prefix/body plus junk
- Decoded bytes look structured but not yet human-readable
- You suspect UTF-16/UTF-32, endianness, framing bytes, or word-level shifts
- You see nested encoding artifacts like
V2V..., PEM-like blocks, hex-looking tails, or obvious flag substrings after a first decode
Do not start here when the task is clearly classical crypto, RSA/ECC, or a web/pwn challenge.
Core Principles
- Exact symbols beat broad guessing
- If the prompt leaks function names, library names, or upstream source references, reconstruct that exact pipeline first.
- Example clues:
dirName(),byteArrayToAltBase64(),UTF_16BE, custom serializer helpers.
- Readable fragments are directional clues
- A short readable prefix does not prove the whole decode is correct.
- But it strongly suggests the alphabet and overall transform family are right.
- Keep layers separate
- Track:
- raw ciphertext / encoded string
- first-stage decoded bytes
- interpreted words/code units
- realigned candidate plaintext
- nested second-layer decodes
- final flag wrapper hypothesis
- Do not merge these too early.
- Track:
Standard Workflow
1. Reconstruct the upstream transform
Before brute forcing anything, write down the exact implied pipeline:
input string
→ optional prefix/suffix framing
→ custom alphabet decode
→ bytes
→ string-byte interpretation (UTF-16BE/LE? UTF-32? raw bytes?)
→ alignment/offset repair
→ nested decode if present
→ flag extractionQuestions:
- Was a prefix added mechanically (
_, version byte, marker)? - Is the alphabet fully known?
- Did the source convert characters to bytes using UTF-16BE/LE or platform-default encoding?
- Is there padding suppression or truncation?
2. Decode with the custom alphabet exactly
Do not substitute a "close enough" alphabet. Build the exact translation table. Log:
- input length
- decoded byte length
- remainder / padding situation
- whether any characters are out-of-alphabet
3. Try structured byte interpretations
Inspect the same bytes as multiple candidate views:
- raw hex
- 8-bit ASCII/Latin-1
- UTF-16BE
- UTF-16LE
- 16-bit words
- 32-bit words if source suggests it
Quick signals:
- alternating zero/high-byte patterns → UTF-16 candidate
- many words with low 6 bits zero → possible bit-shift issue
- readable text every N bytes → framing or interleaving
4. Scan alignment, not just encodings
If the direction looks right but output is garbled, systematically try:
- whole-bitstream shifts
0..15 - byte offsets
0..7where reasonable - word-level transforms such as
word >> k,word << kwith masked carry awareness - skipping an initial framing segment of a few words/bytes
Score candidates by:
- printable ASCII ratio
- presence of flag syntax / leetspeak / English fragments
- Base64/hex/URL-safe subpatterns
- known challenge prefix/suffix
5. Hunt for nested encodings
Once the candidate plaintext becomes partly readable, look for substrings matching:
- standard Base64:
[A-Za-z0-9+/=]{8,} - hex runs
- URL encoding
- gzip/zlib magic
- PEM/ASN.1 headers
- obvious wrapper text around an embedded payload
Decode these as a separate stage, not by rewriting the whole recovered plaintext.
6. Verify each layer independently
Keep a table like:
| Layer | Status | Evidence |
| Custom alphabet identified | verified / hypothesis | source symbol, exact alphabet |
| Prefix removal | verified / hypothesis | upstream function behavior |
| UTF-16BE interpretation | verified / hypothesis | source or byte pattern |
| Bit-shift value | verified / hypothesis | scoring / recovered text |
| Nested Base64 | verified / hypothesis | regex + successful decode |
| Final wrapper | verified / hypothesis | platform rule or observed format |
This prevents "looks right" from becoming false certainty.
OpenJDK altBase64 Pattern
A common pattern validated in practice:
- Challenge references
java.util.prefs.FileSystemPreferences.dirName() - Leading
_is added before encoding - Payload uses Java Preferences alternate Base64 alphabet
- Underlying string bytes are UTF-16BE
- Output may still require bit realignment or skipping framing words
- Recovered plaintext may contain a nested standard Base64 tail
Practical heuristic: if decoded UTF-16 words look like large non-ASCII code points but share suspicious structure, test bitstream shifts before abandoning the path.
Common Pitfalls
- Brute-forcing generic decoders before reading the source clue
- Exact upstream behavior usually narrows the search far faster.
- Trusting the first readable prefix too much
- A prefix can be real, junk, or a wrapper while the main message still needs alignment.
- Normalizing to "better English" too early
- Preserve literal recovered payload first; human interpretation is a later layer.
- Confusing payload with final flag
- The decoded message may still need wrapper extraction or submission-format confirmation.
- Ignoring truncation
- Missing padding or shortened tails can create misleading near-miss decodes.
Quick Triage Checklist
- Wrote down the exact source-implied transform
- Removed only prefixes/suffixes justified by source behavior
- Implemented the exact custom alphabet
- Inspected bytes as UTF-16BE/LE and raw words
- Tried systematic bit/byte/word offset scans
- Scored candidates instead of eyeballing one output
- Separated recovered payload from final flag hypothesis
- Checked for nested Base64/hex/other encodings
- Marked each layer as verified vs hypothesis
Minimal Solver Strategy
For reproducible solves, build a script that:
- decodes the exact alphabet
- prints multiple interpretations
- scans bit offsets / word shifts
- ranks candidates by printability + pattern hits
- extracts nested encodings for separate testing
- prints all final candidates with provenance
Verification Checklist
- Can explain why the chosen alphabet is exact
- Can point to evidence for the selected string-byte encoding
- Can reproduce the realignment numerically (not just visually)
- Can show the nested decode separately from the main recovery
- Can distinguish verified facts from guessed wrapper/flag formatting
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

