Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess
- import requests
- import sys
- print("program running _-_-_-_-_-_-_-_-_-_-_-----____")
- url = "http://127.0.0.1:8000/ssid"
- res = requests.get(url)
- if res.status_code == 200:
- data = res.json()
- print(data)
- new_ssid = data
- subprocess.run(["systemctl", "start", "hostapd"])
- result = subprocess.run(["iwgetid", "-r"], capture_output=True, text=True)
- ossid = result.stdout.strip()
- if new_ssid == ossid:
- sys.exit(1)
- else:
- subprocess.run(["systemctl", "stop", "hostapd"])
- with open("/etc/hostapd.conf", "r") as f:
- lines = f.readlines()
- for i in range(len(lines)):
- if lines[i].startswith("ssid="):
- lines[i] = f"ssid={new_ssid}\n"
- break
- with open("/etc/hostapd.conf", "w") as f:
- f.writelines(lines)
- else:
- print(f"Failed to get SSID from {url}. Status code: {res.status_code}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement