python / cpython

The Python programming language
https://www.python.org
Other
63.8k stars 30.55k forks source link

SyntaxWarning: invalid escape sequence #125689

Closed sec13b closed 1 month ago

sec13b commented 1 month ago

after i update the python

setting up crackmapexec (5.4.0-0kali6) ...
/usr/lib/python3/dist-packages/cme/cli.py:35: SyntaxWarning: invalid escape sequence '\ '
  """,
/usr/lib/python3/dist-packages/cme/cmedb.py:141: SyntaxWarning: invalid escape sequence '\{'
  entry.append(f"{user[1]}\{user[2]}")
/usr/lib/python3/dist-packages/cme/modules/daclread.py:71: SyntaxWarning: invalid escape sequence '\V'
  'S-1-5-83-0': 'NT VIRTUAL MACHINE\Virtual Machines',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:80: SyntaxWarning: invalid escape sequence '\P'
  'S-1-5-32-554': 'BUILTIN\Pre-Windows 2000 Compatible Access',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:81: SyntaxWarning: invalid escape sequence '\R'
  'S-1-5-32-555': 'BUILTIN\Remote Desktop Users',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:82: SyntaxWarning: invalid escape sequence '\I'
  'S-1-5-32-557': 'BUILTIN\Incoming Forest Trust Builders',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:84: SyntaxWarning: invalid escape sequence '\P'
  'S-1-5-32-558': 'BUILTIN\Performance Monitor Users',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:85: SyntaxWarning: invalid escape sequence '\P'
  'S-1-5-32-559': 'BUILTIN\Performance Log Users',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:86: SyntaxWarning: invalid escape sequence '\W'
  'S-1-5-32-560': 'BUILTIN\Windows Authorization Access Group',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:87: SyntaxWarning: invalid escape sequence '\T'
  'S-1-5-32-561': 'BUILTIN\Terminal Server License Servers',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:88: SyntaxWarning: invalid escape sequence '\D'
  'S-1-5-32-562': 'BUILTIN\Distributed COM Users',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:89: SyntaxWarning: invalid escape sequence '\C'
  'S-1-5-32-569': 'BUILTIN\Cryptographic Operators',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:90: SyntaxWarning: invalid escape sequence '\E'
  'S-1-5-32-573': 'BUILTIN\Event Log Readers',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:91: SyntaxWarning: invalid escape sequence '\C'
  'S-1-5-32-574': 'BUILTIN\Certificate Service DCOM Access',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:92: SyntaxWarning: invalid escape sequence '\R'
  'S-1-5-32-575': 'BUILTIN\RDS Remote Access Servers',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:93: SyntaxWarning: invalid escape sequence '\R'
  'S-1-5-32-576': 'BUILTIN\RDS Endpoint Servers',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:94: SyntaxWarning: invalid escape sequence '\R'
  'S-1-5-32-577': 'BUILTIN\RDS Management Servers',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:95: SyntaxWarning: invalid escape sequence '\H'
  'S-1-5-32-578': 'BUILTIN\Hyper-V Administrators',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:96: SyntaxWarning: invalid escape sequence '\A'
  'S-1-5-32-579': 'BUILTIN\Access Control Assistance Operators',
/usr/lib/python3/dist-packages/cme/modules/daclread.py:97: SyntaxWarning: invalid escape sequence '\R'
  'S-1-5-32-580': 'BUILTIN\Remote Management Users',
/usr/lib/python3/dist-packages/cme/modules/get_description.py:34: SyntaxWarning: invalid escape sequence '\d'
  self.regex = re.compile("((?=[^ ]*[A-Z])(?=[^ ]*[a-z])(?=[^ ]*\d)|(?=[^ ]*[a-z])(?=[^ ]*\d)(?=[^ ]*[^\w \n])|(?=[^ ]*[A-Z])(?=[^ ]*\d)(?=[^ ]*[^\w \n])|(?=[^ ]*[A-Z])(?=[^ ]*[a-z])(?=[^ ]*[^\w \n]))[^ \n]{"+self.MINLENGTH+",}") # Credit : https://stackoverflow.com/questions/31191248/regex-password-must-have-at-least-3-of-the-4-of-the-following
/usr/lib/python3/dist-packages/cme/modules/masky.py:16: SyntaxWarning: invalid escape sequence '\C'
  """
/usr/lib/python3/dist-packages/cme/modules/masky.py:37: SyntaxWarning: invalid escape sequence '\C'
  "Please provide a valid CA server and CA name (CA_SERVER\CA_NAME)"
/usr/lib/python3/dist-packages/cme/modules/masky.py:83: SyntaxWarning: invalid escape sequence '\{'
  context.log.highlight(f"{user.domain}\{user.name} {user.nt_hash}")
/usr/lib/python3/dist-packages/cme/modules/met_inject.py:41: SyntaxWarning: invalid escape sequence '\p'
  command = """$url="{}://{}:{}/{}"
/usr/lib/python3/dist-packages/cme/modules/ms17-010.py:14: SyntaxWarning: invalid escape sequence '\ '
  description = "MS17-010, /!\ not tested oustide home lab"
/usr/lib/python3/dist-packages/cme/modules/ms17-010.py:184: SyntaxWarning: invalid escape sequence '\I'
  ipc = "\\\\{}\IPC$\x00".format(ip)
/usr/lib/python3/dist-packages/cme/modules/nanodump.py:45: SyntaxWarning: invalid escape sequence '\C'
  if not os.path.exists(appdata_path+"\CME"):
/usr/lib/python3/dist-packages/cme/modules/nanodump.py:46: SyntaxWarning: invalid escape sequence '\C'
  os.mkdir(appdata_path+"\CME")
/usr/lib/python3/dist-packages/cme/modules/nanodump.py:47: SyntaxWarning: invalid escape sequence '\C'
  self.nano_path = appdata_path + "\CME\\"
/usr/lib/python3/dist-packages/cme/modules/runasppl.py:18: SyntaxWarning: invalid escape sequence '\S'
  command = 'reg query HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\ /v RunAsPPL'
/usr/lib/python3/dist-packages/cme/modules/wireless.py:18: SyntaxWarning: invalid escape sequence '\:'
  command = 'powershell.exe -c "(netsh wlan show profiles) | Select-String """"\:(.+)$"""" | %{$name=$_.Matches.Groups[1].Value.Trim(); $_} | %{(netsh wlan show profile name="$name" key=clear)}'
/usr/lib/python3/dist-packages/cme/protocols/smb/smbexec.py:49: SyntaxWarning: invalid escape sequence '\p'
  stringbinding = 'ncacn_np:%s[\pipe\svcctl]' % self.__host
/usr/lib/python3/dist-packages/cme/protocols/smb/smbexec.py:93: SyntaxWarning: invalid escape sequence '\{'
  command = self.__shell + 'echo '+ data + ' ^> \\\\127.0.0.1\\{}\\{} 2^>^&1 > %TEMP%\{} & %COMSPEC% /Q /c %TEMP%\{} & %COMSPEC% /Q /c del %TEMP%\{}'.format(self.__share_name, self.__output, self.__batchFile, self.__batchFile, self.__batchFile)
/usr/lib/python3/dist-packages/cme/protocols/winrm.py:324: SyntaxWarning: invalid escape sequence '\S'
  self.conn.execute_cmd("reg save HKLM\SAM C:\\windows\\temp\\SAM && reg save HKLM\SYSTEM C:\\windows\\temp\\SYSTEM")
/usr/lib/python3/dist-packages/cme/protocols/winrm.py:338: SyntaxWarning: invalid escape sequence '\S'
  self.conn.execute_cmd("reg save HKLM\SECURITY C:\\windows\\temp\\SECURITY && reg save HKLM\SYSTEM C:\\windows\\temp\\SYSTEM")

Setting up wifite (2.7.0-2) ...
/usr/lib/python3/dist-packages/wifite/attack/pmkid.py:342: SyntaxWarning: invalid escape sequence '\d'
  essid_safe = re.sub('[^a-zA-Z\d]', '', self.target.essid)
/usr/lib/python3/dist-packages/wifite/attack/wpa.py:199: SyntaxWarning: invalid escape sequence '\d'
  essid_safe = re.escape(re.sub('[^a-zA-Z\d]', '', essid))
/usr/lib/python3/dist-packages/wifite/attack/wpa.py:226: SyntaxWarning: invalid escape sequence '\d'
  essid_safe = re.sub('[^a-zA-Z\d]', '', handshake.essid)

Setting up python3-winacl (0.1.9-0kali1) ...
/usr/lib/python3/dist-packages/winacl/functions/winregistry.py:27: SyntaxWarning: invalid escape sequence '\C'
  key = 'System\CurrentControlSet\Services\Tcpip\Parameters\Interfaces'

Setting up python3-masky (0.2.0-0kali3) ...
/usr/lib/python3/dist-packages/masky/core.py:108: SyntaxWarning: invalid escape sequence '\{'
  f"Start processing PFX of the user '{user_data.domain}\{user_data.name}'"
/usr/lib/python3/dist-packages/masky/core.py:112: SyntaxWarning: invalid escape sequence '\{'
  f"Fail to process gathered certificate related to the user '{user_data.domain}\{user_data.name}'"
/usr/lib/python3/dist-packages/masky/core.py:116: SyntaxWarning: invalid escape sequence '\{'
  f"End processing PFX of the user '{user_data.domain}\{user_data.name}'"
nineteendo commented 1 month ago

Works as intended, use a raw string for strings with unescaped backslashes. If suggest to raise an issue if this is an issue with a library you're using.

nineteendo commented 1 month ago

Both string and bytes literals may optionally be prefixed with a letter 'r' or 'R'; such constructs are called raw string literals and raw bytes literals respectively and treat backslashes as literal characters. As a result, in raw string literals, '\U' and '\u' escapes are not treated specially.

nineteendo commented 1 month ago

Can someone close this issue?

sec13b commented 3 weeks ago

nothing