phamio/caesar

GitHub: phamio/caesar

一个实现凯撒密码编码与解码的轻量工具,用于教学与CTF场景。

Stars: 0 | Forks: 0

# caesar 一种凯撒密码编码和解码工具。 # 安装 ``` nimble install caesar ``` # 模式参考 [模式参考文件](https://github.com/ph4mished/caesar/blob/main/pattern.md) # 用法 ``` caesar -h ``` # 帮助输出 ``` =============================================================== Caesar 0.1.0 - Caesar cipher encoding and decoding =============================================================== Encode or Decode file in Caesar cipher. Usage: caesar [OPTIONS] Input may be a file path or stdin When no FILE is provided, read from standard input ===== ARGUMENT ===== File for caesar cipher encoding/decoding. ===== OPTIONS ===== -k, --key NUM Key for cipher encoding or decoding [default: 3] -p, --pattern PATTERN Advanced key patterns for cipher encoding or decoding(progressive cipher). Use 'caesar pattern --help' for complete reference -c, --count Count all characters (including non-alpha-ascii letters) for position index. -d, --decode Decode caesar cipher -h, --help Show this help. -v, --version Show version information. ====== EXAMPLES ===== # Encoding caesar my_file.txt -k 23 # Text Encoding echo 'hello world' | caesar -k 23 # Progressive Cipher Encoding echo 'hello world' | caesar -p 13:1 # Decoding caesar enc_file.txt -d -k 5 # Text Decoding echo 'uryyb jbeyq' | caesar -k 13 -d # Progressive Cipher Decoding echo 'usabf ohlgz' | caesar -p 13:1 -d NOTE: input containing spaces or special characters should be placed in quotes. ``` # 模式帮助 ``` caesar pattern --help ``` ## 输出 ``` =============================================================== Caesar 0.1.0 - Pattern Reference =============================================================== Advanced key patterns for progressive and variant Caesar ciphers. Usage: caesar --pattern PATTERN [OPTIONS] ===== PATTERN SYNTAX ===== 1. LINEAR INCREMENT KEY:STEP Add STEP to KEY for each letter. Example: '0:1' 0,1,2,3,4,5... Example: '25:-1' 25,24,23,22...(count down) Example: '3:2' 3,5,7,9,11... 2. CYCLIC INCREMENT KEY:STEP:CYCLE Add STEP to KEY for each letter, reset every CYCLE Example: '3:1:5' 3,4,5,6,7, 3,4,5,6,7... Example: '0:3:4' 0,3,6,9, 0,3,6,9... 3. BLOCK PATTERN KEY:STEP::BLOCK Same KEY for BLOCK chars, increment by STEP Example: '5:1::3' 5,5,5, 6,6,6, 7,7,7... Example: '3:2::4' 3,3,3,3, 5,5,5,5, 7,7,7,7... 4. CUSTOM SEQUENCE A,B,C,D... Repeat exact sequence of keys Example: '7,3,9' 7,3,9, 7,3,9, 7,3,9... Example: '1,4,9,16' 1,4,9,16, 1,4,9,16, 1,4,9,16... ===== POSITION COUNTING ===== By default, patterns use LETTER-ONLY position counting: 'a_b' => 'a'=position0, 'b'=position1 (underscore ignored) Use --count flag for ALL-CHARACTER counting: 'a_b' => 'a'=position0, 'b'=position2 (underscore counts as position1) ====== PRACTICAL EXAMPLES ===== # Common CTF Patterns caesar -p 0:1 my_file.txt #Increment by 1 each letter. caesar -p 3:1:5 message.txt #Decode cyclic pattern. caesar -p 5:1::3 flag.txt #Same key for 3 chars. caesar -p 7,3,9 puzzle.txt #Custom sequence # With Position Counting Options caesar -p 0:1 my_file.txt -c #Count all caesar -p 0:1 message.txt #Count only alpha-ascii letters # Mathematical Patterns '0:1' = f(n) = n #Linear. '3:1:5' = f(n) = 3 + (n mod 5) #Modulo cycle. '0:2' = f(n) = 2n #Even Numbers. '1:2' = f(n) = 2n + 1 #Odd Numbers. ====== NOTE ===== - Keys wrap automatically modulo 26 - Non-alpha-ascii letters (spaces, numbers, punctuations) are never shifted - Patterns work with both uppercase and lowercase letters ``` **注意**:凯撒密码极其脆弱,不要将其用于任何需要保护的内容 # 总结 我编写这个工具是为了 - 学习 Nim - 成为我 CTF 工具箱中的一个工具
标签:CLI, DOS头擦除, meg, Nim, nimble, ProjectDiscovery, WiFi技术, 二进制发布, 信息安全, 凯撒密码, 加密, 古典密码, 字符替换, 实用工具, 密码学, 密码破解, 开源工具, 手动系统调用, 数据保护, 文件加密, 文本加密, 模式匹配, 漏洞扫描器, 编码, 自动化资产收集, 解码, 进阶密钥, 隐私安全