diff --git a/CHANGELOG b/CHANGELOG index a7ab1f4..61e2e14 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,11 @@ +[2020-04-22] + Released.: 3.1.14 + Modified.: Fix for #351, it was just superficial and never stopped the tool from running, but changes "is not" to != + +[2020-03-25] + Released.: 3.1.13 + Modified.: Imports now use new version of imports, and updated setup script (both were pull requests) + [2019-06-17] Released.: 3.1.12 Fixed....: Pyherion including tabs in imports could cause syntax errors, tabs are now stripped only for imports diff --git a/README.md b/README.md index e84a3b0..4232f16 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ The following OSs are officially supported: The following OSs are likely able to run Veil: - Arch Linux +- Manjaro Linux - BlackArch Linux - Deepin 15+ - Elementary diff --git a/Veil.py b/Veil.py index 57e44c6..cf4cc02 100755 --- a/Veil.py +++ b/Veil.py @@ -12,6 +12,8 @@ if __name__ == "__main__": + import os + os.chdir(os.path.dirname(os.path.realpath(__file__))) parser = argparse.ArgumentParser( add_help=False, description="Veil is a framework containing multiple\ diff --git a/config/setup.sh b/config/setup.sh index 3195a61..9a10f75 100755 --- a/config/setup.sh +++ b/config/setup.sh @@ -5,6 +5,7 @@ os="$( awk -F '=' '/^ID=/ {print $2}' /etc/os-release 2>&- )" if [ "${os}" == "arch" ] \ +|| [ "${os}" == "manjaro" ]\ || [ "${os}" == "blackarch" ] \ || [ "${os}" == "debian" ] \ || [ "${os}" == "deepin" ] \ @@ -32,16 +33,24 @@ fi userprimarygroup="$( id -Gn "${trueuser}" | cut -d' ' -f1 )" arch="$( uname -m )" -if [ "${os}" == "\"void\"" ]; then + +if [ "${os}" == "manjaro" ]; then + osversion="$(uname -r)" +elif [ "${os}" == "\"void\"" ]; then osversion="$(uname -r)" else osversion="$( awk -F '=' '/^VERSION_ID=/ {print $2}' /etc/os-release 2>&- | sed 's/"//g' )" fi -if [ "${os}" == "\"void\"" ]; then + +if [ "${os}" == "manjaro" ]; then + osmajversion="$(uname -a | cut -f3 -d\ | cut -f-2 -d.)" +elif [ "${os}" == "\"void\"" ]; then osmajversion="$(uname -a | cut -f3 -d\ | cut -f-2 -d.)" else - osmajversion="$( awk -F '["=]' '/^VERSION_ID=/ {print $3}' /etc/os-release 2>&- | cut -d'.' -f1 )" + osmajversion="$( awk -F '["=]' '/^VERSION_ID=/ {print $3}' /etc/os-release 2>&- | cut -d'.' -f1 )" fi + + veildir="/var/lib/veil" outputdir="${veildir}/output" dependenciesdir="${veildir}/setup-dependencies" @@ -386,7 +395,8 @@ func_package_deps(){ echo -e " ${RED}[ERROR] ${msg}${RESET}\n" fi - elif [ "${os}" == "arch" ]; then + elif [ "${os}" == "arch" ] \ + || [ "${os}" == "manjaro" ]; then AUR_packages() { if [ $1 == 'yay' ]; then @@ -589,6 +599,7 @@ func_package_deps(){ echo -e " ${RED}[ERROR] ${msg}${RESET}\n" fi elif [ "${os}" == "arch" ] \ + || [ "${os}" == "blackarch" ] \ || [ "${os}" == "blackarch" ]; then echo -e "\n\n [*] ${YELLOW}Installing Wine 32-bit on x86_64 System (via PACMAN)${RESET}\n" if grep -Fxq "#[multilib]" /etc/pacman.conf; then @@ -784,7 +795,7 @@ func_python_deps(){ ## Use wine based pip to install dependencies echo -e "\n\n [*] ${YELLOW}Installing (Wine) Python's PIP pefile${RESET}\n" - sudo -u "${trueuser}" WINEPREFIX="${winedir}" wine "${winedir}/drive_c/Python34/python.exe" "-m" "pip" "install" "--upgrade" "pip" + sudo -u "${trueuser}" WINEPREFIX="${winedir}" wine "${winedir}/drive_c/Python34/python.exe" "-m" "pip" "install" "--upgrade" "pip==19.1.*" tmp="$?" if [[ "${tmp}" -ne "0" ]]; then msg="Failed to run (wine) Python pip... Exit code: ${tmp}" @@ -1038,6 +1049,8 @@ else echo -e " [I] ${YELLOW}Arch Linux ${arch} detected...${RESET}\n" elif [ "${os}" == "blackarch" ]; then echo -e " [I] ${YELLOW}BlackArch Linux ${arch} detected...${RESET}\n" + elif [ "${os}" == "manjaro" ]; then + echo -e " [I] ${YELLOW}Manjaro Linux ${arch} detected...${RESET}\n" elif [ "${os}" == "debian" ]; then echo -e " [!] ${YELLOW}Debian Linux sid/TESTING ${arch} *possibly* detected..." echo -e " If you are not currently running Debian Testing, you should exit this installer!${RESET}\n" diff --git a/lib/common/completer.py b/lib/common/completer.py index bc7caa7..65db347 100644 --- a/lib/common/completer.py +++ b/lib/common/completer.py @@ -97,7 +97,7 @@ def complete_info(self, args): parts = name.split("/") # iterate down the split parts so we can handle the nested payload structure - for x in xrange(len(parts)): + for x in range(len(parts)): # if the first part of the iterated payload matches the language, append it if parts[x] == lang: diff --git a/lib/common/helpers.py b/lib/common/helpers.py index 02b2f07..7bb3415 100644 --- a/lib/common/helpers.py +++ b/lib/common/helpers.py @@ -8,6 +8,7 @@ import re import string import sys +import importlib.util # Try to find and import the settings.py config file @@ -160,3 +161,13 @@ def validate_port(port_number): return False except ValueError: return False + + +def load_module(module_path): + """ + Takes module path, return module object + """ + spec = importlib.util.spec_from_file_location(module_path, module_path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + return module diff --git a/lib/common/messages.py b/lib/common/messages.py index 10f6527..4ac5174 100644 --- a/lib/common/messages.py +++ b/lib/common/messages.py @@ -15,7 +15,7 @@ sys.exit() # Current version of Veil -veil_version = "3.1.12" +veil_version = "3.1.14" def title_screen(): diff --git a/lib/common/orchestra.py b/lib/common/orchestra.py index 04aa2c7..6fdd106 100644 --- a/lib/common/orchestra.py +++ b/lib/common/orchestra.py @@ -3,7 +3,6 @@ """ import glob -import imp import os import readline import sys @@ -72,9 +71,8 @@ def load_tools(self, command_line_object): # (Evasion, Ordnance, Pillage, etc.) for name in glob.glob('tools/*/tool.py'): if name.endswith(".py") and ("__init__" not in name): - loaded_tool = imp.load_source( - name.replace("/", ".").rstrip('.py'), name) - self.imported_tools[name] = loaded_tool.Tools( + module = helpers.load_module(name) + self.imported_tools[name] = module.Tools( command_line_object) return diff --git a/tools/evasion/evasion_common/outfile.py b/tools/evasion/evasion_common/outfile.py index c82788d..c1c2f3b 100644 --- a/tools/evasion/evasion_common/outfile.py +++ b/tools/evasion/evasion_common/outfile.py @@ -49,7 +49,7 @@ def compiler(payload_object, invoked=False, cli_object=None): # Used when outputting exe files, go figure executable_filepath = settings.PAYLOAD_COMPILED_PATH + file_name + ".exe" - if payload_object.language is not "native" and payload_object.extension is not "war": + if payload_object.language != "native" and payload_object.extension != "war": with open(source_code_filepath, 'w') as source_file: source_file.write(payload_object.payload_source_code) diff --git a/tools/evasion/evasion_common/shellcode_help.py b/tools/evasion/evasion_common/shellcode_help.py index 16bf1f6..e7548d8 100644 --- a/tools/evasion/evasion_common/shellcode_help.py +++ b/tools/evasion/evasion_common/shellcode_help.py @@ -457,7 +457,7 @@ def menu(self): if selection != '': num_extra_options = selection.split(' ') for xtra_opt in num_extra_options: - if xtra_opt is not '': + if xtra_opt != '': if "=" not in xtra_opt: print(helpers.color(" [!] Parameter not entered in correct syntax.\n", warning=True)) continue @@ -547,7 +547,7 @@ def cli_msf_shellcode_gen(command_line_args): if command_line_args.msfoptions is not None: num_extra_options = command_line_args.msfoptions.split(' ') for xtra_opt in num_extra_options: - if xtra_opt is not '': + if xtra_opt != '': if "=" not in xtra_opt: print(helpers.color(" [!] Parameter not entered in correct syntax.\n", warning=True)) sys.exit() diff --git a/tools/evasion/tool.py b/tools/evasion/tool.py index 90a5b88..e85c4a9 100644 --- a/tools/evasion/tool.py +++ b/tools/evasion/tool.py @@ -3,7 +3,6 @@ """ import glob -import imp import os import readline import subprocess @@ -192,7 +191,7 @@ def cli_menu(self, invoked=False): # -c if self.command_options.c is not None: for payload_option in self.command_options.c: - if payload_option is not '': + if payload_option != '': if "=" not in payload_option: print(helpers.color(" [!] Payload option not entered in correct syntax.\n", warning=True)) sys.exit() @@ -246,9 +245,8 @@ def load_payloads(self, cli_args): for x in range(1, 5): for name in glob.glob(join("tools/evasion/payloads/" + "*/" * x,'[!_]*.py')): if name.endswith(".py") and ("__init__" not in name): - loaded_payloads = imp.load_source( - name.replace("/", ".").rstrip('.py'), name) - self.active_payloads[name.replace('tools/evasion/payloads/', '')] = loaded_payloads.PayloadModule(cli_args) + module = helpers.load_module(name) + self.active_payloads[name.replace('tools/evasion/payloads/', '')] = module.PayloadModule(cli_args) return def print_options_screen(self, pload_object): @@ -285,18 +283,18 @@ def payload_info(self, payload_obj, showTitle=True, showInfo=True): def return_payload_object(self, user_selection): # This function handles returning the selected payload module object # to the calling function - counter_value = 1 - for payload_path, payload_module in sorted(self.active_payloads.items()): - if user_selection.isdigit() and (0 < int(user_selection) <= len(self.active_payloads)): - if int(user_selection) == counter_value: - return payload_module - else: - if user_selection.strip().lower() == payload_path: - return payload_module - # Iterate counter for number based selection - counter_value += 1 - return False + payloads = sorted(self.active_payloads.items()) + payload_by_path = [payload for payload in payloads if payload[0] == user_selection.strip().lower()] + + if user_selection.isdigit() and (0 < int(user_selection) <= len(self.active_payloads)): + # minus 1 because menu starts counting at 1 not 0 + user_selection = int(user_selection) - 1 + return payloads[user_selection][1] + elif payload_by_path: + return payload_by_path[0][1] + else: + return False def tool_main_menu(self): # This is the main function where everything is called from @@ -417,7 +415,7 @@ def use_payload(self, selected_payload): key = key.upper() if key in selected_payload.required_options: # Validate LHOST value - if key is "LHOST": + if key == "LHOST": if helpers.validate_ip(value): selected_payload.required_options[key][0] = value else: @@ -425,7 +423,7 @@ def use_payload(self, selected_payload): print(helpers.color(" [!] ERROR: You did not provide a valid IP!", warning=True)) print() # Validate LPORT - elif key is "LPORT": + elif key == "LPORT": if helpers.validate_port(value): selected_payload.required_options[key][0] = value else: diff --git a/tools/ordnance/tool.py b/tools/ordnance/tool.py index 4944cdd..a0af2d8 100644 --- a/tools/ordnance/tool.py +++ b/tools/ordnance/tool.py @@ -3,7 +3,6 @@ """ import glob -import imp import readline import sys from lib.common import helpers @@ -99,7 +98,7 @@ def cli_menu(self, invoked=False): payload.cli_gen_shellcode() self.final_shellcode = payload.customized_shellcode # Check if an encoder is being called by the user - if self.command_options.encoder is not None: + if self.command_options.encoder != None: encoder_found_here = False if "BadChars" in payload.required_options: payload.required_options["BadChars"][0] = self.command_options.bad_chars @@ -121,17 +120,15 @@ def cli_menu(self, invoked=False): def load_encoders(self, cli_args): for name in sorted( glob.glob('tools/ordnance/encoders/*.py') ): if name.endswith(".py") and ("__init__" not in name): - loaded_encoder = imp.load_source( - name.replace("/", ".").rstrip('.py'), name) - self.active_encoders[name] = loaded_encoder.EncoderModule(cli_args) + module = helpers.load_module(name) + self.active_encoders[name] = module.EncoderModule(cli_args) return def load_payloads(self, cli_args): for name in sorted( glob.glob('tools/ordnance/payloads/x86/*.py') ): if name.endswith(".py") and ("__init__" not in name): - loaded_payloads = imp.load_source( - name.replace("/", ".").rstrip('.py'), name) - self.active_shellcode[name] = loaded_payloads.ShellcodeModule(cli_args) + module = helpers.load_module(name) + self.active_shellcode[name] = module.ShellcodeModule(cli_args) return def print_encoders(self): @@ -379,7 +376,7 @@ def use_payload(self, payload): self.payload_options['RHOST'] = rhost_out # Check if encoder is needed - if payload.required_options["Encoder"][0] is not "None": + if payload.required_options["Encoder"][0] != "None": self.use_encoder(payload) self.final_shellcode = payload.customized_shellcode