Skip to content

Instantly share code, notes, and snippets.

@Hodgegoblin
Last active July 19, 2019 14:13
Show Gist options
  • Save Hodgegoblin/f0f9a224873c4601276a989ebb770bc7 to your computer and use it in GitHub Desktop.
Save Hodgegoblin/f0f9a224873c4601276a989ebb770bc7 to your computer and use it in GitHub Desktop.
# Cisco Wireless Capture Network Access Script
# version 0.1b - Hodge 27 Feb 2018
#
#
# Script selects a random user agent string then sends form data to captive portal host to authenticate workstaion on network.
#
captivePortal = "http://1.1.1.1"
import requests
from random import choice
# Array of user agents to choose from
desktop_agents = ['Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/602.2.14 (KHTML, like Gecko) Version/10.0.1 Safari/602.2.14',
'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.71 Safari/537.36',
'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36',
'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0']
# Select a random agent and generate the http headers
def random_headers():
return {'User-Agent': choice(desktop_agents),'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8'}
# Android internet test expected result is HTTP reponse code 204, anything else captive portal or error
if requests.get("http://clients3.google.com/generate_204").status_code != 204:
r = requests.post(captivePortal, headers = random_headers(), data = {'buttonClicked' : '4', 'redirect_url' : '', 'err_flag' : '0'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment