{"id":13845714,"url":"https://github.com/ignis-sec/CtfCryptoTool","last_synced_at":"2025-07-12T03:31:43.144Z","repository":{"id":81931074,"uuid":"243517192","full_name":"ignis-sec/CtfCryptoTool","owner":"ignis-sec","description":"A tool for automated analysis of ctf type crypto challenges","archived":false,"fork":false,"pushed_at":"2020-03-03T15:19:08.000Z","size":63,"stargazers_count":29,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-11T07:13:10.534Z","etag":null,"topics":["crypto","cryptography","ctf"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ignis-sec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-27T12:44:29.000Z","updated_at":"2025-05-05T09:49:12.000Z","dependencies_parsed_at":"2023-06-30T02:16:16.809Z","dependency_job_id":null,"html_url":"https://github.com/ignis-sec/CtfCryptoTool","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ignis-sec/CtfCryptoTool","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignis-sec%2FCtfCryptoTool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignis-sec%2FCtfCryptoTool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignis-sec%2FCtfCryptoTool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignis-sec%2FCtfCryptoTool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ignis-sec","download_url":"https://codeload.github.com/ignis-sec/CtfCryptoTool/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignis-sec%2FCtfCryptoTool/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264930717,"owners_count":23684916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crypto","cryptography","ctf"],"created_at":"2024-08-04T17:03:34.056Z","updated_at":"2025-07-12T03:31:43.127Z","avatar_url":"https://github.com/ignis-sec.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# CtfCryptoTool\n\nThis is a tool aiming to significantly cut-off manual-labor of ctf crypto challenges, mostly ones related to classical, non modern ciphers.\n\nUsage:\n```\nCtfCrpytoTool.py [-h] [-v] [-k KEY] [-b] [-p PLAIN] [-f] [-d DEPTH] [-i IGNORE] ciphertext\n```\n\n\n```\npositional arguments:\n  ciphertext            ciphertext to analyse\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -v, --verbose         set verbosity level\n  -k KEY, --key KEY     use a key\n  -b, --brute           attempt brute force on the text\n  -p PLAIN, --plain PLAIN\n                        a part of a plaintext to search for (required for recursive checks)\n  -f, --file            give a file instead of cli text\n  -d DEPTH, --depth DEPTH\n                        depth limit for recursive search\n  -i IGNORE, --ignore IGNORE\n                        (regex) characters to ignore during charset analysis\n```\n\n\n## Example Usage\n### Recursively find solution using flag format\n```\npython3 CtfCrpytoTool.py \"NmIgNzEgNjYgNmMgN2IgNjggNzcgNjQgNzUgNzkgNzQgMjAgNmUgNzggMjAgNmIgN2EgNzMgN2Q=\" -p \"flag{.*}\" -i \"[{}]\"\n```\n\n[![asciicast](https://asciinema.org/a/XKVCGym6aFCZGhg6HtSjWZQRA.svg)](https://asciinema.org/a/XKVCGym6aFCZGhg6HtSjWZQRA)\n\n\n### Simple Mode\n```\npython3 CtfCrpytoTool.py \"102 108 97 103 123 99 114 121 112 116 111 32 105 115 32 102 117 110 125\"\n```\n[![asciicast](https://asciinema.org/a/WpPR6f44jmHcsg6nAMXSEoNqG.svg)](https://asciinema.org/a/WpPR6f44jmHcsg6nAMXSEoNqG)\n\n\n### Known Key Example (Affine key in the example)\n\n```\npython3 CtfCrpytoTool.py \"00110001 00110001 00110100 00100000 00110001 00110000 00110110 00100000 00111001 00111001 00100000 00110001 00110001 00110111 00100000 00110001 00110010 00110011 00100000 00110001 00110000 00110101 00100000 00111001 00111000 00100000 00110001 00110001 00111001 00100000 00110001 00110001 00111000 00100000 00110001 00110000 00110100 00100000 00110001 00110001 00110101 00100000 00110011 00110010 00100000 00111001 00110111 00100000 00110001 00110000 00110001 00100000 00110011 00110010 00100000 00110001 00110001 00110100 00100000 00110001 00110000 00110111 00100000 00110001 00110001 00110010 00100000 00110001 00110010 00110101\" -p \"flag{.*}\" -i \"[{}]\" -k \"3,2\" -d 4\n```\n[![asciicast](https://asciinema.org/a/3BhmSsvRm6onITQWPe0j3CRIf.svg)](https://asciinema.org/a/3BhmSsvRm6onITQWPe0j3CRIf)\n\n\n\n# Extending modules\n\nDocumentation on how to create a simple module is given below. You can just use one of the templates below, and build on top of that.\nTo get it imported, just drop it to the correct folder in the tool.\n\n## Analysis modules\n\nAnalysis modules are dynamically loaded from the `./analysis` folder.\n\nDuring the analysis step, tool iterates over all the analysis modules, and calls their analyse function.\n\n---\n\nVery minimal analysis module example:\n\n```py\nname = \"Ciphertext Length\"\nsuccess = \"Found cipher length\"\nfail = \"failed\"\n\ndef analyse(result, text, **kwargs):\n    result[\"cipherLength\"]=len(text)\n    result[\"cipherLengthNOWS\"]=len(text.replace(' ',''))\n    return True\n```\n---\n\n### Analysis module Components:\n\n#### Name:\nName of the module to be printed during the load process\n\n#### Success\nWill be printed when analysis is completed in verbose mode\n\n#### Share (optional)\nA list of strings, holding variable names to be shared. Given variables will be added to the sharedData dictionary.\n\n#### Prequisites (optional)\nA list of strings, holding which values should be in the result dictionary for this module to be used. If any of the key values is not in the result dictionary, module will be called after all the remaining modules are called.\n\n#### Fail\nWill be printed if module throws an exception.\n\n---\n\n### Analyse Function\nWill be called with following arguements:\n```py\nmodule.analyse(results,cipher,ignore=self.ignore, shared=self.sharedData)\n```\n\n### Arguements\n* results: A dictionary to store all the results for the given ciphertext\n* cipher: ciphertext itself\n* ignore: characters to ignore during analysis (in regex format, `r\"[abc]\"`)\n* shared: shared data between modules. Data contained in this dictionary is independent from the ciphertext being analysed:\n    * example: All the charsets defined in charset analysis module\n    * if a crypto module was called before during this run.\n\n--- \n\n\n\n\n## Crypto Modules\n\nCrypto modules are dynamically loaded from the `./crypto` folder, and `./crypto/helpers` subfolder.\n\nAfter the analysis step, tool iterates over all the crypto modules, and calls their check function.\n\nIf check function returns true, then decryption is attempted with decrypt function.\n\n--- \nVery minimal crypto module example:\n\n```py\nimport binascii\nimport re\nname = \"Hex\"\npriority=50\n\ndef check(result,**kwargs):\n    if(\"charset\" in result):\n        if(not result[\"charset\"]==r\"[0-9a-fA-F ]\" and not result[\"charset\"]==r\"[0-9 ]\"):\n            return False\n    \n    if(\"entropy\" in result):\n        if(result[\"entropy\"]\u003c=1.95 or result[\"entropy\"]\u003e=4):\n            return False\n    \n    return True\n\n\ndef decrypt(text, **kwargs):\n    text = text.replace(' ', '')\n    res = binascii.unhexlify(text).decode()\n    if(re.match(r'^[ -~]*$',res)):\n        return res\n    else:\n        return False\n```\n\n---\n\n### Crypto module Components:\n\n#### Name:\nName of the module to be printed during for the trace output\n\n#### Priority (optional):\nCrypto modules are called in order which is sorted on their priority value. Lower priority values algorithms will be called as a last resort.\nDefault is 50.\n\n\n#### Prequisites (optional):\n\nRequired key values in result dictionary. If the key values are not found in the dictionary, module wont be called.\n\n---\n\n### Check Function\nThis is a forward check to see if given ciphertext can be decoded with this module, without actually decoding it.\nReturns boolean. True for check-pass, False for check-fail.\n\nIt is called with following arguements:\n```py\nmodule.check(results,key=self.key,plain=self.plain,text=cipher, shared=self.sharedData)\n```\n\n### Arguements\n* results: A dictionary to store all the results for the given ciphertext\n* key: key to be used if its needed\n* plain: Flag format of the plaintext\n* cipher: ciphertext\n* shared: shared data between modules. Data contained in this dictionary is independent from the ciphertext being analysed:\n    * example: All the charsets defined in charset analysis module\n    * if a crypto module was called before during this run.\n\n--- \n\n\n### Decrypt Function\nThis function is called if forward checks pass, and attempts to decrypt the ciphertext.\n\nIt is called with following arguements:\n```py\nmodule.decrypt(cipher,key=self.key,plain=self.plain, shared=self.sharedData)\n```\n\n### Arguements\n\n* cipher: ciphertext\n* key: key to be used if its needed\n* plain: Flag format of the plaintext\n* shared: shared data between modules. Data contained in this dictionary is independent from the ciphertext being analysed:\n    * example: All the charsets defined in charset analysis module\n    * if a crypto module was called before during this run.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignis-sec%2FCtfCryptoTool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fignis-sec%2FCtfCryptoTool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignis-sec%2FCtfCryptoTool/lists"}