Last active
August 22, 2020 01:24
-
-
Save Steve-Tech/aef02836011ed84990a297a9783cdd7f to your computer and use it in GitHub Desktop.
Python Telstra Air Connector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "[email protected]" | |
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=(.*)&',login)[0] | |
ipaddr = re.findall(r'uamip=(.*)&',login)[0] | |
port = re.findall(r'uamport=(.*)&',login)[0] | |
macaddr = re.findall(r'mac=(.*)&',login)[0] | |
challenge = re.findall(r'challenge=(.*)&',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'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
Thanks @Steve-Tec - this is great! Thank you for working out the auth flow :)
I had some trouble with HTML-encoding on the Telstra Air AP I was connecting to and changed the parsing a little - this is what is working for me: