Skip to content

Commit

Permalink
Gave the CLI command line some love. Much more verbose/user friendly
Browse files Browse the repository at this point in the history
  • Loading branch information
g0tmi1k committed Apr 16, 2018
1 parent 8915e56 commit 1ece1d0
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 65 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ usage: Veil.py [--list-tools] [-t TOOL] [--update] [--setup] [--config]
[-p [PAYLOAD]] [-o OUTPUT-NAME]
[-c [OPTION=value [OPTION=value ...]]]
[--msfoptions [OPTION=value [OPTION=value ...]]] [--msfvenom ]
[--compiler pyinstaller] [--clean] [--ordnance-payload rev_tcp]
[--list-encoders] [-e ENCODER] [-b \\x00\\x0a..]
[--compiler pyinstaller] [--clean] [--ordnance-payload [PAYLOAD]]
[--list-encoders] [-e ENCODER] [-b \x00\x0a..]
[--print-stats]

Veil is a framework containing multiple tools.
Expand Down Expand Up @@ -166,14 +166,14 @@ Veil is a framework containing multiple tools.
--clean Clean out payload folders
[*] Veil-Ordnance Shellcode Options:
--ordnance-payload rev_tcp
--ordnance-payload [PAYLOAD]
Payload type (bind_tcp, rev_tcp, etc.)
[*] Veil-Ordnance Encoder Options:
--list-encoders Lists all available encoders
-e ENCODER, --encoder ENCODER
Name of shellcode encoder to use
-b \\x00\\x0a.., --bad-chars \\x00\\x0a..
-b \\x00\\x0a.., --bad-chars \x00\x0a..
Bad characters to avoid
--print-stats Print information about the encoded shellcode
$
Expand Down
10 changes: 9 additions & 1 deletion Veil.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@

ordnance_shellcode = parser.add_argument_group('[*] Veil-Ordnance Shellcode Options')
ordnance_shellcode.add_argument(
"--ordnance-payload", metavar="rev_tcp", default=None,
"--ordnance-payload", metavar="PAYLOAD", default=None,
help='Payload type (bind_tcp, rev_tcp, etc.)')

ordnance_encoder = parser.add_argument_group('[*] Veil-Ordnance Encoder Options')
Expand All @@ -95,34 +95,42 @@

the_conductor = orchestra.Conductor(args)

# --help
if args.h:
parser.print_help()
sys.exit()

# --version
if args.version:
messages.title_screen()
sys.exit()

# --update
if args.update:
the_conductor.update_veil()
sys.exit()

# --setup
if args.setup:
the_conductor.setup_veil()
sys.exit()

# --config
if args.config:
the_conductor.config_veil()
sys.exit()

# --list-tools
if args.list_tools:
the_conductor.list_tools()
sys.exit()

# --clean
if args.clean:
helpers.clean_payloads()
sys.exit()

# Anything else that isn't defined
if not args.tool:
the_conductor.main_menu()
sys.exit()
Expand Down
11 changes: 4 additions & 7 deletions config/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ RESET="\033[00m" # Normal
func_title(){
## Echo title
echo " =========================================================================="
echo " Veil (Setup Script) | [Updated]: 2018-04-12"
echo " Veil (Setup Script) | [Updated]: 2018-04-16"
echo " =========================================================================="
echo " [Web]: https://www.veil-framework.com/ | [Twitter]: @VeilFramework"
echo " =========================================================================="
Expand All @@ -83,6 +83,8 @@ func_title(){
echo " winedir = ${winedir}"
echo " winedrive = ${winedrive}"
echo " gempath = ${gempath}"
echo " silent = ${silent}"
echo " force = ${force}"
echo ""
}

Expand All @@ -108,11 +110,6 @@ func_check_env(){
fi


## Feedback to user
[ "${silent}" == "true" ] && echo -e " [I] ${YELLOW}Silent Mode${RESET}: ${GREEN}Enabled${RESET}"
[ "${force}" == "true" ] && echo -e " [I] ${YELLOW}Force Mode${RESET}: ${GREEN}Enabled${RESET}"


## Double check install (if not silent)
echo -e "\n\n [?] ${BOLD}Are you sure you wish to install Veil?${RESET}\n"
echo -en " Continue with installation? ([${BOLD}y${RESET}]es/[${BOLD}s${RESET}]ilent/[${BOLD}N${RESET}]o): "
Expand Down Expand Up @@ -289,7 +286,7 @@ func_package_deps(){
|| echo -e "${RED}[ERROR]: Failed with apt-get install dependencies (5)\n${RESET}\n"
tmp="$?"
if [[ "${tmp}" -ne "0" ]]; then
msg="Failed to install dependencies (Metasploit-Framework/python2.7/python3/python3-pycryptodome/python3-crypto)... Exit code: ${tmp}"
msg="Failed to install the additional Kali/parrot dependencies... Exit code: ${tmp}"
errors="${errors}\n${msg}"
echo -e " ${RED}[ERROR] ${msg}${RESET}\n"
fi
Expand Down
20 changes: 14 additions & 6 deletions tools/evasion/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, cli_options=None):
"exit": "Completely exit Veil",
"back": "Go to Veil's main menu",
"clean": "Remove generated artifacts",
"checkvt": "Check VirusTotal against generated hashes"}
"checkvt": "Check VirusTotal.com against generated hashes"}
self.final_shellcode = ""
self.payload_option_commands = {
"set": "Set shellcode option",
Expand All @@ -58,7 +58,7 @@ def __init__(self, cli_options=None):

def check_vt(self, interactive=True):
"""
Checks payload hashes in veil-output/hashes.txt vs VirusTotal
Checks payload hashes in veil-output/hashes.txt vs VirusTotal.com
"""

# Command for in-menu vt-notify check against hashes within hash file
Expand All @@ -78,7 +78,7 @@ def check_vt(self, interactive=True):
print(helpers.color(" [!] File %s with hash %s found!" % (filename, filehash), warning=True))
found = True
if found is False:
print(" [*] No payloads found on VirusTotal!")
print(" [*] No payloads found on VirusTotal.com!")

input("\n [>] Press any key to continue...")

Expand Down Expand Up @@ -126,12 +126,19 @@ def clean_artifacts(self, interactive=True):
return

def cli_menu(self, invoked=False):
evasion_helpers.title_screen()

# --list-payloads
if self.command_options.list_payloads:
self.list_loaded_payloads()
sys.exit()

# check if a payload is provided, and if so, start the generation
# Check if a payload is provided, and if so, start the generation
# process
elif self.command_options.p:
# Missing -p ?
if not self.command_options.p:
print(helpers.color("[*] Error: Missing --payload selection (-p <payload>). Try: -t Evasion --list-payloads", warning=True))
else:
user_cli_payload = self.return_payload_object(self.command_options.p)
if not user_cli_payload:
print(helpers.color("[*] Error: You did not provide a valid payload selection!", warning=True))
Expand All @@ -142,6 +149,7 @@ def cli_menu(self, invoked=False):
sys.exit()

# Make sure IP is valid
# --ip
if self.command_options.ip is not None:
valid_ip = helpers.validate_ip(self.command_options.ip)
valid_hostname = helpers.validate_hostname(self.command_options.ip)
Expand Down Expand Up @@ -183,6 +191,7 @@ def cli_menu(self, invoked=False):
user_cli_payload.cli_shellcode = cli_shellcode

# Loop over setting required options
# -c
if self.command_options.c is not None:
for payload_option in self.command_options.c:
if payload_option is not '':
Expand All @@ -204,7 +213,6 @@ def cli_menu(self, invoked=False):

# figure out how to compile the code
outfile.compiler(user_cli_payload, invoked=True, cli_object=self.command_options)

return

def display_payload_options(self, selected_pload, showTitle=True):
Expand Down
100 changes: 53 additions & 47 deletions tools/ordnance/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,36 @@ def __init__(self, cli_options=None):
self.payload_options = {}

def cli_menu(self, invoked=False):
ordnance_helpers.title_screen()

# Check to see if we're just listing payloads or encoders
# If so, do that and then exit
# --list-payloads
if self.command_options.list_payloads:
self.print_payloads()
sys.exit()
# --list-encoders
elif self.command_options.list_encoders:
self.print_encoders()
sys.exit()

# Now let's check for payloads we're doing
if self.command_options.ordnance_payload:
payload_found = False
for payload in self.active_shellcode.values():
if self.command_options.ordnance_payload.lower() == payload.cli_name:
payload_found = True
if "LHOST" in payload.required_options:
# Missing --ordnance-payload ?
if not self.command_options.ordnance_payload:
print(helpers.color("[*] Error: Missing ordnance-payload selection (--ordnance-payload <payload>). Try: -t Ordnance --list-payloads", warning=True))
else:
payload_selected = self.command_options.ordnance_payload.lower()
payload = self.return_payload_object(payload_selected)
if not payload:
print(helpers.color("[*] Error: You specified a non-existent Ordnance payload!", warning=True))
sys.exit()
else:
if "LHOST" in payload.required_options:
# Is --ip missing?
if self.command_options.ip is None:
print(helpers.color("[*] Error: Missing --ip <value>", warning=True))
sys.exit()
else:
valid_ip = helpers.validate_ip(self.command_options.ip)
valid_hostname = helpers.validate_hostname(self.command_options.ip)
if valid_ip:
Expand All @@ -71,46 +86,39 @@ def cli_menu(self, invoked=False):
payload.required_options["LHOST"][0] = self.command_options.ip
else:
print(helpers.color("[*] Error: Invalid IP/Hostname specified!", warning=True))
print(helpers.color("[*] Try again?", warning=True))
sys.exit()
else:
print(helpers.color("[*] Error: Invalid IP/Hostname specified!", warning=True))
print(helpers.color("[*] Try again?", warning=True))
sys.exit()
if "LPORT" in payload.required_options:
if 0 < self.command_options.port < 65535:
payload.required_options["LPORT"][0] = self.command_options.port
else:
print(helpers.color("[*] Error: Invalid port number provided!", warning=True))
print(helpers.color("[*] Try again?", warning=True))
sys.exit()
# Generate the original shellcode
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:
encoder_found_here = False
if "BadChars" in payload.required_options:
payload.required_options["BadChars"][0] = self.command_options.bad_chars
for loaded_encoder in self.active_encoders.values():
if self.command_options.encoder.lower() == loaded_encoder.cli_name:
encoder_found_here = True
loaded_encoder.cli_encode(payload)
if not encoder_found_here:
print(helpers.color("[*] Error: Encoder you specified was not found!", warning=True))
print(helpers.color("[*] Try again?", warning=True))
sys.exit()
self.final_shellcode = payload.customized_shellcode
if invoked:
pass
if "LPORT" in payload.required_options:
if 0 < self.command_options.port < 65535:
payload.required_options["LPORT"][0] = self.command_options.port
else:
payload.payload_stats()

# If the payload supplied isn't found
if not payload_found:
print(helpers.color("[*] Error: You specified a non-existent Ordnance payload!", warning=True))
print(helpers.color("[*] Go to start... do not collect $200!", warning=True))
sys.exit()
print(helpers.color("[*] Error: Invalid port number provided!", warning=True))
print(helpers.color("[*] Try again?", warning=True))
sys.exit()
# Generate the original shellcode
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:
encoder_found_here = False
if "BadChars" in payload.required_options:
payload.required_options["BadChars"][0] = self.command_options.bad_chars
for loaded_encoder in self.active_encoders.values():
if self.command_options.encoder.lower() == loaded_encoder.cli_name:
encoder_found_here = True
loaded_encoder.cli_encode(payload)
if not encoder_found_here:
print(helpers.color("[*] Error: Encoder you specified was not found!", warning=True))
print(helpers.color("[*] Try again?", warning=True))
sys.exit()
self.final_shellcode = payload.customized_shellcode
if invoked:
pass
else:
payload.payload_stats()
return

def load_encoders(self, cli_args):
for name in sorted( glob.glob('tools/ordnance/encoders/*.py') ):
Expand All @@ -133,11 +141,8 @@ def print_encoders(self):
print("\tCommand Line Name => Description")
print("-" * 79)
print()
#x = 1
for encoder_module in self.active_encoders.values():
print( "\t%s)\t%s => %s" % ( x, '{0: <24}'.format( helpers.color( encoder_module.cli_name ) ), encoder_module.name ) )
print( "\t%s => %s" % ( x, '{0: <24}'.format( helpers.color( encoder_module.cli_name ) ), encoder_module.name ) )
#x += 1
print( "\t%s => %s" % ( '{0: <24}'.format( helpers.color( encoder_module.cli_name ) ), encoder_module.name ) )
return

def print_shellcode_option_commands(self):
Expand Down Expand Up @@ -217,13 +222,15 @@ def tool_main_menu(self, invoked=False):
list_selection = ordnance_main_command.split()[1].lower()

# Check and see what we are listing
# Payloads
if list_selection.startswith('p'):
ordnance_helpers.title_screen()
self.print_payloads()
print()
ordnance_main_command = ""
show_ordnance_menu = False

# Encdoers
elif list_selection.startswith('e'):
ordnance_helpers.title_screen()
self.print_encoders()
Expand Down Expand Up @@ -287,11 +294,9 @@ def return_payload_object(self, user_selection):
for payload in self.active_shellcode.values():
if user_selection.isdigit() and (0 < int(user_selection) <= len(self.active_shellcode)):
if int(user_selection) == counter_value:
print ("w00t1!")
return payload
else:
if user_selection.lower() == payload.cli_name:
print ("w00t2!")
return payload

# Iterate counter for number based selection
Expand Down Expand Up @@ -403,6 +408,7 @@ def use_payload(self, payload):
self.final_shellcode = payload.customized_shellcode

# Print payload stats
ordnance_helpers.title_screen()
payload.payload_stats()
if self.invoked:
dummy = input('\nHit enter to return to Veil-Evasion... ')
Expand Down

0 comments on commit 1ece1d0

Please sign in to comment.