bkerler / netgear_telnet

Netgear Enable Telnet (New Crypto)
MIT License
126 stars 34 forks source link

Syntax error using Python 3.12.1 #40

Closed RDHWalker closed 5 months ago

RDHWalker commented 9 months ago

Syntax error as shown below under Python version 3.12.1:

C:\Users\rdhw>python \local\bin\telnet-enable.py 192.168.XXX.1 C8:9E:43:XX:XX:XX admin XXXXXXXXXX
C:\local\bin\telnet-enable.py:50: SyntaxWarning: invalid escape sequence '\s'
  for v in (re.split('\s+', i) for i in arp_data_raw))
C:\local\bin\telnet-enable.py:660: SyntaxWarning: invalid escape sequence '\s'
  for line in re.findall('([-.0-9]+)\s+([-0-9a-f]{17})\s+(\w+)', data):
Netgear Telnet enabler V3.1 (c) B.Kerler 2021-2023
Done sending pw data XXXXXXXXXX to 192.168.XXX.1:23
Iliasbrv commented 9 months ago

I get the same error on my RAX70 on Win11 but not on Linux...

halden2714 commented 9 months ago

Same here with RAXE500 on firmware 1.2.13.100_2.0.54.

sshirey76 commented 5 months ago

You should be able to address this by editing your 49-50 From: parsed_arp_table = (dict(zip(('ip_address', 'type', 'flags', 'hw_address', 'mask', 'device'), v)) for v in (re.split('\s+', i) for i in arp_data_raw)) To: parsed_arp_table = [dict(zip(('ip_address', 'type', 'flags', 'hw_address', 'mask', 'device'), v)) for v in (re.split(r'\s+', i) for i in arp_data_raw)]

For the referenced at your 660: From: for line in re.findall('([-.0-9]+)\s+([-0-9a-f]{17})\s+(\w+)', data): To: for line in re.findall(r'([[-.0-9]]+)\s+([-0-9a-f]{17})\s+(\w+)', data):

They are caused by the way the backslash character \ is used in the regular expression patterns. Example on the 2nd error.. In the pattern '([-.0-9]+)\s+([-0-9a-f]{17})\s+(\w+)', the \s is interpreted as an invalid escape sequence because the backslash \ is not being treated as a literal character. To fix this issue, you use a raw string literal by prefixing the pattern with r. This way, backslashes \ are treated as literal characters, and you don't need to escape them. Hope it helps someone!

bkerler commented 5 months ago

Fixed in PR #47

Pawel-B7 commented 5 months ago

Doesn't work after reboot on LBR20 :(