summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-04-17 04:23:02 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-04-17 04:23:02 +0530
commit68f48a85ee96ee60b2d920d08758c69f198ad34b (patch)
tree5f978ffa298cb00d73ba33d12e14757a1d1584df
parentb4f58ec1b4e3cf15c439a9a06ee16d72b64852b0 (diff)
Using netifaces library to get gateway IP Address
-rw-r--r--auto-login.py15
1 files changed, 3 insertions, 12 deletions
diff --git a/auto-login.py b/auto-login.py
index 01bb5b0..5359ef0 100644
--- a/auto-login.py
+++ b/auto-login.py
@@ -1,21 +1,12 @@
import time
import subprocess
-import requests
+import netifaces
w_user=subprocess.run(["pass","wifi-user"], capture_output=True).stdout.decode().strip()
w_pass=subprocess.run(["pass","wifi-pass"], capture_output=True).stdout.decode().strip()
-cmd = "netstat -nr | grep -w 'UG'| awk '{print $2}'"
+#Using netifaces to get gateway
+gateway = netifaces.gateways()['default'][netifaces.AF_INET][0]
-#Better implementation to get the captive portal url
-url = 'http://detectportal.firefox.com/canonical.html'
-expected_response = b'I am not a portal'
-
-response = requests.get(url)
-
-if response.content == expected_response:
- print('Not behind a captive portal')
-else:
- print('Behind a captive portal')
from selenium import webdriver
from selenium.webdriver.common.by import By