Created
January 17, 2017 04:42
-
-
Save ncaq/d79f861d3f159c81098753617112dab2 to your computer and use it in GitHub Desktop.
専修大学のwifiに自動ログインするためのscript
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 python3 | |
from urllib.parse import urlencode | |
import os | |
import pycurl | |
import sys | |
ssid='SENSHUWL' | |
auth_url='https://wcgw.senshu-u.ac.jp/cgi-bin/login' | |
user='ne260258' | |
password=open('/etc/senshu-login.conf').read().rstrip('\n') | |
if(sys.argv[2] == 'up' and os.getenv('CONNECTION_ID') == ssid) : | |
c = pycurl.Curl() | |
c.setopt(c.URL, auth_url) | |
c.setopt(pycurl.REFERER, auth_url) | |
c.setopt(c.POSTFIELDS, urlencode({ 'user' : user, | |
'password' : password, | |
'cmd' : 'authenticate', | |
'Login' : 'Log+In',})) | |
c.perform() | |
c.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment