Skip to content

Instantly share code, notes, and snippets.

@cooliscool
Last active August 31, 2021 01:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cooliscool/4bc4a3710e07f40ab720901c71c57796 to your computer and use it in GitHub Desktop.
Save cooliscool/4bc4a3710e07f40ab720901c71c57796 to your computer and use it in GitHub Desktop.
Approve Netaccess automatically ( for IIT Madras ).
#!/usr/bin/env python
import requests
import sys
import getpass
username = 'aexxxxxx'
print ('LDAP pass ')
pa = str(getpass.getpass())
with requests.session() as s:
page = s.post('https://netaccess.iitm.ac.in/account/login' , data={ 'userLogin':username, 'userPassword':pa, 'submit':''})
if page.text.find('MAC') != -1:
approve = s.post('https://netaccess.iitm.ac.in/account/approve', data = { 'duration':'2' , 'approveBtn':''})
if approve.text.find('MAC') != -1:
print 'done'
else:
print 'error'
else:
print 'error'
sys.exit()
'''
Author : Mohammed Ajmal
GNU Public License
-------
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