Skip to content

Commit

Permalink
Merge pull request Veil-Framework#50 from Veil-Framework/readbinary
Browse files Browse the repository at this point in the history
Readbinary
  • Loading branch information
ChrisTruncer authored Apr 17, 2017
2 parents 6b48039 + 9a3e5ed commit e733079
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Tools/Evasion/Tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from Tools.Evasion.evasion_common import evasion_helpers
from Tools.Evasion.evasion_common import outfile
from Tools.Evasion.evasion_common import shellcode_help
from Tools.Ordnance import Tool as Ordnance_Import


# try to find and import the settings.py config file
Expand All @@ -27,6 +26,9 @@
print("\n [!] ERROR #1: run %s manually\n" % (os.path.abspath("./config/update.py")))
sys.exit()

sys.path.insert(0, settings.VEIL_EVASION_PATH + 'Tools/Ordnance')
import Tool as Ordnance_Import


class Tools:

Expand Down
48 changes: 44 additions & 4 deletions Tools/Evasion/evasion_common/shellcode_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@
import sys

from lib.common import helpers
from Tools.Ordnance import Tool as Ordnance_Import
from Tools.Evasion.evasion_common import evasion_helpers
from lib.common import completer

# try to find and import the settings.py config file
if os.path.exists("/etc/veil/settings.py"):
try:
sys.path.append("/etc/veil/")
import settings

import settings
except ImportError:
print("\n [!] ERROR #1: run %s manually\n" % (os.path.abspath("./config/update.py")))
sys.exit()

sys.path.insert(0, settings.VEIL_EVASION_PATH + 'Tools/Ordnance')
import Tool as Ordnance_Import


class Shellcode:
Expand Down Expand Up @@ -180,7 +189,8 @@ def payload_selection_menu(self, showTitle=True):
print(' %s - Ordnance %s' % (helpers.color('1'), helpers.color('(default)', yellow=True)))
print(' %s - MSFVenom' % (helpers.color('2')))
print(' %s - custom shellcode string' % (helpers.color('3')))
print(' %s - file with shellcode (raw)\n' % (helpers.color('4')))
print(' %s - file with shellcode (\\x41\\x42..)' % (helpers.color('4')))
print(' %s - binary file with shellcode\n' % helpers.color('5'))

try:
choice = self.required_options['SHELLCODE'][0].lower().strip()
Expand All @@ -198,7 +208,7 @@ def payload_selection_menu(self, showTitle=True):
readline.set_completer(comp.complete)

# if the shellcode is specicified as a raw file
filePath = input(" [>] Please enter the path to your raw shellcode file: ")
filePath = input(" [>] Please enter the path to your shellcode file: ")

try:
with open(filePath, 'r') as shellcode_file:
Expand All @@ -224,6 +234,36 @@ def payload_selection_menu(self, showTitle=True):
# remove the completer
readline.set_completer(None)

elif choice == '5':
# instantiate our completer object for path completion
comp = completer.PathCompleter()

# we want to treat '/' as part of a word, so override the delimiters
readline.set_completer_delims(' \t\n;')
readline.parse_and_bind("tab: complete")
readline.set_completer(comp.complete)

# if the shellcode is specicified as a raw file
filePath = input(" [>] Please enter the path to your binary file: ")

try:
with open(filePath, 'rb') as shellcode_file:
file_shellcode = shellcode_file.read()

except:
print(helpers.color(" [!] WARNING: path not found, defaulting to msfvenom!", warning=True))
return None

if len(file_shellcode) == 0:
print(helpers.color(" [!] WARNING: no custom shellcode restrieved, defaulting to msfvenom!", warning=True))
return None

binary_code = ''
# Convert from binary to shellcode
for byte in file_shellcode:
binary_code += "\\x" + hex(byte)[2:].zfill(2)
return binary_code

elif choice == '3' or choice == 'string':
# if the shellcode is specified as a string
cust_sc = input(" [>] Please enter custom shellcode (one line, no quotes, \\x00.. format): ")
Expand Down

0 comments on commit e733079

Please sign in to comment.