Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added autocompletion to payloads #142

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 27 additions & 13 deletions Villain.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,13 +481,23 @@ def __init__(self):
self.generate_arguments = ['payload', 'lhost', 'obfuscate', 'encode', 'constraint_mode', \
'exec_outfile', 'domain']
self.payload_templates_root = os.path.dirname(os.path.abspath(__file__)) + f'{os.sep}Core{os.sep}payload_templates'

self.payload_templates_list = self.get_payload_templates_list()


def reset_counter(self):
sleep(0.4)
self.tab_counter = 0



def get_payload_templates_list(self):
root = self.payload_templates_root
dirs = [d + os.sep for d in next(os.walk(root))[1]]
files = next(os.walk(root))[2]
files = [os.path.splitext(f)[0] for f in files]

return dirs + files



def get_possible_cmds(self, cmd_frag):
Expand Down Expand Up @@ -673,6 +683,9 @@ def complete(self, text, state):






# Autocomplete aliases for reset
elif (main_cmd in ['reset']) and (line_buffer_list_len > 1) and \
(line_buffer_list[-1][0] not in ["/", "~"]):
Expand All @@ -686,28 +699,29 @@ def complete(self, text, state):
self.update_prompt(len(line_buffer_list[-1]), match) if match else chill()



# Autocomplete generate prompt command arguments
elif (main_cmd == 'generate') and (line_buffer_list_len > 1):

word_frag = line_buffer_list[-1].lower()

if re.search('payload=[\w\/\\\]{0,}', word_frag):

tmp = word_frag.split('=')

if tmp[1]:

root = self.payload_templates_root
root = self.payload_templates_root
search_term = tmp[1]
self.path_autocompleter(root, search_term, hide_py_extensions = True)

self.path_autocompleter(root, search_term, hide_py_extensions=True)
else:
pass

else:
match = self.get_match_from_list(line_buffer_list[-1], self.generate_arguments)
self.update_prompt(len(line_buffer_list[-1]), match, lower = True) if match else chill()
if line_buffer_list_len >= 3 and line_buffer_list[-2] == 'payload':
match = self.get_match_from_list(line_buffer_list[-1], self.payload_templates_list)
self.update_prompt(len(line_buffer_list[-1]), match, lower=True) if match else chill()
else:
match = self.get_match_from_list(line_buffer_list[-1], self.generate_arguments)
self.update_prompt(len(line_buffer_list[-1]), match, lower=True) if match else chill()



# Autocomplete help
Expand Down