lgandx / Responder

Responder is a LLMNR, NBT-NS and MDNS poisoner, with built-in HTTP/SMB/MSSQL/FTP/LDAP rogue authentication server supporting NTLMv1/NTLMv2/LMv2, Extended Security NTLMSSP and Basic HTTP authentication.
GNU General Public License v3.0
5.48k stars 776 forks source link

Fixed 'SyntaxWarning: invalid escape sequence' for Python 3.12+ #261

Closed exploide closed 10 months ago

exploide commented 11 months ago

When using Python 3.12 it emits several SyntaxWarning: invalid escape sequence because there were some strings containing backslashes without being an actual escape character like \n. This is e.g. common for regular expressions.

I fixed this by using raw strings where appropriate and escaped the backslash when a literal backslash is desired.

Before, it looked like this:

> sudo ./Responder.py -I enp1s0 -A
/home/user/repos/Responder/utils.py:183: SyntaxWarning: invalid escape sequence '\.'
  regex = "(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))"
/home/user/repos/Responder/settings.py:246: SyntaxWarning: invalid escape sequence '\ '
  print(utils.color("/!\ Warning: %s: file not found" % self.Html_Filename, 3, 1))
/home/user/repos/Responder/settings.py:249: SyntaxWarning: invalid escape sequence '\ '
  print(utils.color("/!\ Warning: %s: file not found" % self.Exe_Filename, 3, 1))
                                         __
  .----.-----.-----.-----.-----.-----.--|  |.-----.----.
  |   _|  -__|__ --|  _  |  _  |     |  _  ||  -__|   _|
  |__| |_____|_____|   __|_____|__|__|_____||_____|__|
                   |__|

           NBT-NS, LLMNR & MDNS Responder 3.1.3.0

  To support this project:
  Patreon -> https://www.patreon.com/PythonResponder
  Paypal  -> https://paypal.me/PythonResponder

  Author: Laurent Gaffie (laurent.gaffie@gmail.com)
  To kill this script hit CTRL-C

[+] Poisoners:
    LLMNR                      [OFF]
    NBT-NS                     [OFF]
    MDNS                       [OFF]
    DNS                        [ON]
    DHCP                       [OFF]

[+] Servers:
    HTTP server                [ON]
    HTTPS server               [ON]
    WPAD proxy                 [OFF]
    Auth proxy                 [OFF]
    SMB server                 [ON]
    Kerberos server            [ON]
    SQL server                 [ON]
    FTP server                 [ON]
    IMAP server                [ON]
    POP3 server                [ON]
    SMTP server                [ON]
    DNS server                 [ON]
    LDAP server                [ON]
    MQTT server                [ON]
    RDP server                 [ON]
    DCE-RPC server             [ON]
    WinRM server               [ON]
    SNMP server                [OFF]

[+] HTTP Options:
    Always serving EXE         [OFF]
    Serving EXE                [OFF]
    Serving HTML               [OFF]
    Upstream Proxy             [OFF]

[+] Poisoning Options:
    Analyze Mode               [ON]
    Force WPAD auth            [OFF]
    Force Basic Auth           [OFF]
    Force LM downgrade         [OFF]
    Force ESS downgrade        [OFF]

[+] Generic Options:
    Responder NIC              [enp1s0]
    Responder IP               [192.168.122.8]
    Responder IPv6             [fe80::f176:78b0:e882:a16]
    Challenge set              [random]
    Don't Respond To Names     ['ISATAP', 'ISATAP.LOCAL']

[+] Current Session Variables:
    Responder Machine Name     [WIN-54XBQZXBKCJ]
    Responder Domain Name      [HF15.LOCAL]
    Responder DCE-RPC Port     [49734]

[+] Listening for events...

/home/user/repos/Responder/packets.py:218: SyntaxWarning: invalid escape sequence '\W'
  SplitFQDN =  re.split('\W+', DNSName) # split the ldap.tcp.blah.blah.blah.domain.tld
[Analyze mode: ICMP] You can ICMP Redirect on this network.
[Analyze mode: ICMP] This workstation (192.168.122.8) is not on the same subnet than the DNS server (127.0.0.53).
[Analyze mode: ICMP] Use `python tools/Icmp-Redirect.py` for more details.
/home/user/repos/Responder/servers/SMB.py:212: SyntaxWarning: invalid escape sequence '\?'
  if data[8:10] == b"\x72\x00" and re.search(b"SMB 2.\?\?\?", data):
/home/user/repos/Responder/servers/SMB.py:250: SyntaxWarning: invalid escape sequence '\?'
  if data[8:10] == b'\x72\x00' and data[4:5] == b'\xff' and re.search(b'SMB 2.\?\?\?', data) == None:
[+] Responder is in analyze mode. No NBT-NS, LLMNR, MDNS requests will be poisoned.
[!] Error starting TCP server on port 53, check permissions or other servers running.
[+] Exiting...
lgandx commented 10 months ago

Good catch, merged