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

SyntaxWarning with Python 3.12 #177

Open
elboulangero opened this issue Jul 22, 2024 · 0 comments · May be fixed by #179
Open

SyntaxWarning with Python 3.12 #177

elboulangero opened this issue Jul 22, 2024 · 0 comments · May be fixed by #179

Comments

@elboulangero
Copy link

elboulangero commented Jul 22, 2024

With Python 3.12:

/usr/share/unicorn-magic/unicorn.py:1241: SyntaxWarning: invalid escape sequence '\.'
  elif re.search('\.ps1$', sys.argv[1]) is not None:

This change is documented at https://docs.python.org/3/whatsnew/3.12.html#other-language-changes:

A backslash-character pair that is not a valid escape sequence now generates a SyntaxWarning, instead of DeprecationWarning. For example, re.compile("\d+.\d+") now emits a SyntaxWarning ("\d" is an invalid escape sequence, use raw strings for regular expression: re.compile(r"\d+.\d+")). In a future Python version, SyntaxError will eventually be raised, instead of SyntaxWarning.

Patch (trivial):

From: Arnaud Rebillout <arnaudr@kali.org>
Date: Mon, 22 Jul 2024 22:53:10 +0200
Subject: Use raw string for regex pattern

---
 unicorn.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/unicorn.py b/unicorn.py
index 496bd57..c06aacf 100755
--- a/unicorn.py
+++ b/unicorn.py
@@ -1238,7 +1238,7 @@ try:
             if len(sys.argv) > 2 and sys.argv[2] == "crt":
                 attack_type = "crt"
                 payload = sys.argv[1]
-            elif re.search('\.ps1$', sys.argv[1]) is not None:
+            elif re.search(r'\.ps1$', sys.argv[1]) is not None:
                 attack_type = "custom_ps1"
                 ps1path = sys.argv[1]
 
jeffmcjunkin added a commit to jeffmcjunkin/unicorn that referenced this issue Jan 29, 2025
Closes trustedsec#177. Figured I'd put this PR in while I was here <3
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 a pull request may close this issue.

1 participant