Skip to content

Instantly share code, notes, and snippets.

@bmatthewshea
Last active May 9, 2019 02:13
Show Gist options
  • Save bmatthewshea/c038a0d38ce8804ac6eae39ae8f814f3 to your computer and use it in GitHub Desktop.
Save bmatthewshea/c038a0d38ce8804ac6eae39ae8f814f3 to your computer and use it in GitHub Desktop.
Convert EXP SonicWall Settings File to Windows Text
#!/usr/bin/python
# -*- coding: utf-8 -*-
# "Convert Sonicwall Settings EXP to Windows TXT"
# Author: Brady Shea
# Email: Use github user: bmatthewshea or gist comments
# Origin: https://gist.github.com/bmatthewshea/c038a0d38ce8804ac6eae39ae8f814f3
#
# If this script helps you, please consider a small donation!
#
# Buy me a coffee:
# https://www.buymeacoffee.com/vZyT94kE2
#
# BTC 1CmuTLFoApWRxXRaZvpsQ1cC9gdJSef3K6
# ETH 4e06e4080E6043dfF23c8b634712Aca2e1DE4347
# LTC LawZKPgkUc1DJRjdMqH2u8L6cgSMpD8H2E
# XMR 49mRDhPU1qURWT5g9ZPuexELwSr1VUpKMQMPRHTkkezXG3eQ1rHYedkieb7RkzPkVrW9QPm3r6cLA1AuJEDKLrqzRFPyZ79
# Thank you!
#
# USAGE:
# Defaults:
# ./sonicwall-exp2text.py
# Give custom EXP filename:
# ./sonicwall-exp2text.py <filename.exp>
#
import base64, os, sys, subprocess
#defaults
outputFile = './export.txt'
inputFile = './export.exp'
sed_args = 'sed -i \'s/&/\\r\\n&/g\' ' + outputFile
head_args = 'head ' + outputFile
print ""
print "--------------------------"
print "Current File Defaults:"
print "outputFile = " + outputFile
print "inputFile = " + inputFile
print "--------------------------\n"
#remove old conversion file if found
if os.path.exists(outputFile):
print '* Found previous text export file.\n* Removing old file: ' + outputFile + '\n'
os.remove(outputFile)
if len(sys.argv) == 1:
print "* No EXP file found on command line.\n* Using default (" + inputFile + ") as input filename.\n"
else:
inputFile = sys.argv[1]
#Decode
print '* Decoding EXP file ' + '"' + inputFile + '".'
base64.decode(open(inputFile), open(outputFile, "w"))
#Linefeeds
print '* Text file \"' + outputFile + '\" created.\n* Converting to windows linefeeds using: ' + '"' + sed_args + '"' + '\n'
subprocess.call(sed_args, shell=True)
print "Conversion completed.\n"
#Show some of new file:
print "Sample of " + outputFile + ":\n"
subprocess.call(head_args, shell=True)
print "\nExiting."
sys.exit
@bmatthewshea
Copy link
Author

bmatthewshea commented May 8, 2019

SHEA99-2019-05-08_211023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment