Skip to content

Instantly share code, notes, and snippets.

@oxyflour
Created October 17, 2015 06:12
Show Gist options
  • Save oxyflour/907e7375c035b3a66fbc to your computer and use it in GitHub Desktop.
Save oxyflour/907e7375c035b3a66fbc to your computer and use it in GitHub Desktop.
auto authentication script in Guanghua Building
import httplib, urllib, datetime
conn = httplib.HTTPConnection('baidu.com')
conn.request('GET', '/')
response = conn.getresponse()
data = response.read()
conn.close()
if data.find('//10.108.255.12') < 0:
exit()
params = urllib.urlencode({
'username': 'xxxxxx',
'password': 'xxxxxx',
'action': 'login',
'ac_id': '1',
'user_ip': '',
'nas_ip': '',
'user_mac': '',
'ajax': '1',
})
headers = {
'Content-type': 'application/x-www-form-urlencoded',
'Accept': 'text/plain'
}
conn = httplib.HTTPConnection('10.108.255.12')
conn.request('POST', '/include/auth_action.php', params, headers)
response = conn.getresponse()
with open('log.txt', 'a') as f:
f.write('-- ' + str(datetime.datetime.now()) + '\n')
f.write('-- ' + str(response.status) + ' ' + response.reason + '\n')
f.write(response.read() + '\n')
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment