new versions of python 3.9+ new regex patterns defined as raw strings, otherwise report syntax error for unknown stirng escape sequence like \s Only in dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig: 1.orig diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/doc/source/conf.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/doc/source/conf.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/doc/source/conf.py 2024-07-16 02:09:42.459377247 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/doc/source/conf.py 2024-07-16 02:08:40.881028357 +0200 @@ -62,7 +62,7 @@ # The short X.Y version. version = "undefined" regex_version = re.compile( - "^project\s*\([^)]+?\s+VERSION\s+(?P[0-9]+\.[0-9]+\.[0-9]+)$", + r"^project\s*\([^)]+?\s+VERSION\s+(?P[0-9]+\.[0-9]+\.[0-9]+)$", re.MULTILINE|re.DOTALL ) data = open("../../CMakeLists.txt", "r").read() diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/cmd.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/cmd.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/cmd.py 2024-07-16 02:09:42.462377264 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/cmd.py 2024-07-16 02:08:40.918028567 +0200 @@ -29,7 +29,7 @@ else: self.send = self.void self.files = {} - self.cwd = 'C:\WINDOWS\System32' + self.cwd = 'C:\\WINDOWS\\System32' def handle_io_in(self, data): diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/emu_scripts/handler.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/emu_scripts/handler.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/emu_scripts/handler.py 2024-07-16 02:09:42.464377275 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/emu_scripts/handler.py 2024-07-16 02:11:23.762951218 +0200 @@ -22,7 +22,7 @@ self._regex_detect = [] self._regex_url = re.compile( - b"(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)" + r"(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)" ) def run(self, data): @@ -52,7 +52,7 @@ self._config = config self._regex_url = re.compile( - b"(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)" + r"(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)" ) def run(self, data): @@ -70,13 +70,13 @@ self.min_match_count = 2 self._regex_detect = [ - re.compile(b"New-Object\s+System\.Net\.WebClient"), - re.compile(b"DownloadFile([^,]+?,[^,]+?)"), - re.compile(b"Invoke-Expression([^)]+?)") + re.compile(r"New-Object\s+System\.Net\.WebClient"), + re.compile(r"DownloadFile([^,]+?,[^,]+?)"), + re.compile(r"Invoke-Expression([^)]+?)") ] self._regex_url = re.compile( - b"\w+\s*=\s*\"\s*(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)\s*\"" + r"\w+\s*=\s*\"\s*(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)\s*\"" ) @@ -88,9 +88,9 @@ self.min_match_count = 1 self._regex_detect = [ - re.compile(b"Set\s+\w+\s+=\s+CreateObject\(.*?(Msxml2.XMLHTTP|Wscript.Shell).*?\)") + re.compile(r"Set\s+\w+\s+=\s+CreateObject\(.*?(Msxml2.XMLHTTP|Wscript.Shell).*?\)") ] self._regex_url = re.compile( - b"\.Open\s+\"GET\"\s*,\s*\"(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)\"" + r"\.Open\s+\"GET\"\s*,\s*\"(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)\"" ) diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/memcache/command.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/memcache/command.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/memcache/command.py 2024-07-16 02:09:42.466377287 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/memcache/command.py 2024-07-16 02:08:40.902028476 +0200 @@ -18,7 +18,7 @@ class Decrement(Command): name = "decr" - regex_cmd = re.compile(b"^decr (?P\w+) (?P\d+)( (?Pnoreply))?$") + regex_cmd = re.compile(r"^decr (?P\w+) (?P\d+)( (?Pnoreply))?$") def __init__(self, key=None, value=0, no_reply=False): self.key = key @@ -37,7 +37,7 @@ class Delete(Command): name = "delete" - regex_cmd = re.compile(b"^(?P\w+) (?P\w+)( (?Pnoreply))?$") + regex_cmd = re.compile(r"^(?P\w+) (?P\w+)( (?Pnoreply))?$") def __init__(self, key=None, no_reply=None): self.key = key @@ -73,7 +73,7 @@ class Increment(Command): name = "incr" - regex_cmd = re.compile(b"^incr (?P\w+) (?P\d+)( (?Pnoreply))?$") + regex_cmd = re.compile(r"^incr (?P\w+) (?P\d+)( (?Pnoreply))?$") def __init__(self, key=None, value=0, no_reply=False): self.key = key @@ -91,7 +91,7 @@ class StorageCommand(Command): - regex_cmd = re.compile(b"^(?P\w+) (?P\w+) (?P\d+) (?P\d+) (?P\d+)( (?Pnoreply))?") + regex_cmd = re.compile(r"^(?P\w+) (?P\w+) (?P\d+) (?P\d+) (?P\d+)( (?Pnoreply))?") def __init__(self, key=None, flags=None, exptime=None, byte_count=None, noreply=None): self.key = key @@ -171,7 +171,7 @@ class Touch(Command): name = "touch" - regex_cmd = re.compile(b"^touch (?P\w+) (?P\d+)( (?Pnoreply))?$") + regex_cmd = re.compile(r"^touch (?P\w+) (?P\d+)( (?Pnoreply))?$") def __init__(self, key=None, exptime=None, no_reply=None): self.key = key diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/mysql/mysql.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/mysql/mysql.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/mysql/mysql.py 2024-07-16 02:09:42.468377298 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/mysql/mysql.py 2024-07-16 02:13:32.901682889 +0200 @@ -19,12 +19,12 @@ logger = logging.getLogger('mysqld') re_show_var = re.compile( - b"show\s+((?Pglobal)\s+)?variables(\s+like\s+(?P\"|')(?P.*?)(?P=sep))?", + r"show\s+((?Pglobal)\s+)?variables(\s+like\s+(?P\"|')(?P.*?)(?P=sep))?", re.I ) re_select_var = re.compile( - b"select\s+(?P@(?P@)?(?P\w+))(\s+limit\s+\d+)?", + r"select\s+(?P@(?P@)?(?P\w+))(\s+limit\s+\d+)?", re.I ) @@ -42,7 +42,7 @@ self.config = None self.state = "" self.regex_statement = re.compile( - b"""([A-Za-z0-9_.]+\(.*?\)+|\(.*?\)+|"(?:[^"]|\"|"")*"+|'[^'](?:|\'|'')*'+|`(?:[^`]|``)*`+|[^ ,]+|,)""" + r"""([A-Za-z0-9_.]+\(.*?\)+|\(.*?\)+|"(?:[^"]|\"|"")*"+|'[^'](?:|\'|'')*'+|`(?:[^`]|``)*`+|[^ ,]+|,)""" ) self.download_dir = None self.download_suffix = ".tmp" @@ -146,7 +146,7 @@ if re.match(b'set ', p.Query, re.I): r = MySQL_Result_OK(Message="#2") - elif re.match(b'select\s+database\s*\(\s*\)$', p.Query, re.I): + elif re.match(r'select\s+database\s*\(\s*\)$', p.Query, re.I): r = [ MySQL_Result_Header(FieldCount=1), MySQL_Result_Field( @@ -167,7 +167,7 @@ MySQL_Result_EOF(ServerStatus=0x002) ] - elif re.match(b"show\s+databases$", p.Query, re.I): + elif re.match(r"show\s+databases$", p.Query, re.I): r = [ MySQL_Result_Header(FieldCount=1), MySQL_Result_Field( @@ -192,7 +192,7 @@ # r.append(MySQL_Result_Row_Data(ColumnValues=['information_schema'])) r.append(MySQL_Result_EOF(ServerStatus=0x002)) - elif re.match(b'show\s+tables$', p.Query, re.I): + elif re.match(r'show\s+tables$', p.Query, re.I): r = [ MySQL_Result_Header(FieldCount=1), MySQL_Result_Field( @@ -273,8 +273,8 @@ if len(query) == 0: return False - regex_function = re.compile(b"(?P[A-Za-z0-9_.]+)\((?P.*?)\)+") - regex_url = re.compile(b"(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)") + regex_function = re.compile(r"(?P[A-Za-z0-9_.]+)\((?P.*?)\)+") + regex_url = re.compile(r"(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)") m = re_select_var.match(p.Query) if m: diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/sip/extras.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/sip/extras.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/sip/extras.py 2024-07-16 02:09:42.471377315 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/sip/extras.py 2024-07-16 02:08:40.911028527 +0200 @@ -261,7 +261,7 @@ sdp = data[0] for n,v in media_ports.items(): if v is None: - sdp = re.sub("\[" + n +"\].*\[\/" + n + "\]", "", sdp, 0, re.DOTALL) + sdp = re.sub("\\[" + n +"\\].*\\[\\/" + n + "\\]", "", sdp, 0, re.DOTALL) else: params[n] = v diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/sip/rfc2396.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/sip/rfc2396.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/sip/rfc2396.py 2024-07-16 02:09:42.473377327 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/sip/rfc2396.py 2024-07-16 02:08:40.911028527 +0200 @@ -28,9 +28,9 @@ b'"John Doe" ' """ _syntax = [ - re.compile(b'^(?P[a-zA-Z0-9\-\.\_\+\~\ \t]*)<(?P[^>]+)>( *; *(?P.*))?'), - re.compile(b'^(?:"(?P[a-zA-Z0-9\-\.\_\+\~\ \t]+)")[\ \t]*<(?P[^>]+)>( *; *(?P.*))?'), - re.compile(b'^[\ \t]*(?P)(?P[^;]+)( *; *(?P.*))?') + re.compile(r'^(?P[a-zA-Z0-9\-\.\_\+\~\ \t]*)<(?P[^>]+)>( *; *(?P.*))?'), + re.compile(r'^(?:"(?P[a-zA-Z0-9\-\.\_\+\~\ \t]+)")[\ \t]*<(?P[^>]+)>( *; *(?P.*))?'), + re.compile(r'^[\ \t]*(?P)(?P[^;]+)( *; *(?P.*))?') ] def __init__(self, display_name = None, uri = None, must_quote = None, params = None): @@ -128,12 +128,12 @@ True """ - _syntax = re.compile(b"^(?P[a-zA-Z][a-zA-Z0-9\+\-\.]*):" # scheme - + b"(?:(?:(?P[a-zA-Z0-9\-\_\.\!\~\*\'\(\)&=\+\$,;\?\/\%]+)" # user - + b"(?::(?P[^:@;\?]+))?)@)?" # password - + b"(?:(?:(?P[^;\?:]*)(?::(?P[\d]+))?))" # host, port - + b"(?:;(?P[^\?]*))?" # parameters - + b"(?:\?(?P.*))?$" # headers + _syntax = re.compile(r"^(?P[a-zA-Z][a-zA-Z0-9\+\-\.]*):" # scheme + + r"(?:(?:(?P[a-zA-Z0-9\-\_\.\!\~\*\'\(\)&=\+\$,;\?\/\%]+)" # user + + r"(?::(?P[^:@;\?]+))?)@)?" # password + + r"(?:(?:(?P[^;\?:]*)(?::(?P[\d]+))?))" # host, port + + r"(?:;(?P[^\?]*))?" # parameters + + r"(?:\?(?P.*))?$" # headers ) def __init__(self, scheme = None, user = None, password = None, host = None, port = None, params = None, headers = None): diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/sip/rfc3261.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/sip/rfc3261.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/sip/rfc3261.py 2024-07-16 02:09:42.475377338 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/sip/rfc3261.py 2024-07-16 02:08:40.911028527 +0200 @@ -678,7 +678,7 @@ b'z9hG4bK77asjd' b'192.0.2.207' """ - _syntax = re.compile(b"SIP */ *2\.0 */ *(?P[a-zA-Z]+) *(?P
[^ :;]*) *(:(?P[0-9]+))?( *; *(?P.*))?") + _syntax = re.compile(r"SIP */ *2\.0 */ *(?P[a-zA-Z]+) *(?P
[^ :;]*) *(:(?P[0-9]+))?( *; *(?P.*))?") def __init__(self, protocol = None, address = None, port = None, params = None): if params is None: diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/smb/include/asn1/mib.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/smb/include/asn1/mib.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/smb/include/asn1/mib.py 2024-07-16 02:09:42.478377355 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/smb/include/asn1/mib.py 2024-07-16 02:08:40.913028539 +0200 @@ -19,12 +19,12 @@ ## MIB parsing ## ################# -_mib_re_integer = re.compile("^[0-9]+$") -_mib_re_both = re.compile("^([a-zA-Z_][a-zA-Z0-9_-]*)\(([0-9]+)\)$") +_mib_re_integer = re.compile(r"^[0-9]+$") +_mib_re_both = re.compile(r"^([a-zA-Z_][a-zA-Z0-9_-]*)\(([0-9]+)\)$") _mib_re_oiddecl = re.compile( - "$\s*([a-zA-Z0-9_-]+)\s+OBJECT([^:\{\}]|\{[^:]+\})+::=\s*\{([^\}]+)\}",re.M) -_mib_re_strings = re.compile('"[^"]*"') -_mib_re_comments = re.compile('--.*(\r|\n)') + r"$\s*([a-zA-Z0-9_-]+)\s+OBJECT([^:\{\}]|\{[^:]+\})+::=\s*\{([^\}]+)\}",re.M) +_mib_re_strings = re.compile(r'"[^"]*"') +_mib_re_comments = re.compile(r'--.*(\r|\n)') class MIBDict(DADict): def _findroot(self, x): diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/smb/include/fieldtypes.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/smb/include/fieldtypes.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/smb/include/fieldtypes.py 2024-07-16 02:09:42.480377366 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/smb/include/fieldtypes.py 2024-07-16 02:08:40.915028550 +0200 @@ -188,7 +188,7 @@ def m2i(self, pkt, x): return str2mac(x) def any2i(self, pkt, x): - if type(x) is str and len(x) is 6: + if type(x) is str and len(x) == 6: x = self.m2i(pkt, x) return x def i2repr(self, pkt, x): diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/smb/rpcservices.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/smb/rpcservices.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/smb/rpcservices.py 2024-07-16 02:09:42.484377389 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/smb/rpcservices.py 2024-07-16 02:08:40.916028556 +0200 @@ -2802,7 +2802,7 @@ rpclog.debug("docname {} outputfile {}".format(DocName, OutputFile)) - if OutputFile.startswith('\\') and OutputFile.endswith('\PIPE\ATSVC'): + if OutputFile.startswith('\\\\') and OutputFile.endswith('\\PIPE\\ATSVC'): # FIXME PIPE ATSVC COMMAND pass else: diff -ru dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/util.py dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/util.py --- dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.orig/modules/python/dionaea/util.py 2024-07-16 02:09:42.489377417 +0200 +++ dionaea-4e459f1b672a5b4c1e8335c0bff1b93738019215.new/modules/python/dionaea/util.py 2024-07-16 02:08:40.918028567 +0200 @@ -74,14 +74,14 @@ :return: List of urls or None """ from dionaea.core import incident - regex = re.compile(b"\(\)\s*\t*\{.*;\s*\}\s*;") + regex = re.compile(r"\(\)\s*\t*\{.*;\s*\}\s*;") if not regex.search(data): return None logger.debug("Shellshock attack found") urls = [] regex = re.compile( - b"(wget|curl).+(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)" + r"(wget|curl).+(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)" ) for m in regex.finditer(data): logger.debug("Found download command with url %s", m.group("url")) @@ -107,7 +107,7 @@ from dionaea.core import incident urls = [] regex = re.compile( - b"(wget|curl).+(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)" + r"(wget|curl).+(?P(http|ftp|https)://([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)" ) for m in regex.finditer(data): logger.debug("Found download command with url %s", m.group("url"))