-
-
Save sanjeed5/5f1c462ad858138febdd6e5ccad9c0e5 to your computer and use it in GitHub Desktop.
Approve Netaccess automatically ( for IIT Madras ).
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
#!/usr/bin/env python | |
import requests | |
import sys | |
import getpass | |
username = input('Enter username: ') | |
pa = str(getpass.getpass(prompt='Enter password: ')) | |
with requests.session() as s: | |
try: | |
page = s.post('https://netaccess.iitm.ac.in/account/login' , data={ 'userLogin':username, 'userPassword':pa, 'submit':''}, verify=False) | |
except Exception as err: | |
print('Authentication Error: \n', err) | |
if page.text.find('MAC') != -1: | |
try: | |
approve = s.post('https://netaccess.iitm.ac.in/account/approve', data = { 'duration':'2' , 'approveBtn':''}, verify=False) | |
except Exception as err: | |
print('Approve error: \n', err) | |
if approve.text.find('MAC') != -1: | |
print('done') | |
else: | |
print('error') | |
else: | |
print('Authentication Error') | |
sys.exit() | |
''' | |
------- | |
Usage | |
------- | |
NB : You have to install requests in python by using command ` sudo pip install requests ` in terminal. | |
1. Change your username in the variable | |
2. Give permissions for the python script to execute independently by typing ` chmod +x netaccess.py ` in terminal. | |
3. Execute typing ` netaccess.py ` | |
4. Type your password when prompted | |
5. Add the script folder to $PATH variable in ~/.bashrc for executing the script everywhere irrespective of the working directory. | |
In the end you should be able to get the thing working typing ` netaccess.py ` in terminal. | |
''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment