cryptosploit_modules.templates.ExampleBinaryModuleName

Template for other programming languages. 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 other programming languages.
 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 ExampleBinaryModuleName(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 run(self):
26        """
27        A function that is called when the user
28        uses the run command
29        """
30        key = self.env.get_var("key").value
31        ciphertext = self.env.get_var("ciphertext").value
32        if key and ciphertext:
33            return self.command_exec(f"your_binary -k {key} -ct {ciphertext}")
34        return Printer.error("All paramaters must be set")
35
36
37module = ExampleBinaryModuleName()
#   class ExampleBinaryModuleName(cryptosploit_modules.BaseModule):
View Source
10class ExampleBinaryModuleName(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 run(self):
27        """
28        A function that is called when the user
29        uses the run command
30        """
31        key = self.env.get_var("key").value
32        ciphertext = self.env.get_var("ciphertext").value
33        if key and ciphertext:
34            return self.command_exec(f"your_binary -k {key} -ct {ciphertext}")
35        return Printer.error("All paramaters must be set")
#   ExampleBinaryModuleName()
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 run(self):
View Source
26    def run(self):
27        """
28        A function that is called when the user
29        uses the run command
30        """
31        key = self.env.get_var("key").value
32        ciphertext = self.env.get_var("ciphertext").value
33        if key and ciphertext:
34            return self.command_exec(f"your_binary -k {key} -ct {ciphertext}")
35        return Printer.error("All paramaters must be set")

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