summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaumit Dinesan <justsaumit@protonmail.com>2023-04-17 04:09:07 +0530
committerSaumit Dinesan <justsaumit@protonmail.com>2023-04-17 04:09:07 +0530
commitb4f58ec1b4e3cf15c439a9a06ee16d72b64852b0 (patch)
treedda906fbeb5207c49fb256591a2ae6d6454adf98
parent7e94b240b88b29a5868b831b0392a1cfb20149b4 (diff)
Using detectportal.firefox.com used by firefox to detect captive portal through requests
-rw-r--r--auto-login.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/auto-login.py b/auto-login.py
index 36b7fa0..01bb5b0 100644
--- a/auto-login.py
+++ b/auto-login.py
@@ -1,11 +1,21 @@
import time
import subprocess
+import requests
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}'"
-pipedps=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.STDOUT)
-gateway=pipedps.communicate()[0].decode().strip()
+
+#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