Skip to content

Instantly share code, notes, and snippets.

@boringcactus
Last active Jan 27, 2019
Embed
What would you like to do?
wifi defucker for windows

wifi defucker

my wifi is fucked. this helps me defuck it.

λ python defuck.py <my wifi>
  Up....for 4 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up....................for 20 seconds
Down....for 4 seconds
  Up...for 3 seconds
Down....for 4 seconds
  Up....for 4 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up.for 1 seconds
Down.for 1 seconds
  Up.........for 9 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up....................for 20 seconds
Down....for 4 seconds
  Up.............for 13 seconds
Down....for 4 seconds
  Up....for 4 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up.for 1 seconds
Down.for 1 seconds
  Up..................for 18 seconds
Down...for 3 seconds
  Up....for 4 seconds
Down...for 3 seconds
  Up.....for 5 seconds
Down....for 4 seconds
  Up....for 4 seconds
Down....for 4 seconds
  Up...for 3 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up.....................for 21 seconds
Down...for 3 seconds
  Up....
from time import sleep
import sys
import requests
import subprocess
if len(sys.argv) < 2:
print("Usage: python defuck.py <profile, from netsh wlan show profiles>")
sys.exit(1)
profile = sys.argv[1]
failures = 0
successes = 0
while True:
try:
requests.get("http://example.org", timeout=0.5)
if successes == -1:
print("for", failures, "seconds", flush=True)
successes += 1
if successes == 0:
print(" Up", end="", flush=True)
successes += 1
failures = -1
print(".", end="", flush=True)
except requests.exceptions.Timeout:
if failures == -1:
print("for", successes, "seconds", flush=True)
failures += 1
if failures == 0:
print("Down", end="", flush=True)
failures += 1
successes = -1
if failures >= 10:
print("for", failures, "seconds!", flush=True)
failures = -1
print("Disconnecting... ", end="", flush=True)
subprocess.call(["netsh", "wlan", "disconnect"])
print("Connecting... ", end="", flush=True)
subprocess.call(["netsh", "wlan", "connect", "name=" + profile])
successes = 0
else:
print(".", end="", flush=True)
except requests.exceptions.ConnectionError:
pass
sleep(1)
Down....for 4 seconds
  Up....for 4 seconds
Down....for 4 seconds
  Up...for 3 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up.....................for 21 seconds
Down....for 4 seconds
  Up...for 3 seconds
Down.....for 5 seconds
  Up...for 3 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up....................for 20 seconds
Down....for 4 seconds
  Up...for 3 seconds
Down....for 4 seconds
  Up....for 4 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up...................for 19 seconds
Down...for 3 seconds
  Up.....for 5 seconds
Down....for 4 seconds
  Up....for 4 seconds
Down...for 3 seconds
  Up...for 3 seconds
Down.for 1 seconds
  Up...................for 19 seconds
Down....for 4 seconds
  Up....for 4 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up.....................for 21 seconds
Down....for 4 seconds
  Up...for 3 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up....................for 20 seconds
Down...for 3 seconds
  Up.....for 5 seconds
Down....for 4 seconds
  Up...for 3 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up.....................for 21 seconds
Down....for 4 seconds
  Up...for 3 seconds
Down....for 4 seconds
  Up....for 4 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up.....................for 21 seconds
Down...for 3 seconds
  Up.....for 5 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up....................for 20 seconds
Down....for 4 seconds
  Up....for 4 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up....................for 20 seconds
Down....for 4 seconds
  Up.............for 13 seconds
Down.........for 10 seconds!
Disconnecting... Disconnection request was completed successfully for interface "Wi-Fi".
Connecting... Connection request was completed successfully.
  Up....................for 20 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment