Last active
June 9, 2020 00:44
-
-
Save drygdryg/f2404176683f5243235d8b0590c0730b to your computer and use it in GitHub Desktop.
Convert OneShot report files to single Router Scan CSV table easily
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import csv | |
from datetime import datetime | |
if __name__ == '__main__': | |
table_header = ['IP Address', 'Port', 'Time (ms)', 'Status', | |
'Authorization', 'Server name / Realm name / Device type', | |
'Radio Off', 'Hidden', 'BSSID', 'ESSID', 'Security', | |
'Key', 'WPS PIN', 'LAN IP Address', 'LAN Subnet Mask', | |
'WAN IP Address', 'WAN Subnet Mask', 'WAN Gateway', | |
'Domain Name Servers', 'Latitude', 'Longitude', 'Comments'] | |
parser = argparse.ArgumentParser( | |
description='Convert OneShot reports to the Router Scan CSV table easily' | |
) | |
parser.add_argument( | |
'infile', | |
type=argparse.FileType('r'), | |
help='OneShot CSV reports file (stored.csv)' | |
) | |
parser.add_argument( | |
'outfile', | |
nargs='?', | |
type=str, | |
default=f'report-{datetime.now().strftime("%d-%m-%Y_%I-%M_%p")}.csv', | |
help='Router Scan output CSV file' | |
) | |
args = parser.parse_args() | |
r = csv.reader(args.infile, delimiter=';') | |
wr = csv.writer(open(args.outfile, 'w'), delimiter=';', quoting=csv.QUOTE_ALL) | |
next(r) # Skip header | |
wr.writerow(table_header) | |
for row in r: | |
record = ['192.168.1.1', '80', '0', 'Done', '', '', '', '', row[1], row[2], | |
('WPA/WPA2' if row[4] else 'None'), (row[4] if row[4] else '<empty>'), | |
row[3], '', '', '', '', '', '', '', '', ''] | |
wr.writerow(record) | |
print(f'Data was written to {args.outfile}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment