Skip to content

Escape literal backslashes in f-strings to fix syntax warnings#5

Open
deFractal wants to merge 2 commits into
Z4kSec:masterfrom
deFractal:backslash
Open

Escape literal backslashes in f-strings to fix syntax warnings#5
deFractal wants to merge 2 commits into
Z4kSec:masterfrom
deFractal:backslash

Conversation

@deFractal

@deFractal deFractal commented Mar 30, 2024

Copy link
Copy Markdown

This escapes backslashes which aren't part of an escape sequence in f-strings, to fix instances of SyntaxWarning in a few files:

masky/core.py:108: SyntaxWarning: invalid escape sequence '\{'
  f"Start processing PFX of the user '{user_data.domain}\{user_data.name}'"
masky/core.py:112: SyntaxWarning: invalid escape sequence '\{'
  f"Fail to process gathered certificate related to the user '{user_data.domain}\{user_data.name}'"
masky/core.py:116: SyntaxWarning: invalid escape sequence '\{'
  f"End processing PFX of the user '{user_data.domain}\{user_data.name}'"
masky/lib/cert/auth.py:428: SyntaxWarning: invalid escape sequence '\{'
  f"Gathered NT hash for the user '{domain}\{username}': {nt_hash}"
masky/lib/smb.py:105: SyntaxWarning: invalid escape sequence '\{'
  err_msg = f"The user {self.__domain}\{self.__username} is not local administrator on this system"
masky/lib/smb.py:108: SyntaxWarning: invalid escape sequence '\{'
  err_msg = f"The provided credentials for the user '{self.__domain}\{self.__username}' are invalids or the user does not exist"
masky/lib/smb.py:295: SyntaxWarning: invalid escape sequence '\p'
  np_bind = f"ncacn_np:{target_host}[\pipe\svcctl]"
masky/ui/main.py:20: SyntaxWarning: invalid escape sequence '\/'
  """
masky/ui/options.py:164: SyntaxWarning: invalid escape sequence '\C'
  help="Certificate Authority Name (SERVER\CA_NAME)",

In main,py, it also combines a triple-quoted r-string and a trip-quoted f-string to align all but the last line of the ASCII art in the source code while fixing a couple of the aforementioned backslash escapes.

…rent Python

Also fix a few minor typos in comments, strings, and documentation
X0RW3LL added a commit to X0RW3LL/Masky that referenced this pull request Sep 30, 2024
* Fix Python 3.12 SyntaxWarning
* Various typo and grammar fixes
* masky/ui/main.py: future-proof ASCII art by justifying spaces
  following version so as to avoid manually doing that in future
  double-digit version bumps

@rtpt-romankarwacik rtpt-romankarwacik left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One backslash escape is missing:

diff --git a/masky/lib/smb.py b/masky/lib/smb.py
index 5730293..dc56e9b 100644
--- a/masky/lib/smb.py
+++ b/masky/lib/smb.py
@@ -292,7 +292,7 @@ class Smb:
         return rslt
 
     def __init_rpc(self, target_host):
-        np_bind = f"ncacn_np:{target_host}[\pipe\svcctl]"
+        np_bind = f"ncacn_np:{target_host}[\\pipe\\svcctl]"
         self.__rpc_con = transport.DCERPCTransportFactory(np_bind)
         self.__rpc_con.set_dport(self.__port)
         self.__rpc_con.setRemoteHost(target_host)

deFractal pushed a commit to deFractal/Masky that referenced this pull request Nov 15, 2025
from: Z4kSec/pull/5#pullrequestreview-3360223283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants