cmcc / cmcc_login_wlan_v.py

#!/usr/bin/env python
# http://221.176.1.140/wlan/index.php?wlanacname=0361.0371.371.00&wlanuserip=111.7.63.111&ssid=CMCC
import cookielib, urllib2,urllib
import re
import os
import datetime,os
CWD=os.getcwd()

_f=file(os.path.join(CWD,"config.txt"),"r")
CONFIG=_f.readlines()
_f.close()
username=CONFIG[0].strip()
passwd=CONFIG[1].strip()

def w(name):
	_f=file(os.path.join(CWD,name+".html"),"w+")
	_f.write(driver.page_source.encode("utf8"))
	print driver.page_source.encode("utf8")
	_f.close()

cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))

test = opener.open('http://xiaoxia.org')
index = opener.open(test.url).read()
print test.url
sec=re.findall('window.location="(.*)"',index)[0]
print sec

log_in_url="https://221.176.1.140/do_login.php"
wlanuserip=''
wlanacname=''

print sec
for i in sec.split("?")[1].split("&"):
	print i
	print i.split("=")
	if i.split("=")[0]=="wlanuserip":
		wlanuserip=i.split("=")[1]
	if i.split("=")[0]=="wlanacname":
		wlanacname=i.split("=")[1]
	if i.split("=")[0]=="wlanacip":
		wlanacip=i.split("=")[1]
LogInpostData=\
{"staticusername" : username,\
"staticpassword" :passwd,\
"loginmode":"static",\
"wlanacname":wlanacname,
"wlanuserip":wlanuserip,
"wlanacip":wlanacip,
"wlanacssid":"CMCC",
"ualistindex":"UA0999"}
LogInpostData=urllib.urlencode(LogInpostData)

log_in=opener.open(log_in_url,LogInpostData)
print log_in.url
index=log_in.read()

sec=re.findall("""<frame src='(.*)' name='status'""",index)[0]
print sec

f=file("sec.txt","w+")
f.write(sec)
f.close()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.