cryptosploit_modules.templates.ExamplePythonModuleName

Template for python modules To check full module directory structure (config.json, do_install.sh) visit our github: https://github.com/y73n0k/cryptosploit_modules

View Source
 0"""
 1Template for python modules
 2To check full module directory structure (config.json, do_install.sh)
 3visit our github: https://github.com/y73n0k/cryptosploit_modules
 4"""
 5
 6from cryptosploit.cprint import Printer
 7from cryptosploit_modules import BaseModule
 8
 9class ExamplePythonModuleName(BaseModule):
10    def __init__(self):
11        super().__init__()
12        self.env.check_var = self.check_var
13
14    @staticmethod
15    def check_var(name, value):
16        """Must return isvalid_variable: bool, error_msg: str"""
17        match name:
18            case "key":
19                if value.isdigit():
20                    return True, ""
21                return False, "Must be a digit"
22            case _:
23                return True, ""
24
25    def encrypt_command(self):
26       """Encrypt function"""
27
28    def decrypt_command(self):
29       """Decrypt function"""
30
31    def attack_command(self):
32       """Attack cipher function"""
33
34    def run(self):
35        """
36        A function that is called when the user
37        uses the run command
38        """
39        func = getattr(self, self.env.get_var("mode").value + "_command")
40        return func()
41
42
43module = ExamplePythonModuleName()
#   class ExamplePythonModuleName(cryptosploit_modules.BaseModule):
View Source
10class ExamplePythonModuleName(BaseModule):
11    def __init__(self):
12        super().__init__()
13        self.env.check_var = self.check_var
14
15    @staticmethod
16    def check_var(name, value):
17        """Must return isvalid_variable: bool, error_msg: str"""
18        match name:
19            case "key":
20                if value.isdigit():
21                    return True, ""
22                return False, "Must be a digit"
23            case _:
24                return True, ""
25
26    def encrypt_command(self):
27       """Encrypt function"""
28
29    def decrypt_command(self):
30       """Decrypt function"""
31
32    def attack_command(self):
33       """Attack cipher function"""
34
35    def run(self):
36        """
37        A function that is called when the user
38        uses the run command
39        """
40        func = getattr(self, self.env.get_var("mode").value + "_command")
41        return func()
#   ExamplePythonModuleName()
View Source
11    def __init__(self):
12        super().__init__()
13        self.env.check_var = self.check_var
#  
@staticmethod
def check_var(name, value):
View Source
15    @staticmethod
16    def check_var(name, value):
17        """Must return isvalid_variable: bool, error_msg: str"""
18        match name:
19            case "key":
20                if value.isdigit():
21                    return True, ""
22                return False, "Must be a digit"
23            case _:
24                return True, ""

Must return isvalid_variable: bool, error_msg: str

#   def encrypt_command(self):
View Source
26    def encrypt_command(self):
27       """Encrypt function"""

Encrypt function

#   def decrypt_command(self):
View Source
29    def decrypt_command(self):
30       """Decrypt function"""

Decrypt function

#   def attack_command(self):
View Source
32    def attack_command(self):
33       """Attack cipher function"""

Attack cipher function

#   def run(self):
View Source
35    def run(self):
36        """
37        A function that is called when the user
38        uses the run command
39        """
40        func = getattr(self, self.env.get_var("mode").value + "_command")
41        return func()

A function that is called when the user uses the run command