├── .gitignore
├── .gitmodules
├── LICENSE
├── README.md
├── docs
├── cryptosploit
│ ├── cryptosploit.html
│ ├── cryptosploit
│ │ ├── cprint.html
│ │ └── exceptions.html
│ ├── index.html
│ └── search.js
└── cryptosploit_modules
│ ├── cryptosploit_modules.html
│ ├── cryptosploit_modules
│ ├── asymmetric.html
│ ├── asymmetric
│ │ ├── rsa.html
│ │ └── rsa
│ │ │ └── rsactftool.html
│ ├── encodings.html
│ ├── encodings
│ │ ├── base.html
│ │ ├── base
│ │ │ ├── base16.html
│ │ │ ├── base32.html
│ │ │ ├── base64.html
│ │ │ └── base85.html
│ │ ├── hex.html
│ │ ├── morse.html
│ │ └── urlencode.html
│ ├── hashes.html
│ ├── hashes
│ │ ├── cracker.html
│ │ └── cracker
│ │ │ └── hash_identifier.html
│ ├── symmetric.html
│ ├── symmetric
│ │ ├── aes.html
│ │ ├── affine.html
│ │ ├── atbash.html
│ │ └── rot.html
│ ├── templates.html
│ └── templates
│ │ ├── ExampleBinaryModuleName.html
│ │ └── ExamplePythonModuleName.html
│ ├── index.html
│ └── search.js
├── gif_images
└── cryptosploit.gif
├── images
└── cryptosploit_logo.png
├── setup.cfg
├── setup.py
└── src
└── cryptosploit
├── __init__.py
├── __main__.py
├── banners.py
├── console.py
├── cprint.py
└── exceptions.py
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 | .vscode
3 | *.iml
4 | out
5 | test.py
6 | gen
7 | __pycache__/
8 | *.py[cod]
9 | *$py.class
10 | *.so
11 | .Python
12 | build/
13 | develop-eggs/
14 | dist/
15 | downloads/
16 | eggs/
17 | .eggs/
18 | lib/
19 | lib64/
20 | parts/
21 | sdist/
22 | var/
23 | wheels/
24 | share/python-wheels/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 | MANIFEST
29 | *.manifest
30 | *.spec
31 | pip-log.txt
32 | pip-delete-this-directory.txt
33 | htmlcov/
34 | .tox/
35 | .nox/
36 | .coverage
37 | .coverage.*
38 | .cache
39 | nosetests.xml
40 | coverage.xml
41 | *.cover
42 | *.py,cover
43 | .hypothesis/
44 | .pytest_cache/
45 | cover/
46 | *.mo
47 | *.pot
48 | *.log
49 | local_settings.py
50 | db.sqlite3
51 | db.sqlite3-journal
52 | instance/
53 | .webassets-cache
54 | .scrapy
55 | docs/_build/
56 | .pybuilder/
57 | target/
58 | .ipynb_checkpoints
59 | profile_default/
60 | ipython_config.py
61 | __pypackages__/
62 | celerybeat-schedule
63 | celerybeat.pid
64 | *.sage.py
65 | .env
66 | .venv
67 | env/
68 | venv/
69 | ENV/
70 | env.bak/
71 | venv.bak/
72 | .spyderproject
73 | .spyproject
74 | .ropeproject
75 | /site
76 | .mypy_cache/
77 | .dmypy.json
78 | dmypy.json
79 | .pyre/
80 | .pytype/
81 | cython_debug/
82 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "cryptosploit_modules"]
2 | path = cryptosploit_modules
3 | url = https://github.com/y73n0k/cryptosploit_modules.git
4 | branch = main
5 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Cryptosploit
2 | ===
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | A decryption/decoding/cracking tool using various modules.
17 |
18 | To use it, you need to have basic knowledge of cryptography.
19 |
20 |
21 | Table of Contents
22 | ---
23 | - [Cryptosploit](#cryptosploit)
24 | - [Table of Contents](#table-of-contents)
25 | - [🔨 Installation Guide](#-installation-guide)
26 | - [🤔 What is this?](#-what-is-this)
27 | - [🏃♀️ Running Cryptosploit](#️-running-cryptosploit)
28 | - [💻 Modules](#modules)
29 |
30 | ## 🔨 Installation Guide
31 |
32 | We recommend you to install cryptosploit in a **python virtual environment**, but you can also install cryptosploit on the main system.
33 |
34 |
35 |
36 | ### With python virtual environment
37 |
38 | ```sh
39 | python -m venv venv
40 | source venv/bin/activate
41 | pip install git+https://github.com/SNESEAR/cryptosploit.git --upgrade
42 | deactivate
43 | ```
44 |
45 |
46 |
47 | ### On main system
48 |
49 | Alternatively, you can install cryptosploit without sudo and modify your $PATH.
50 |
51 | ```sh
52 | pip install git+https://github.com/SNESEAR/cryptosploit.git --upgrade
53 | echo "export PATH=$PATH:~/.local/bin" >> ~/.bashrc
54 | ```
55 |
56 |
57 | 🤔 What is this?
58 | ---
59 | Cryptosploit is a new module-based cryptographic tool, it designed to become **a tool for automating a lot of routine work with various scripts**. You can use it to solve different cryptographic tasks.
60 |
61 | In fact, it is a large library of tools. **You don't need a directory with gigabytes of cryptographic tools**.
62 | You mustn't keep in mind all the flags and modes in the cli tools anymore.
63 | Cryptosploit will do it for you :З
64 |
65 |
66 | 🏃♀️ Running Cryptosploit
67 | ---
68 | Very simple way of usage:
69 |
70 | 
71 |
72 |
73 |
74 | Read more about any command
75 | ```
76 | crsconsole> help
77 |
78 | Documented commands (type help ):
79 | ========================================
80 | cd exit get help run search set shell unset use
81 |
82 | crsconsole> help search
83 |
84 | Search modules by keyword.
85 | Example: search rot
86 |
87 | ```
88 |
89 |
90 | You can search modules by regular expressions
91 | ```
92 | crsconsole> search hash
93 | [>] Founded:
94 | hashes.cracker
95 | ```
96 |
97 |
98 | Then just type use founded.module
99 | ```
100 | crsconsole> use hashes.cracker
101 | [>] Module loaded successfully
102 | ```
103 |
104 |
105 | Get and set module variables
106 | ```
107 | crsconsole (hashes.cracker)> get
108 | ╒════════════════════╤═════════╤══════════════════════════════════════════════════╕
109 | │ Name │ Value │ Description │
110 | ╞════════════════════╪═════════╪══════════════════════════════════════════════════╡
111 | │ default_cracker │ hashcat │ Default program to crack hashes (hashcat/john). │
112 | │ │ │ You must install one of these tools. │
113 | ├────────────────────┼─────────┼──────────────────────────────────────────────────┤
114 | │ mode │ help │ Operation mode. May be crack/help/advanced. │
115 | │ │ │ Just type run. Advanced users can │
116 | │ │ │ pass all the arguments in extra_flags │
117 | ├────────────────────┼─────────┼──────────────────────────────────────────────────┤
118 | │ hash_file │ │ Path to file with hash. │
119 | ├────────────────────┼─────────┼──────────────────────────────────────────────────┤
120 | │ wordlist │ │ Path to wordlist. │
121 | │ │ │ For example, '/usr/share/wordlists/rockyou.txt' │
122 | ├────────────────────┼─────────┼──────────────────────────────────────────────────┤
123 | │ identify_hash_type │ true │ We will try to identify hash type │
124 | │ │ │ and pass most possible type in hash_mode │
125 | │ │ │ use 'run' again to try next possible type │
126 | ├────────────────────┼─────────┼──────────────────────────────────────────────────┤
127 | │ hash_mode │ │ Mode of your hash for you program. │
128 | │ │ │ For example, '0' (like in hashcat) │
129 | ├────────────────────┼─────────┼──────────────────────────────────────────────────┤
130 | │ extra_flags │ │ Add your own flags. │
131 | │ │ │ For example, '--save-memory=1 --fork=10' │
132 | ├────────────────────┼─────────┼──────────────────────────────────────────────────┤
133 | │ path_to_binary │ │ Specify the path to your program. │
134 | │ │ │ For example, '/usr/bin/hashcat' │
135 | │ │ │ Must contain hashcat/john │
136 | ╘════════════════════╧═════════╧══════════════════════════════════════════════════╛
137 | crsconsole (hashes.cracker)> set mode advanced
138 | [>] Setting mode -> advanced
139 | crsconsole (hashes.cracker)> set extra_flags -a 3 -m 0 hash_to_crack ?a?a?a?a?a?a
140 | [>] Setting extra_flags -> -a 3 -m 0 hash_to_crack ?a?a?a?a?a?a
141 | ```
142 |
143 |
144 | Type run to execute module functionality
145 |
146 | ```
147 | crsconsole (hashes.cracker)> run
148 | ```
149 |
150 | 💻 [Modules](https://github.com/y73n0k/cryptosploit_modules)
151 | ---
152 | As you have already read, this tool is module-based, that's why it is still in development. We want to extend our module's database.
153 |
154 | Anybody can write their own module in any programming language and add it to cryptosploit using a very simple and convenient API in python.
155 | Visit our [modules github wiki](https://github.com/y73n0k/cryptosploit_modules/wiki) to get details about module writing.
156 |
--------------------------------------------------------------------------------
/docs/cryptosploit/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/docs/cryptosploit_modules/cryptosploit_modules/asymmetric.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | cryptosploit_modules.asymmetric API documentation
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
44 |
45 |
46 |
53 |
54 |
232 |
--------------------------------------------------------------------------------
/docs/cryptosploit_modules/cryptosploit_modules/asymmetric/rsa.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | cryptosploit_modules.asymmetric.rsa API documentation
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
44 |
45 |
46 |
53 |
54 |
232 |
--------------------------------------------------------------------------------
/docs/cryptosploit_modules/cryptosploit_modules/encodings.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | cryptosploit_modules.encodings API documentation
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
47 |
48 |
49 |
56 |
57 |
235 |
--------------------------------------------------------------------------------
/docs/cryptosploit_modules/cryptosploit_modules/encodings/base.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | cryptosploit_modules.encodings.base API documentation
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
47 |
48 |
49 |
56 |
57 |
235 |
--------------------------------------------------------------------------------
/docs/cryptosploit_modules/cryptosploit_modules/hashes.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | cryptosploit_modules.hashes API documentation
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
44 |
45 |
46 |
53 |
54 |
232 |
--------------------------------------------------------------------------------
/docs/cryptosploit_modules/cryptosploit_modules/symmetric.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | cryptosploit_modules.symmetric API documentation
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
47 |
48 |
49 |
56 |
57 |
235 |
--------------------------------------------------------------------------------
/docs/cryptosploit_modules/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/gif_images/cryptosploit.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cryptosploit/cryptosploit/91a378cd93084aa5fd853f3080865d8bbab4d7ca/gif_images/cryptosploit.gif
--------------------------------------------------------------------------------
/images/cryptosploit_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cryptosploit/cryptosploit/91a378cd93084aa5fd853f3080865d8bbab4d7ca/images/cryptosploit_logo.png
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [metadata]
2 | name = cryptosploit
3 | version = 0.3.1.0
4 | url = https://github.com/SNESEAR/cryptosploit
5 | author = SNESEAR, y73n0k
6 | author_email = snesear@yandex.ru, ytka.kek@yandex.ru
7 | description = Cryptographic tool
8 | long_description = file: README.md
9 | long_description_content_type = text/markdown
10 | classifiers =
11 | Development Status :: 3 - Alpha
12 | Environment :: Console
13 | Programming Language :: Python :: 3
14 | License :: OSI Approved :: GNU General Public License (GPL)
15 | Operating System :: POSIX :: Linux
16 | Topic :: Security :: Cryptography
17 |
18 | [options]
19 | include_package_data = True
20 | install_requires =
21 | cryptosploit_modules @ git+https://github.com/y73n0k/cryptosploit_modules.git
22 | python_requires = >=3.10
23 | package_dir =
24 | =src
25 | packages = find:
26 |
27 | [options.packages.find]
28 | where = src
29 |
30 | [options.entry_points]
31 | console_scripts =
32 | cryptosploit = cryptosploit.__main__:main
33 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup
2 |
3 | setup()
4 |
--------------------------------------------------------------------------------
/src/cryptosploit/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cryptosploit/cryptosploit/91a378cd93084aa5fd853f3080865d8bbab4d7ca/src/cryptosploit/__init__.py
--------------------------------------------------------------------------------
/src/cryptosploit/__main__.py:
--------------------------------------------------------------------------------
1 | from .console import CRSConsole
2 |
3 |
4 | def main():
5 | console = CRSConsole()
6 | console.cmdloop()
7 |
--------------------------------------------------------------------------------
/src/cryptosploit/banners.py:
--------------------------------------------------------------------------------
1 | from random import choice
2 |
3 | from .cprint import SGR, colorize_strings
4 |
5 |
6 | BANNERS = [
7 | r"""
8 | ________ ________ ___ ___ ________ _________ ________ ________ ________ ___ ________ ___ _________
9 | |\ ____\|\ __ \ |\ \ / /|\ __ \|\___ ___\\ __ \|\ ____\|\ __ \|\ \ |\ __ \|\ \|\___ ___\
10 | \ \ \___|\ \ \|\ \ \ \ \/ / | \ \|\ \|___ \ \_\ \ \|\ \ \ \___|\ \ \|\ \ \ \ \ \ \|\ \ \ \|___ \ \_|
11 | \ \ \ \ \ _ _\ \ \ / / \ \ ____\ \ \ \ \ \ \\\ \ \_____ \ \ ____\ \ \ \ \ \\\ \ \ \ \ \ \
12 | \ \ \____\ \ \\ \| \/ / / \ \ \___| \ \ \ \ \ \\\ \|____|\ \ \ \___|\ \ \____\ \ \\\ \ \ \ \ \ \
13 | \ \_______\ \__\\ _\ __/ / / \ \__\ \ \__\ \ \_______\____\_\ \ \__\ \ \_______\ \_______\ \__\ \ \__\
14 | \|_______|\|__|\|__|\___/ / \|__| \|__| \|_______|\_________\|__| \|_______|\|_______|\|__| \|__|
15 | \|___|/ \|_________|
16 |
17 | """,
18 | r"""
19 | /$$$$$$ /$$$$$$$ /$$ /$$ /$$$$$$$ /$$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$ /$$$$$$ /$$$$$$ /$$$$$$$$
20 | /$$__ $$| $$__ $$| $$ /$$/| $$__ $$|__ $$__//$$__ $$ /$$__ $$| $$__ $$| $$ /$$__ $$|_ $$_/|__ $$__/
21 | | $$ \__/| $$ \ $$ \ $$ /$$/ | $$ \ $$ | $$ | $$ \ $$| $$ \__/| $$ \ $$| $$ | $$ \ $$ | $$ | $$
22 | | $$ | $$$$$$$/ \ $$$$/ | $$$$$$$/ | $$ | $$ | $$| $$$$$$ | $$$$$$$/| $$ | $$ | $$ | $$ | $$
23 | | $$ | $$__ $$ \ $$/ | $$____/ | $$ | $$ | $$ \____ $$| $$____/ | $$ | $$ | $$ | $$ | $$
24 | | $$ $$| $$ \ $$ | $$ | $$ | $$ | $$ | $$ /$$ \ $$| $$ | $$ | $$ | $$ | $$ | $$
25 | | $$$$$$/| $$ | $$ | $$ | $$ | $$ | $$$$$$/| $$$$$$/| $$ | $$$$$$$$| $$$$$$/ /$$$$$$ | $$
26 | \______/ |__/ |__/ |__/ |__/ |__/ \______/ \______/ |__/ |________/ \______/ |______/ |__/
27 |
28 | """,
29 | r"""
30 | _,.----. _ __ ,--.--------. _,.---._ ,-,--. _ __ _,.---._ .=-.-.,--.--------.
31 | .' .' - \ .-.,.---. ,--.-. .-,--.-`.' ,`./==/, - , -\,-.' , - `. ,-.'- _\ .-`.' ,`. _.-. ,-.' , - `. /==/_ /==/, - , -\
32 | /==/ , ,-' /==/ ` \/==/- / /=/_ /==/, - \==\.-. - ,-./==/_, , - \/==/_ ,_.'/==/, - \.-,.'| /==/_, , - \|==|, |\==\.-. - ,-./
33 | |==|- | .|==|-, .=., \==\, \/=/. /==| _ .=. |`--`\==\- \ |==| .=. \==\ \ |==| _ .=. |==|, | |==| .=. |==| | `--`\==\- \
34 | |==|_ `-' \==| '=' /\==\ \/ -/|==| , '=',| \==\_ \|==|_ : ;=: - |\==\ -\ |==| , '=',|==|- | |==|_ : ;=: - |==|- | \==\_ \
35 | |==| _ , |==|- , .' |==| ,_/ |==|- '..' |==|- ||==| , '=' |_\==\ ,\|==|- '..'|==|, | |==| , '=' |==| ,| |==|- |
36 | \==\. /==|_ . ,'. \==\-, / |==|, | |==|, | \==\ - ,_ //==/\/ _ |==|, | |==|- `-._\==\ - ,_ /|==|- | |==|, |
37 | `-.`.___.-'/==/ /\ , ) /==/._/ /==/ - | /==/ -/ '.='. - .' \==\ - , /==/ - | /==/ - , ,/'.='. - .' /==/. / /==/ -/
38 | `--`-`--`--' `--`-` `--`---' `--`--` `--`--'' `--`---'`--`---' `--`-----' `--`--'' `--`-` `--`--`
39 |
40 | """,
41 | r"""
42 | _____ ________ _______ _____ _____ ___________ _ _____ _____ _____
43 | / __ \| ___ \ \ / / ___ \_ _| _ / ___| ___ \ | | _ |_ _|_ _|
44 | | / \/| |_/ /\ V /| |_/ / | | | | | \ `--.| |_/ / | | | | | | | | |
45 | | | | / \ / | __/ | | | | | |`--. \ __/| | | | | | | | | |
46 | | \__/\| |\ \ | | | | | | \ \_/ /\__/ / | | |___\ \_/ /_| |_ | |
47 | \____/\_| \_| \_/ \_| \_/ \___/\____/\_| \_____/\___/ \___/ \_/
48 |
49 | """,
50 | r"""
51 | ..|'''.| '||''|. '||' '|' '||''|. |''||''| ..|''|| .|'''.| '||''|. '||' ..|''|| '||' |''||''|
52 | .|' ' || || || | || || || .|' || ||.. ' || || || .|' || || ||
53 | || ||''|' || ||...|' || || || ''|||. ||...|' || || || || ||
54 | '|. . || |. || || || '|. || . '|| || || '|. || || ||
55 | ''|....' .||. '|' .||. .||. .||. ''|...|' |'....|' .||. .||.....| ''|...|' .||. .||.
56 |
57 | """,
58 | r"""
59 | # # #### #### ##### ##### ### #### ##### ##### ### # # #####
60 | # # # # # # # # # # # # # # # # # # # ## #
61 | #### #### #### # # # # # # # # # # # # # # # #
62 | # # # # # # # # # # # # # # # # ## # #
63 | # # # # # # # ### #### # # # # ### # # #
64 |
65 | """
66 | ]
67 |
68 |
69 | def print_banner():
70 | print(colorize_strings(choice(BANNERS), fg=SGR.COLOR.FOREGROUND.GREEN))
71 |
--------------------------------------------------------------------------------
/src/cryptosploit/console.py:
--------------------------------------------------------------------------------
1 | import re
2 | import os
3 |
4 | from cmd import Cmd
5 | from importlib import import_module
6 | from importlib.util import find_spec
7 | from subprocess import Popen, PIPE
8 | from sys import path
9 | from pkgutil import walk_packages, get_loader
10 |
11 | from .banners import print_banner
12 | from .cprint import colorize_strings, SGR, Printer
13 | from .exceptions import (
14 | ArgError,
15 | CryptoException,
16 | PathError,
17 | ModuleError,
18 | UnknownCommandError,
19 | )
20 |
21 |
22 | class CRSConsole(Cmd):
23 | """
24 | Class of main console
25 | """
26 |
27 | prompt = "crsconsole> "
28 | intro = (
29 | "Wellcome to CryptoSploit "
30 | + colorize_strings("<3", fg=SGR.COLOR.FOREGROUND.RED)
31 | + "\nType "
32 | + colorize_strings("help", fg=SGR.COLOR.FOREGROUND.GREEN)
33 | + " or "
34 | + colorize_strings("?", fg=SGR.COLOR.FOREGROUND.GREEN)
35 | + " to list commands.\n"
36 | )
37 |
38 | module = None
39 | modules_list = None
40 | variables = None
41 | shell_proc: Popen | None = None
42 |
43 | def __load_modules(self):
44 | csmodule = get_loader("cryptosploit_modules")
45 | self.modules_list = []
46 | for ff, name, ispkg in walk_packages([os.path.dirname(csmodule.path)], csmodule.name + "."):
47 | if ispkg:
48 | path[4] = os.path.join(ff.path, name.rsplit(".", 1)[-1], "site-packages/")
49 | if hasattr(import_module(name), "module"):
50 | self.modules_list.append(name.split(".", 1)[1])
51 | path[4] = ""
52 |
53 | def preloop(self):
54 | path.insert(4, "")
55 | self.__load_modules()
56 | print_banner()
57 |
58 | def precmd(self, line: str) -> str:
59 | if line == "EOF":
60 | print()
61 | return ""
62 | return line
63 |
64 | def onecmd(self, line: str) -> bool:
65 | try:
66 | return super().onecmd(line)
67 | except CryptoException as err:
68 | Printer.error(str(err))
69 | return False
70 | except KeyboardInterrupt:
71 | print()
72 | if self.module:
73 | self.module.kill_proc()
74 | if self.shell_proc:
75 | self.shell_proc.terminate()
76 | self.shell_proc.kill()
77 | self.shell_proc = None
78 |
79 | def default(self, line: str) -> bool:
80 | self.do_shell(line)
81 | return False
82 |
83 | def emptyline(self) -> bool:
84 | return False
85 |
86 | def do_shell(self, arg):
87 | """
88 | Any shell command.
89 | Example: ls -la
90 | """
91 | self.shell_proc = Popen(
92 | arg,
93 | shell=True,
94 | stdin=self.stdin,
95 | stdout=self.stdout,
96 | stderr=self.stdout,
97 | universal_newlines=True,
98 | )
99 | Printer.exec(f"Executing '{arg}'")
100 | self.shell_proc.wait()
101 | print()
102 | return False
103 |
104 | def do_use(self, module_path: str):
105 | """
106 | Load module
107 | Example: use symmetric.rot
108 | """
109 | Printer.info("Loading module...")
110 | try:
111 | module_obj = import_module("cryptosploit_modules." + module_path)
112 | packages_path = os.path.join(module_obj.__path__[0], "site-packages")
113 | if os.path.isdir(packages_path):
114 | path[4] = packages_path
115 | self.module = module_obj.module()
116 | except (ModuleNotFoundError, TypeError) as err:
117 | raise ModuleError("No such module") from err
118 | except AttributeError as err:
119 | raise ModuleError("Not a module") from err
120 | else:
121 | self.variables = self.module.env
122 | self.prompt = f"crsconsole ({colorize_strings(f'{module_path}', fg=SGR.COLOR.FOREGROUND.PURPLE)})> "
123 | Printer.info("Module loaded successfully")
124 | return False
125 |
126 | def do_search(self, name):
127 | """
128 | Search modules by keyword.
129 | Example: search rot
130 | """
131 | pattern = f".*{name}.*"
132 | try:
133 | r = re.compile(pattern)
134 | except re.error as err:
135 | raise ArgError("Invalid regex") from err
136 | else:
137 | found = list(filter(r.match, self.modules_list))
138 | if found:
139 | Printer.info("Founded:\n", "\n".join(found), sep="")
140 | else:
141 | Printer.negative(f"No results for {name}")
142 | return False
143 |
144 | def do_exit(self, arg=""):
145 | """
146 | Just an exit command.
147 | Just type exit.
148 | """
149 | print("Bye bye! UwU")
150 | return True
151 |
152 | def do_run(self, arg):
153 | """
154 | Run loaded module.
155 | Just type run.
156 | """
157 | self.module.run()
158 | return False
159 |
160 | def do_set(self, arg):
161 | """
162 | Set the value of a variable.
163 | Example: set ciphertext OwO
164 | """
165 | arg = arg.split(maxsplit=1)
166 | if len(arg) == 2:
167 | name, value = arg
168 | if self.variables:
169 | if name in self.variables:
170 | self.variables.set_var(name, value)
171 | Printer.info(f"Setting {name} -> {value}")
172 | return False
173 | raise ArgError("No such variable")
174 | raise ModuleError("Module is not loaded")
175 | raise ArgError("Value is not set")
176 |
177 | def do_unset(self, name):
178 | """
179 | Unset the value of a variable.
180 | Example: unset ciphertext
181 | """
182 | if self.variables:
183 | if name in self.variables:
184 | self.variables.set_var(name, "")
185 | Printer.info(f"Setting {name} -> None")
186 | return False
187 | raise ArgError("No such variable")
188 | raise ModuleError("Module is not loaded")
189 |
190 | def do_get(self, arg):
191 | """
192 | Print variables allowed to set.
193 | Just type get.
194 | """
195 | if self.variables:
196 | print(self.variables)
197 | return False
198 | raise ModuleError("Module is not loaded")
199 |
200 | def do_cd(self, new_path: str):
201 | """
202 | Wrapper over change directory command.
203 | Use like cd.
204 | """
205 | Printer.exec(f"Executing cd {new_path}")
206 | cwd = os.path.abspath(new_path)
207 | if os.path.exists(cwd):
208 | os.chdir(cwd)
209 | else:
210 | raise PathError("No such directory")
211 | return False
212 |
213 | def completedefault(self, text, line, begidx, endidx):
214 | return self.explore_paths(line, False)
215 |
216 | def complete_cd(self, text, line, begidx, endidx):
217 | return self.explore_paths(line, True)
218 |
219 | @staticmethod
220 | def explore_paths(line, only_dirs):
221 | text = (line.split(" "))[-1]
222 | if text in ("..", "."):
223 | return (
224 | [os.path.join(".", ""), os.path.join("..", "")]
225 | if text == "."
226 | else [os.path.join("..", "")]
227 | )
228 | if only_dirs:
229 | paths = filter(
230 | lambda x: os.path.isdir(os.path.join(os.path.dirname(text), x)),
231 | os.listdir(os.path.dirname(text) or "."),
232 | )
233 | else:
234 | paths = os.listdir(os.path.dirname(text) or ".")
235 | founded = list(
236 | map(
237 | lambda a: os.path.join(a, "") if os.path.isdir(a) else a,
238 | filter(lambda x: x.startswith(os.path.split(text)[-1]), paths),
239 | )
240 | )
241 | return founded
242 |
243 | def complete_use(self, text, line, begidx, endidx):
244 | return self.complete_search(text, line, begidx, endidx)
245 |
246 | def complete_search(self, text, line, begidx, endidx):
247 | founded = list(
248 | filter(
249 | lambda x: x.startswith(text) and len(x.split(".")) > 1,
250 | self.modules_list,
251 | )
252 | )
253 | return founded
254 |
255 | def complete_set(self, text, line, begidx, endidx):
256 | if " " not in line[:begidx].strip():
257 | founded = []
258 | if self.variables:
259 | for varname in iter(self.variables):
260 | if varname.startswith(text):
261 | founded.append(varname)
262 | return founded
263 | else:
264 | return self.explore_paths(line, False)
265 |
266 | def complete_unset(self, text, line, begidx, endidx):
267 | return self.complete_set(text, line, begidx, endidx)
268 |
--------------------------------------------------------------------------------
/src/cryptosploit/cprint.py:
--------------------------------------------------------------------------------
1 | class SGR:
2 | """Styling class with constants."""
3 | TEMPLATE = "\x1b[{}m"
4 | CLEAR = TEMPLATE.format("0")
5 |
6 | @staticmethod
7 | def format(s):
8 | return SGR.TEMPLATE.format(s)
9 |
10 | class STYLES:
11 | NORMAL = "0"
12 | BOLD = "1"
13 | LIGHT = "2"
14 | ITALIC = "3"
15 | UNDERLINE = "4"
16 | BLINK = "5"
17 |
18 | class COLOR:
19 | class FOREGROUND:
20 | BLACK = "30"
21 | RED = "31"
22 | GREEN = "32"
23 | YELLOW = "33"
24 | BLUE = "34"
25 | PURPLE = "35"
26 | CYAN = "36"
27 | WHITE = "37"
28 |
29 | class BACKGROUND:
30 | BLACK = "40"
31 | RED = "41"
32 | GREEN = "42"
33 | YELLOW = "43"
34 | BLUE = "44"
35 | PURPLE = "45"
36 | CYAN = "46"
37 | WHITE = "47"
38 |
39 |
40 | def colorize_strings(*strings, styles=[], fg="", bg="", sep=" "):
41 | """
42 | With colorize_strings you can change
43 | strings style, color (fg), color of background (bg).
44 | Use SGR class for styling.
45 | """
46 | template = ""
47 | if styles:
48 | template += SGR.format(";".join(styles))
49 | if fg:
50 | template += SGR.format(fg)
51 | if bg:
52 | template += SGR.format(bg)
53 | template += "{}" + SGR.CLEAR
54 | return template.format(sep.join(map(template.format, strings)))
55 |
56 |
57 | class Printer:
58 | """
59 | Class for printing of any information.
60 | Use it to colorize the output of your module.
61 | """
62 | @staticmethod
63 | def info(*strings, sep=" "):
64 | """Print cyan string with '[>]' prefix."""
65 | prefix = colorize_strings("[>]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.CYAN)
66 | print(prefix)
67 |
68 | @staticmethod
69 | def error(*strings, sep=" "):
70 | """Print red string with '[!]' prefix."""
71 | s = colorize_strings(
72 | colorize_strings("[!]", styles=[SGR.STYLES.BLINK]),
73 | sep.join(strings),
74 | fg=SGR.COLOR.FOREGROUND.RED,
75 | )
76 | print(s)
77 |
78 | @staticmethod
79 | def exec(*strings, sep=" "):
80 | """Print yellow string with '[*]' prefix."""
81 | prefix = colorize_strings("[*]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.YELLOW)
82 | print(prefix)
83 |
84 | @staticmethod
85 | def positive(*strings, sep=" "):
86 | """Print green string with '[+]' prefix."""
87 | prefix = colorize_strings("[+]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.GREEN)
88 | print(prefix)
89 |
90 | @staticmethod
91 | def negative(*strings, sep=" "):
92 | """Print red string with '[-]' prefix."""
93 | prefix = colorize_strings("[-]", sep.join(strings), fg=SGR.COLOR.FOREGROUND.RED)
94 | print(prefix)
95 |
--------------------------------------------------------------------------------
/src/cryptosploit/exceptions.py:
--------------------------------------------------------------------------------
1 | class CryptoException(Exception):
2 | """Base application exception."""
3 |
4 |
5 | class ArgError(CryptoException):
6 | """Exception raised for errors in the input command."""
7 |
8 |
9 | class PathError(CryptoException):
10 | """Exception raised for errors in os paths."""
11 |
12 |
13 | class ModuleError(CryptoException):
14 | """Exception raised for errors in modules."""
15 |
16 |
17 | class UnknownCommandError(CryptoException):
18 | """Exception raised for unknown commands."""
19 |
--------------------------------------------------------------------------------