Commits

gao shuai committed d6b2a92 Draft

成功

Comments (0)

Files changed (10)

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()
+username = '13829107673'
+passwd = '252806'
+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()
+

cmcc_logout_wlan_v.py

+#!/usr/bin/env python
+import cookielib, urllib2,urllib
+import re
+import os
+
+cj = cookielib.CookieJar()
+opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
+
+
+f=file("sec.txt","r")
+sec=f.read()
+f.close()
+
+#logout
+LogOutpostData={}
+
+
+for ce in sec.split("?")[1].split("&"):
+	LogOutpostData[ce.split("=")[0]]=ce.split("=")[1]
+
+LogOutpostData["logouttype"]="TYPESUBMIT"
+
+
+LogOutpostData=urllib.urlencode(LogOutpostData)
+print LogOutpostData
+
+print opener.open('http://221.176.1.140/do_logout.php',LogOutpostData).read()
+
+#!/usr/bin/env python
+import cookielib, urllib2
+import re
+import os
+import random
+import time
+
+username = ''
+passwd = ''
+
+cj = cookielib.CookieJar()
+opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
+
+test = opener.open('http://xiaoxia.org')
+data = test.read()
+userip = re.search(r'NAME="wlanuserip" value="(.+)">', data).group(1)
+acname = re.search(r'NAME="wlanacname" value="(.+)">', data).group(1)
+acip = re.search(r'NAME="wlanacip" value="(.+)">', data).group(1)
+
+url = os.path.join(os.path.dirname(test.url), 'index.jsp')
+data = 'wlanuserip=%s&wlanacname=%s&wlanacip=%s' % (userip, acname, acip)
+print 'opening', url, data
+data = opener.open(url, data).read()
+
+url = os.path.join(os.path.dirname(test.url), 'jsp/do_login.jsp')
+data = 'bpssUSERNAME=%s&bpssBUSPWD=%s&' +\
+ 'Submit=\xb5\xc7\xc2\xbc&bpssLoginType=1' % (username, passwd)
+print 'opening', url, data
+data = opener.open(url, data).read()
+print 'result', data

debug_data/cmcc_selenium.py

+#coding=utf8
+from selenium import webdriver
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.ui import Select
+from selenium.common.exceptions import NoSuchElementException
+import selenium.webdriver.common.keys as keys
+import time, re
+import datetime,os
+CWD=os.getcwd()
+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()
+
+# staticusername:13829107673
+# staticpassword:252806
+driver = webdriver.Firefox()
+driver.implicitly_wait(30)
+base_url = "http://172.18.254.22/"
+verificationErrors = []
+
+driver = driver
+driver.get(base_url)
+
+def l():
+	driver.switch_to_frame("input")
+	driver.find_element_by_id("staticusernameid").clear()
+	driver.find_element_by_id("staticusernameid").send_keys("13829107673")
+	driver.find_element_by_id("staticpasswordid").clear()
+	driver.find_element_by_id("staticpasswordid").send_keys("252806")
+	driver.find_element_by_css_selector("input[type=\"submit\"]").click()
+def g():
+	
+	w("index.php")
+	driver.switch_to_frame("status")
+	w("status.php")

debug_data/index.php.html

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<meta content="text/html; charset=gb2312" http-equiv="Content-Type" />
+<meta content="no-cache" http-equiv="Cache-Control" />
+<title>User Status</title>
+
+<script language="JavaScript">
+function setCookie(name, value, datenum)
+{
+		var expires=new Date();
+		expires.setTime(expires.getTime()+datenum*24*60*60*1000);
+
+		document.cookie=name+"="+escape(value)+"; expires="+expires.toGMTString()+"; path=/; secure";
+
+}
+
+
+
+function popupprovopintro()
+{
+window.open('http://221.176.1.140:80/provopintro.php?pcode=200&amp;key=', 'popup1348151905', 'width=850,height=600,resizable=0 ,status=no,toolbar=no,location=no,menu=no'); 
+}
+//window.onload = popupprovopintro;
+
+</script>
+
+</head>
+<frameset marginheight="0" marginwidth="0" frameborder="0" framespacing="0" border="0" rows="600,*"><frame scrolling="no" marginheight="0" marginwidth="0" name="status" src="http://221.176.1.140:80/user_status.php?username=13829107673&amp;logonsessid=0361.0371.371.00;2012092022382504A1A6;ps060&amp;wlanacip=221.176.119.178&amp;wlanacname=0361.0371.371.00&amp;wlanuserip=111.7.63.111&amp;logintime=2012-09-20%2022:38:25&amp;remaintime=0&amp;areacode=200&amp;wlanacssid=&amp;productid=22&amp;effecttime=20120831%20000000&amp;expiretime=20380101%20000000&amp;keystr=dad2e30fdc65841fce1cded0f6aeeee7713ef3bb731ae0dc&amp;cf=disabled" /><noframes>
+&lt;body&gt;
+&lt;/body&gt;
+</noframes>
+</frameset>
+
+
+</html>

debug_data/input.php.html

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head>
+<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
+<meta http-equiv="Cache-Control" content="no-cache">
+<title>User Status</title>
+
+<script language="JavaScript">
+function setCookie(name, value, datenum)
+{
+		var expires=new Date();
+		expires.setTime(expires.getTime()+datenum*24*60*60*1000);
+
+		document.cookie=name+"="+escape(value)+"; expires="+expires.toGMTString()+"; path=/; secure";
+
+}
+
+
+
+function popupprovopintro()
+{
+window.open('http://221.176.1.140:80/provopintro.php?pcode=200&key=', 'popup1348150987', 'width=850,height=600,resizable=0 ,status=no,toolbar=no,location=no,menu=no'); 
+}
+//window.onload = popupprovopintro;
+
+</script>
+
+</head>
+<frameset rows="600,*" border="0" framespacing="0" frameborder="0" marginwidth="0" marginheight="0"><frame src="http://221.176.1.140:80/user_status.php?username=13829107673&amp;logonsessid=0361.0371.371.00;20120920222307048AE8;ps060&amp;wlanacip=221.176.119.178&amp;wlanacname=0361.0371.371.00&amp;wlanuserip=111.7.63.111&amp;logintime=2012-09-20 22:23:07&amp;remaintime=0&amp;areacode=200&amp;wlanacssid=&amp;productid=22&amp;effecttime=20120831 000000&amp;expiretime=20380101 000000&amp;keystr=dad2e30fdc65841fce1cded0f6aeeee7713ef3bb731ae0dc&amp;cf=disabled" name="status" scrolling="no" marginwidth="0" marginheight="0"><noframes>
+&lt;body&gt;
+&lt;/body&gt;
+</noframes>
+</frameset>
+
+
+</html>

debug_data/sad.html

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
+<meta http-equiv="Cache-Control" content="no-cache">
+<title>User Status</title>
+
+<script LANGUAGE="JavaScript">
+function setCookie(name, value, datenum)
+{
+		var expires=new Date();
+		expires.setTime(expires.getTime()+datenum*24*60*60*1000);
+
+		document.cookie=name+"="+escape(value)+"; expires="+expires.toGMTString()+"; path=/; secure";
+
+}
+
+
+
+function popupprovopintro()
+{
+window.open('http://221.176.1.140:80/provopintro.php?pcode=200&key=', 'popup1348152472', 'width=850,height=600,resizable=0 ,status=no,toolbar=no,location=no,menu=no'); 
+}
+//window.onload = popupprovopintro;
+
+</script>
+
+</head>
+<frameset rows='600,*' border='0' framespacing='0' frameborder=0 marginwidth='0' marginheight='0'><frame src='http://221.176.1.140:80/user_status.php?username=13829107673&logonsessid=0361.0371.371.00;2012092022475204B38A;ps060&wlanacip=221.176.119.178&wlanacname=0361.0371.371.00&wlanuserip=111.7.63.111&logintime=2012-09-20 22:47:52&remaintime=0&areacode=200&wlanacssid=&productid=22&effecttime=20120831 000000&expiretime=20380101 000000&keystr=dad2e30fdc65841fce1cded0f6aeeee7713ef3bb731ae0dc&cf=disabled' name='status' scrolling='no' marginwidth='0' marginheight='0'><noframes>
+<body>
+</body>
+</noframes>
+</frameset>
+
+</html>

debug_data/selenium_auto.py

+from selenium import webdriver
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support.ui import Select
+from selenium.common.exceptions import NoSuchElementException
+import unittest, time, re
+
+class Dd(unittest.TestCase):
+    def setUp(self):
+        self.driver = webdriver.Firefox()
+        self.driver.implicitly_wait(30)
+        self.base_url = "http://221.176.1.140/"
+        self.verificationErrors = []
+    
+    def test_dd(self):
+        driver = self.driver
+        driver.get(self.base_url + "/wlan/index.php?wlanacname=0361.0371.371.00&wlanuserip=111.7.63.111&ssid=CMCC")
+        # ERROR: Caught exception [ERROR: Unsupported command [selectFrame]]
+        driver.find_element_by_id("staticusernameid").clear()
+        driver.find_element_by_id("staticusernameid").send_keys("13829107673")
+        driver.find_element_by_id("staticpasswordid").clear()
+        driver.find_element_by_id("staticpasswordid").send_keys("252806")
+        driver.find_element_by_css_selector("input[type=\"submit\"]").click()
+    
+    def is_element_present(self, how, what):
+        try: self.driver.find_element(by=how, value=what)
+        except NoSuchElementException, e: return False
+        return True
+    
+    def tearDown(self):
+        self.driver.quit()
+        self.assertEqual([], self.verificationErrors)
+
+if __name__ == "__main__":
+    unittest.main()

debug_data/status.php.html

+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"><head>
+<meta content="text/html; charset=gb2312" http-equiv="Content-Type" />
+<title>Portal UserStatus</title>
+<link type="text/css" rel="stylesheet" href="css/wlanPortal.css" />
+<script src="./jsp/clock.js" language="JavaScript1.1"></script>
+<script language="JavaScript">
+&lt;!--
+
+function chgprovince(theform,seltext)
+{
+	var pcode;
+	var plink;
+	if(seltext==null)
+	{
+		return false
+	}
+
+	if(seltext=="S_E_L")
+	{
+		alert("请选择具体省份!");
+		return false;
+	}
+
+	sellist = seltext.split("|");
+	listnum = sellist.length;
+
+	if( listnum != 2)
+	{
+		alert("该省页面参数错误!");
+		return false;
+	}
+	pcode = sellist[0];
+	plink = sellist[1];
+	window.open (plink,'plind',"");
+
+	return true
+}
+
+
+function KeyDown()
+{
+  	if ((event.keyCode ==   8)||            //屏蔽退格删除键
+    	(event.keyCode == 114)||
+    	(event.keyCode == 116)||			//屏蔽 F5 刷新键
+    	(event.keyCode == 122)) 			//屏蔽 F12 刷新键
+    {
+     	event.keyCode=0;
+     	event.returnValue=false;
+     }
+
+	if ((window.event.altKey)&amp;&amp; ((window.event.keyCode==37)||(window.event.keyCode==39))) // 屏蔽 Alt + -&gt; 和 Alt+ &lt;-
+	{
+		event.returnValue=false;
+	}
+
+	if (window.event.ctrlKey ||(event.shiftKey)&amp;&amp;(event.keyCode==121)) //屏蔽 Ctrl 键 和 shift+F10
+	{
+		event.returnValue=false;
+	}
+}
+
+var IsSubmitLogout = 0;
+
+var IsConfirmIsFalse = 0;
+
+function ButtonSubmit(thisform)
+{
+	if( !confirm("请确认下线!") ) 
+	{
+		IsConfirmIsFalse = 1;
+		return false;
+	}
+
+	IsSubmitLogout = 1;
+	thisform.logouttype.value = "TYPESUBMIT";
+
+	thisform.action='do_logout.php';
+	thisform.submit();
+	return true;
+
+}
+
+
+function exitFunc()
+{
+/*
+	if( IsConfirmIsFalse == 1)
+	{
+		return false;
+	}
+*/
+	if(IsSubmitLogout == 1)
+	{
+		return false;
+	}
+
+	//var message = "在本页面直接访问其他网址会造成您非正常下线,如需访问其他网页,请按“取消”按钮,并打开新的IE窗口进行后续访问。";
+var message = "在本页面直接访问其他网址会造成您非正常下线,如需访问其他网页,请按“取消”按钮,并打开新的IE窗口进行后续访问。"; 
+	if (typeof evt == "undefined")
+	{
+		evt = window.event;
+	}
+
+	if (evt)
+	{
+		evt.returnValue = message;
+	}
+
+
+	return true;
+}
+
+
+function RunOnUnload()
+{
+	/*
+	if( IsConfirmIsFalse == 1)
+	{
+		return false;
+	}
+*/
+	if( IsSubmitLogout == 1)
+	{
+		return;
+	}
+
+	var toTop;
+	var toLeft;
+	var sh = screen.height;
+	var sw = screen.width;
+
+	heightStr = 20;
+	widthStr = 250;
+
+
+	toTop  = parseInt((sh - heightStr)/2)-10;
+	toLeft = parseInt((sw - widthStr )/2);
+
+	var sstyle = "width="+widthStr+",height="+heightStr+",resizable=no,scrollbars=0,status=no,toolbar=no,location=no,menu=no,left="+toLeft+",top="+toTop;
+
+	if(document.getElementById("cancelinfoid").checked)
+	{
+	window.open('do_logout.php?logonsessid=0361.0371.371.00;2012092022382504A1A6;ps060&amp;wlanuserip=111.7.63.111&amp;logouttype=URL&amp;cancelinfo=yes&amp;username=13829107673', 'Logout1348151905', sstyle);	}
+	else
+	{
+window.open('do_logout.php?logonsessid=0361.0371.371.00;2012092022382504A1A6;ps060&amp;wlanuserip=111.7.63.111&amp;logouttype=URL&amp;cancelinfo=', 'Logout1348151905', sstyle);	}
+
+	window.top.opener = null;
+
+ 	window.top.open("","_self");
+ 	window.top.close();
+}
+
+
+var onlinetime = 0
+function initFunc()
+{
+	myDate = new Date();
+
+	seconds = (myDate.getTime() + onlinetime*1000 - inittime)/1000
+	updateAllClocks();
+
+	setTimeout('initFunc()',1000);
+}
+
+
+function do_loginself(username)
+{
+
+	var myurl = './do_login_self.php?keystr=dad2e30fdc65841fce1cded0f6aeeee7713ef3bb731ae0dc&amp;username=13829107673&amp;logonsessid=0361.0371.371.00;2012092022382504A1A6;ps060'; 
+	//var myurl1 = myurl+"&amp;irand="+Math.random();
+	//document.getElementById('loginselfid').href=myurl1;
+	document.getElementById('loginselfid').href=myurl;
+}
+
+
+--&gt;
+</script>
+</head>
+<!--
+<body oncontextmenu="window.event.returnValue=false" onkeydown="KeyDown()" onload='initFunc()' onbeforeunload ='exitFunc()' onunload="RunOnUnload()">
+-->
+<body onunload="RunOnUnload()" onbeforeunload="exitFunc()" onload="initFunc()" onkeydown="KeyDown()" oncontextmenu="window.event.returnValue=false">
+<script language="JavaScript1.1">seconds=0</script><div id="wrapper">
+	<div id="header">
+		<h1 class="logo"><strong>欢迎使用“随e行”业务</strong></h1>
+		<div class="worldwide"><a target="_blank" href="./html/serviceInfo.html">业务使用说明</a></div>
+		<div class="clear"></div>
+	</div>
+	<div id="content">
+		<form onsubmit="return false;" action="" method="POST" name="portal">
+			<div class="loginInContent">
+				<h2>用户登录成功</h2>
+				<ul class="login">
+					<li>
+						<label>用户名:</label>
+							13829107673					</li>
+					<li>
+						<label>在线时间:</label>
+						<script language="JavaScript1.1">clock = new Clock(6);</script><img height="20" width="15" border="0" src="images/n0.gif" class="clock" /><img height="20" width="15" border="0" src="images/n0.gif" class="clock" /><img height="20" width="9" border="0" src="images/col.gif" class="clock" /><img height="20" width="15" border="0" src="images/n0.gif" class="clock" /><img height="20" width="15" border="0" src="images/n0.gif" class="clock" /><img height="20" width="9" border="0" src="images/col.gif" class="clock" /><img height="20" width="15" border="0" src="images/n0.gif" class="clock" /><img height="20" width="15" border="0" src="http://221.176.1.140/images/n2.gif" class="clock" />
+					</li>
+					<li>
+						<label>套餐信息:</label>
+						<p>
+您当前使用的是WLAN标准资费,按0.05元/分钟收取WLAN上网费用<!--
+						套餐种类/剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间剩余时间或到期时间
+-->
+						</p><p>
+					</p></li>
+					<li>
+						<input type="checkbox" disabled="disabled" value="yes" id="cancelinfoid" name="cancelinfo" />
+						取消自动登录功能(点击下线按钮后生效)
+					</li>
+					<li style="color:#C00; font-weight:bold; font-size:14px;">
+						请点击下线按钮完成下线操作,否则会造成非正常下线,给您的使用造成不便。
+					</li>
+					<li class="loginCtrl">
+						<input type="button" onclick="ButtonSubmit(this.form)" value="下 线" />
+					</li>
+					<li class="center">
+						<a target="_blank" onclick='do_loginself("13829107673")' href="" id="loginselfid">用户自服务</a>
+					</li>
+				</ul>
+			</div>
+
+ <input type="hidden" value="13829107673" name="username" /> 
+ <input type="hidden" value="2012-09-20 22:38:25" name="logintime" /> 
+ <input type="hidden" value="0" name="remaintime" /> 
+ <input type="hidden" value="200" name="areacode" /> 
+ <input type="hidden" value="221.176.119.178" name="wlanacip" /> 
+ <input type="hidden" value="0361.0371.371.00" name="wlanacname" /> 
+ <input type="hidden" value="111.7.63.111" name="wlanuserip" /> 
+ <input type="hidden" value="22" name="productid" /> 
+ <input type="hidden" value="20120831 000000" name="effecttime" /> 
+ <input type="hidden" value="20380101 000000" name="expiretime" /> 
+ <input type="hidden" value="dad2e30fdc65841fce1cded0f6aeeee7713ef3bb731ae0dc" name="keystr" /> 
+ <input type="hidden" value="disabled" name="cf" /> 
+ <input type="hidden" value="" name="logouttype" /> 
+ <input type="hidden" value="0361.0371.371.00;2012092022382504A1A6;ps060" name="logonsessid" /> 
+		</form>
+	</div>
+	<div id="footer"><span class="fR">
+		<a target="_blank" href="http://www.miibeian.gov.cn">京ICP备05002571号</a>|中国移动通信版权所有</span>
+	</div>
+</div>
+
+
+</body></html>
-http://221.176.1.140:80/cmcc_mobile_user_status.php?username=18229467518&logonsessid=0361.0371.371.00;201209190352201B039B;ps001&wlanacip=221.176.119.178&wlanacname=0361.0371.371.00&wlanuserip=111.7.61.168&logintime=2012-09-19 03:52:20&remaintime=0&areacode=731&wlanacssid=&productid=22&effecttime=20110907 000000&expiretime=20380101 000000&keystr=9ea6cb84cc9adf025ee3e56fa0a78a043e57d3735b3fd6f0&cf=disabled&ualistindex=UA0999
+http://221.176.1.140:80/user_status.php?username=13829107673&logonsessid=0361.0371.371.00;2012092022550804BAAA;ps060&wlanacip=221.176.119.178&wlanacname=0361.0371.371.00&wlanuserip=111.7.63.111&logintime=2012-09-20 22:55:08&remaintime=0&areacode=200&wlanacssid=&productid=22&effecttime=20120831 000000&expiretime=20380101 000000&keystr=dad2e30fdc65841fce1cded0f6aeeee7713ef3bb731ae0dc&cf=disabled
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.