Advertisement
SnoopSheep2001

maal

Mar 21st, 2023
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. import subprocess
  2. import requests
  3. import sys
  4.  
  5. print("program running _-_-_-_-_-_-_-_-_-_-_-----____")
  6.  
  7. url = "http://127.0.0.1:8000/ssid"
  8. res = requests.get(url)
  9.  
  10.  
  11. if res.status_code == 200:
  12. data = res.json()
  13. print(data)
  14.  
  15. new_ssid = data
  16. subprocess.run(["systemctl", "start", "hostapd"])
  17. result = subprocess.run(["iwgetid", "-r"], capture_output=True, text=True)
  18. ossid = result.stdout.strip()
  19.  
  20. if new_ssid == ossid:
  21. sys.exit(1)
  22.  
  23. else:
  24. subprocess.run(["systemctl", "stop", "hostapd"])
  25.  
  26. with open("/etc/hostapd.conf", "r") as f:
  27. lines = f.readlines()
  28.  
  29.  
  30. for i in range(len(lines)):
  31. if lines[i].startswith("ssid="):
  32. lines[i] = f"ssid={new_ssid}\n"
  33. break
  34.  
  35. with open("/etc/hostapd.conf", "w") as f:
  36. f.writelines(lines)
  37.  
  38.  
  39.  
  40. else:
  41. print(f"Failed to get SSID from {url}. Status code: {res.status_code}")
  42.  
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement