patator icon indicating copy to clipboard operation
patator copied to clipboard

invalid escape sequences

Open fabpiaf opened this issue 1 year ago • 1 comments

/usr/bin/patator:27: SyntaxWarning: invalid escape sequence '\w'
  '''
/usr/bin/patator:2674: SyntaxWarning: invalid escape sequence '\w'
  ('prompt_re', 'regular expression to match prompts [\w+:]'),
/usr/bin/patator:2687: SyntaxWarning: invalid escape sequence '\w'
  def execute(self, host, port='23', inputs=None, prompt_re='\w+:', timeout='20', persistent='0'):
/usr/bin/patator:3361: SyntaxWarning: invalid escape sequence '\w'
  ('prompt_re', 'regular expression to match prompts [\w+:]'),
/usr/bin/patator:3383: SyntaxWarning: invalid escape sequence '\w'
  def execute(self, host, port='513', luser='root', user='', password=None, prompt_re='\w+:', timeout='10', persistent='0'):
/usr/bin/patator:4254: SyntaxWarning: invalid escape sequence '\d'
  m = re.search(' Authentication only, exit status (\d+)', err)
/usr/bin/patator:4971: SyntaxWarning: invalid escape sequence '\('
  mesg = 'Handshake returned: %s (%s)' % (re.search('SA=\((.+) LifeType', out).group(1), re.search('\t(.+) Mode Handshake returned', out).group(1))

I'd suggest:

diff --git a/patator.py b/patator.py
index 606bbe1..a70d2a4 100755
--- a/patator.py
+++ b/patator.py
@@ -449,7 +449,7 @@ $ http_fuzz url='http://10.0.0.1/login?username=admin&password=_@@_FILE0_@@_' -e
   (b) Use regular expressions to extract the nonces that are to be submitted along the main request.
 ---------
 $ http_fuzz url=http://10.0.0.1/login method=POST body='user=admin&pass=FILE0&nonce1=_N1_&nonce2=_N2_' 0=passwords.txt accept_cookie=1 \
- before_urls=http://10.0.0.1/index before_egrep='_N1_:<input type="hidden" name="nonce1" value="(\w+)"|_N2_:name="nonce2" value="(\w+)"'
+ before_urls=http://10.0.0.1/index before_egrep='_N1_:<input type="hidden" name="nonce1" value="(\\w+)"|_N2_:name="nonce2" value="(\\w+)"'
  (a)                               (b)
 
 * Test the OPTIONS method against a list of URLs.
@@ -2671,7 +2671,7 @@ class Telnet_login(TCP_Cache):
     ('host', 'target host'),
     ('port', 'target port [23]'),
     ('inputs', 'list of values to input'),
-    ('prompt_re', 'regular expression to match prompts [\w+:]'),
+    ('prompt_re', 'regular expression to match prompts [\\w+:]'),
     ('timeout', 'seconds to wait for a response and for prompt_re to match received data [20]'),
     )
   available_options += TCP_Cache.available_options
@@ -2684,7 +2684,7 @@ class Telnet_login(TCP_Cache):
 
     return TCP_Connection(fp)
 
-  def execute(self, host, port='23', inputs=None, prompt_re='\w+:', timeout='20', persistent='0'):
+  def execute(self, host, port='23', inputs=None, prompt_re=r'\w+:', timeout='20', persistent='0'):
 
     with Timing() as timing:
       fp, _ = self.bind(host, port, timeout=timeout)
@@ -3358,7 +3358,7 @@ class Rlogin_login(TCP_Cache):
     ('luser', 'client username [root]'),
     ('user', 'usernames to test'),
     ('password', 'passwords to test'),
-    ('prompt_re', 'regular expression to match prompts [\w+:]'),
+    ('prompt_re', 'regular expression to match prompts [\\w+:]'),
     ('timeout', 'seconds to wait for a response and for prompt_re to match received data [10]'),
     )
   available_options += TCP_Cache.available_options
@@ -3380,7 +3380,7 @@ class Rlogin_login(TCP_Cache):
 
     return TCP_Connection(fp)
 
-  def execute(self, host, port='513', luser='root', user='', password=None, prompt_re='\w+:', timeout='10', persistent='0'):
+  def execute(self, host, port='513', luser='root', user='', password=None, prompt_re=r'\w+:', timeout='10', persistent='0'):
 
     fp, _ = self.bind(host, port, timeout=int(timeout))
 
@@ -4251,7 +4251,7 @@ class RDP_login:
       code = p.returncode
 
     mesg = []
-    m = re.search(' Authentication only, exit status (\d+)', err)
+    m = re.search(r' Authentication only, exit status (\d+)', err)
     if m:
       mesg.append(('exit', m.group(1)))
     m = re.search(' (ERR.+?) ', err)
@@ -4968,7 +4968,7 @@ class IKE_enum:
 
     has_sa = 'SA=(' in out
     if has_sa:
-      mesg = 'Handshake returned: %s (%s)' % (re.search('SA=\((.+) LifeType', out).group(1), re.search('\t(.+) Mode Handshake returned', out).group(1))
+      mesg = 'Handshake returned: %s (%s)' % (re.search(r'SA=\((.+) LifeType', out).group(1), re.search(r'\t(.+) Mode Handshake returned', out).group(1))
     else:
       try:
         mesg = out.strip().split('\n')[1].split('\t')[-1]

fabpiaf avatar Sep 03 '24 08:09 fabpiaf

Please update

DarkSkull91 avatar May 30 '25 10:05 DarkSkull91