Monday, December 21, 2020

Export SonicWALL config to text

Needed a way to export the SonicWALL config file to plane text.

It did not work correctly with Python3.

PS C:\support\fw> python.exe .\ .\sonicwall-NSA_2600.exp
  File ".\", line 454
    print ""

I found the 2to3.exe tool in the Python tools directory.

Made a copy of the file
.\copy C:\temp\ C:\temp\ 

Ran the tool
.\2to3.exe C:\temp\ -w

After converting with 2to3.exe tool still received a error

python.exe .\ .\sonicwall-NSA_2600.exp

Traceback (most recent call last):
  File ".\", line 14, in <module>
    decoded_data =  decoded_data.split("&")
TypeError: a bytes-like object is required, not 'str'

A little research found we needed to convert the byte-like object to string
decoded_data = decoded_data.decode(encoding="utf-8"# Python 3

After the update the parser worked without issue.
python.exe .\ .\sonicwall-NSA_2600.exp  >test.txt

I posted the updated files on GitHub

No comments:

Post a Comment