Skip to content

Instantly share code, notes, and snippets.

@lts-rad
Last active October 14, 2022 17:45
Show Gist options
  • Save lts-rad/ae48b239e083258a588c8f4bcd059898 to your computer and use it in GitHub Desktop.
Save lts-rad/ae48b239e083258a588c8f4bcd059898 to your computer and use it in GitHub Desktop.
restore passwords from wpa files for SPR
#!/usr/bin/env python3
import json
dev = {}
sae=open("sae_passwords").read()
wpa2=open("wpa2pskfile").read()
def make(mac, password, t):
if mac in dev:
return
d = {}
d["Name"] = ""
d["MAC"] = mac
d["WGPubKey"] = ""
d["VLANTag"] = ""
d["RecentIP"] = ""
d["PSKEntry"] = {"Type": t, "Psk": password}
d["Groups"] = ["wan", "dns"]
d["DeviceTags"] = []
dev[mac] = d
for line in sae.splitlines():
password,mac = line.split("|mac=")
make(mac, password, "sae")
for line in wpa2.splitlines():
mac,password = line.split(" ")
make(mac, password, "wpa2")
open("newdevices.json",'w').write(json.dumps(dev, indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment