Skip to content

Instantly share code, notes, and snippets.

@ghuntley
Forked from Steve-Tech/TelstraAirConnect.py
Created August 22, 2020 01:24
Show Gist options
  • Save ghuntley/d0ff2d039b595ca376b8e66238741c8b to your computer and use it in GitHub Desktop.
Save ghuntley/d0ff2d039b595ca376b8e66238741c8b to your computer and use it in GitHub Desktop.
Python Telstra Air Connector
import requests
import re
session = requests.Session()
# This isn't your Telstra ID but rather the Fon credentials found in the Telstra Air app, you can also find this in the network tab of inspect element when logging in normally.
anid = "m61400000000@wifi.telstra.com"
anidpassword = ""
try: login = re.findall(r'<LoginURL>(.*)</LoginURL>', session.get("http://msftconnecttest.com/redirect").text)[0] # Get the Telstra Air login URL
except IndexError: print("Already Connected"); exit()
# Get the required parameters to login
nasid = re.findall(r'nasid=(.*)&amp;',login)[0]
ipaddr = re.findall(r'uamip=(.*)&amp;',login)[0]
port = re.findall(r'uamport=(.*)&amp;',login)[0]
macaddr = re.findall(r'mac=(.*)&amp;',login)[0]
challenge = re.findall(r'challenge=(.*)&amp;',login)[0]
print(login, nasid, ipaddr, port, macaddr, challenge)
print("Attempting to Connect")
# Put the required parameters into the login URL
loginURL = f"https://telstra.portal.fon.com/jcp/telstra?res=vnp-login&nasid={nasid}&uamip={ipaddr}&uamport={port}&mac={macaddr}&challenge={challenge}&ANID={anid}&ANIDPASSWORD={anidpassword}"
loggingIn = session.get(loginURL)
try: print("Error:", re.findall(r'<div class="error">.*\n.*<span>(.*)</span>', loggingIn.text)[0])
except IndexError: pass
if loggingIn.text.find("You&#39;re connected!") and re.findall(r'<LogoffURL>(.*)</LogoffURL>', loggingIn.text):
print("You're connected!")
print("LogoffURL:", re.findall(r'<LogoffURL>(.*)</LogoffURL>', loggingIn.text)[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment