Commits

gao shuai committed 172bb90 Draft

clean

  • Participants
  • Parent commits c1e68e9

Comments (0)

Files changed (6)

lua/cmcc_Login.lua

--------------------------------------------------------------------------------
--- LuaSocket connector
--- Facepunch Lua API
--- Authors: Andrew McWatters
---			Gran PC
---			Gregor Steiner
--------------------------------------------------------------------------------
--- a small problem:
--- URL mast with http://,
- 
-local error = error
-local http = require( "socket.http" )
-local ltn12 = require( "ltn12" )
-local string = string
-local table = table
- 
-facepunch={}
-facepunch.http={}
- 
-function facepunch.http.get( URL, session )
-	local t = {}
-	local cookie = nil
-	if ( session and session.cookie ) then
-		cookie = session.cookie
-	end
-	local headers = {}
-	headers[ "Cookie" ] = cookie
-	local r, c, h = http.request({
-		url = URL,
-		sink = ltn12.sink.table( t ),
-		headers = headers
-	})
-	r = table.concat( t, "" )
-	if ( h ) then
-		t = {}
-		for k, v in pairs( h ) do
-			if ( k == "set-cookie" ) then
-				-- We remove expiration data here since it has commas in the given
-				-- timestamps, so it doesn't break us separating individual cookies
-				-- below
-				v = string.gsub( v, "(expires=.-; )", "" )
-				-- Grab set-cookie and append an additional separator for gmatch
-				-- convenience
-				v = v .. ", "
-				for cookie in string.gmatch( v, "(.-), " ) do
-					cookie = string.match( cookie, "(.-);" )
-					table.insert( t, cookie )
-				end
-			end
-		end
-		cookie = table.concat( t, ";" )
-	else
-		cookie = nil
-	end
-	-- r is retcontent,c is retcode,cookie just cookie
-	return r, c, cookie
-end
- 
-function facepunch.http.post( URL, session, postData )
-	local t = {}
-	local cookie = nil
-	if ( session and session.cookie ) then
-		cookie = session.cookie
-	end
-	postData = postData or ""
-	local headers = {}
-	headers[ "Content-Type" ] = "application/x-www-form-urlencoded"
-	headers[ "Content-Length" ] = string.len( postData )
-	headers[ "Cookie" ] = cookie
-	local r, c, h = http.request( {
-		url = URL,
-		source = ltn12.source.string( postData ),
-		sink = ltn12.sink.table( t ),
-		method = "POST",
-		headers = headers,
-	}, postData )
-	r = table.concat( t, "" )
-	if ( h ) then
-		t = {}
-		for k, v in pairs( h ) do
-			if ( k == "set-cookie" ) then
-				-- We remove expiration data here since it has commas in the given
-				-- timestamps, so it doesn't break us separating individual cookies
-				-- below
-				v = string.gsub( v, "(expires=.-; )", "" )
-				-- Grab set-cookie and append an additional separator for gmatch
-				-- convenience
-				v = v .. ", "
-				for cookie in string.gmatch( v, "(.-), " ) do
-					cookie = string.match( cookie, "(.-);" )
-					table.insert( t, cookie )
-				end
-			end
-		end
-		cookie = table.concat( t, ";" )
-	else
-		cookie = nil
-	end
-	return r, c, cookie
-end
+require( "facepunch" )
 
-r=[[
 
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
-
-<head>
-<!--
-<WISPAccessGatewayParam xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespace SchemaLocation="http://www.acmewisp.com/WISPAccessGatewayParam.xsd">
-<Proxy>
-<MessageType>110</MessageType>
-<NextURL>http://cmccportal.aicent.net/gis.php?Hotspot_operator=CMCC&Hotspot_location=beijing&Nas_id=0361.0371.371.00&Nas_ip=221.176.119.178&User_ip=111.7.61.189&Portal_ip=221.176.1.140:80&Client_type=wispr</NextURL>
-<ResponseCode>200</ResponseCode>
-<Delay>2</Delay>
-</Proxy>
-</WISPAccessGatewayParam>
--->
-<!-- cmcccs|login_req||-->
-<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
-<meta http-equiv="Cache-Control" content="no-cache">
-<link href='http://221.176.1.140:80/cmcc_mobile/mobile.css' rel='stylesheet' type='text/css' />
-<title>�й��ƶ� Wlan</title>
-
-
-</head>
-
-<body>
-<form name="loginform" action="https://221.176.1.140/wlan/index.php" method="post">
-
-<input  type="hidden" name="wlanacname" value="0361.0371.371.00">
-<input  type="hidden" name="wlanuserip" value="111.7.61.189">
-<input  type="hidden" name="wlanacssid" value="CMCC">
-<input  type="hidden" name="actiontype" value="LOGIN">
-<input  type="hidden" name="languagetype" value="">
-</form>
-</body>
-<script language="javascript">
-window.location="https://221.176.1.140:443/cmcc_mobile_input.php?wlanacip=221.176.119.178&wlanacname=0361.0371.371.00&wlanuserip=111.7.61.189&wlanacssid=CMCC&fromlocation=cmcc_index&ualistindex=UA0999";
-</script>
-</html>
-]]
-
--- ���Ըɻ�Ŷ
 r,c,cookie=facepunch.http.get("http://www.baidu.com/")
 print (r.."\n"..c)
 print ("\n"..cookie)
 local string = require"string"
-username="13873772907"
-password="743482"
+
+local configfile = io.open("config.txt", "r")
+username=configfile:read()
+password=configfile:read()
+configfile:close()
+print(username,password)
+
 local patters = { "wlanacip","wlanacname","wlanuserip", }
 login_data={wlancssid="CMCC",ualistindex="UA0999",loginmode="static",staticusername=username,staticpassword=password}
 for _,p in pairs(patters) do

lua/cmcc_Login_localtest.lua

--------------------------------------------------------------------------------
--- LuaSocket connector
--- Facepunch Lua API
--- Authors: Andrew McWatters
---			Gran PC
---			Gregor Steiner
--------------------------------------------------------------------------------
--- a small problem:
--- URL mast with http://,
- 
-local error = error
-local http = require( "socket.http" )
-local ltn12 = require( "ltn12" )
-local string = string
-local table = table
- 
-facepunch={}
-facepunch.http={}
- 
-function facepunch.http.get( URL, session )
-	local t = {}
-	local cookie = nil
-	if ( session and session.cookie ) then
-		cookie = session.cookie
-	end
-	local headers = {}
-	headers[ "Cookie" ] = cookie
-	local r, c, h = http.request({
-		url = URL,
-		sink = ltn12.sink.table( t ),
-		headers = headers
-	})
-	r = table.concat( t, "" )
-	if ( h ) then
-		t = {}
-		for k, v in pairs( h ) do
-			if ( k == "set-cookie" ) then
-				-- We remove expiration data here since it has commas in the given
-				-- timestamps, so it doesn't break us separating individual cookies
-				-- below
-				v = string.gsub( v, "(expires=.-; )", "" )
-				-- Grab set-cookie and append an additional separator for gmatch
-				-- convenience
-				v = v .. ", "
-				for cookie in string.gmatch( v, "(.-), " ) do
-					cookie = string.match( cookie, "(.-);" )
-					table.insert( t, cookie )
-				end
-			end
-		end
-		cookie = table.concat( t, ";" )
-	else
-		cookie = nil
-	end
-	-- r is retcontent,c is retcode,cookie just cookie
-	return r, c, cookie
-end
- 
-function facepunch.http.post( URL, session, postData )
-	local t = {}
-	local cookie = nil
-	if ( session and session.cookie ) then
-		cookie = session.cookie
-	end
-	postData = postData or ""
-	local headers = {}
-	headers[ "Content-Type" ] = "application/x-www-form-urlencoded"
-	headers[ "Content-Length" ] = string.len( postData )
-	headers[ "Cookie" ] = cookie
-	local r, c, h = http.request( {
-		url = URL,
-		source = ltn12.source.string( postData ),
-		sink = ltn12.sink.table( t ),
-		method = "POST",
-		headers = headers,
-	}, postData )
-	r = table.concat( t, "" )
-	if ( h ) then
-		t = {}
-		for k, v in pairs( h ) do
-			if ( k == "set-cookie" ) then
-				-- We remove expiration data here since it has commas in the given
-				-- timestamps, so it doesn't break us separating individual cookies
-				-- below
-				v = string.gsub( v, "(expires=.-; )", "" )
-				-- Grab set-cookie and append an additional separator for gmatch
-				-- convenience
-				v = v .. ", "
-				for cookie in string.gmatch( v, "(.-), " ) do
-					cookie = string.match( cookie, "(.-);" )
-					table.insert( t, cookie )
-				end
-			end
-		end
-		cookie = table.concat( t, ";" )
-	else
-		cookie = nil
-	end
-	return r, c, cookie
-end
-
+require( "facepunch" )
 r=[[
 
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
 <meta http-equiv="Cache-Control" content="no-cache">
 <link href='http://221.176.1.140:80/cmcc_mobile/mobile.css' rel='stylesheet' type='text/css' />
-<title>�й��ƶ� Wlan</title>
+<title>中国移动 Wlan</title>
 
 
 </head>
 </html>
 ]]
 
--- ���Ըɻ�Ŷ
+
 -- r,c,cookie=facepunch.http.get("http://www.baidu.com/")
 -- print (r.."\n"..c)
 -- print ("\n"..cookie)

lua/cmcc_Logout.lua

--------------------------------------------------------------------------------
--- LuaSocket connector
--- Facepunch Lua API
--- Authors: Andrew McWatters
---			Gran PC
---			Gregor Steiner
--------------------------------------------------------------------------------
--- a small problem:
--- URL mast with http://,
- 
-local error = error
-local http = require( "socket.http" )
-local ltn12 = require( "ltn12" )
-local string = string
-local table = table
- 
-facepunch={}
-facepunch.http={}
- 
-function facepunch.http.get( URL, session )
-	local t = {}
-	local cookie = nil
-	if ( session and session.cookie ) then
-		cookie = session.cookie
-	end
-	local headers = {}
-	headers[ "Cookie" ] = cookie
-	local r, c, h = http.request({
-		url = URL,
-		sink = ltn12.sink.table( t ),
-		headers = headers
-	})
-	r = table.concat( t, "" )
-	if ( h ) then
-		t = {}
-		for k, v in pairs( h ) do
-			if ( k == "set-cookie" ) then
-				-- We remove expiration data here since it has commas in the given
-				-- timestamps, so it doesn't break us separating individual cookies
-				-- below
-				v = string.gsub( v, "(expires=.-; )", "" )
-				-- Grab set-cookie and append an additional separator for gmatch
-				-- convenience
-				v = v .. ", "
-				for cookie in string.gmatch( v, "(.-), " ) do
-					cookie = string.match( cookie, "(.-);" )
-					table.insert( t, cookie )
-				end
-			end
-		end
-		cookie = table.concat( t, ";" )
-	else
-		cookie = nil
-	end
-	-- r is retcontent,c is retcode,cookie just cookie
-	return r, c, cookie
-end
- 
-function facepunch.http.post( URL, session, postData )
-	local t = {}
-	local cookie = nil
-	if ( session and session.cookie ) then
-		cookie = session.cookie
-	end
-	postData = postData or ""
-	local headers = {}
-	headers[ "Content-Type" ] = "application/x-www-form-urlencoded"
-	headers[ "Content-Length" ] = string.len( postData )
-	headers[ "Cookie" ] = cookie
-	local r, c, h = http.request( {
-		url = URL,
-		source = ltn12.source.string( postData ),
-		sink = ltn12.sink.table( t ),
-		method = "POST",
-		headers = headers,
-	}, postData )
-	r = table.concat( t, "" )
-	if ( h ) then
-		t = {}
-		for k, v in pairs( h ) do
-			if ( k == "set-cookie" ) then
-				-- We remove expiration data here since it has commas in the given
-				-- timestamps, so it doesn't break us separating individual cookies
-				-- below
-				v = string.gsub( v, "(expires=.-; )", "" )
-				-- Grab set-cookie and append an additional separator for gmatch
-				-- convenience
-				v = v .. ", "
-				for cookie in string.gmatch( v, "(.-), " ) do
-					cookie = string.match( cookie, "(.-);" )
-					table.insert( t, cookie )
-				end
-			end
-		end
-		cookie = table.concat( t, ";" )
-	else
-		cookie = nil
-	end
-	return r, c, cookie
-end
+require( "facepunch" )
 
 local serfile = io.open("cmcc_login_info_lua", "r")
 ser=serfile:read()

lua/cmcc_login_info_lua

-http://221.176.1.140:80/user_status.php?username=13873772907&logonsessid=0361.0371.371.00;2012092115142103E63F;ps001new&wlanacip=221.176.119.178&wlanacname=0361.0371.371.00&wlanuserip=111.7.61.189&logintime=2012-09-21 15:14:21&remaintime=0&areacode=731&wlanacssid=&productid=22&effecttime=20120327 000000&expiretime=20380101 000000&keystr=13f38b0aa34870b4037da6b101fb93ef3d17078d42e14504&cf=disabled
+http://221.176.1.140:80/user_status.php?username=13873772907&logonsessid=0361.0371.371.00;201209211451330416D6;ps003new&wlanacip=221.176.119.178&wlanacname=0361.0371.371.00&wlanuserip=111.7.61.189&logintime=2012-09-21 14:51:33&remaintime=0&areacode=731&wlanacssid=&productid=22&effecttime=20120327 000000&expiretime=20380101 000000&keystr=13f38b0aa34870b4037da6b101fb93ef3d17078d42e14504&cf=disabled

lua/facepunch.lua

+-------------------------------------------------------------------------------
+-- LuaSocket connector
+-- Facepunch Lua API
+-- Authors: Andrew McWatters
+--			Gran PC
+--			Gregor Steiner
+-------------------------------------------------------------------------------
+-- a small problem:
+-- URL mast with http://,
+ 
+local error = error
+local http = require( "socket.http" )
+local ltn12 = require( "ltn12" )
+local string = string
+local table = table
+ 
+facepunch={}
+facepunch.http={}
+ 
+function facepunch.http.get( URL, session )
+	local t = {}
+	local cookie = nil
+	if ( session and session.cookie ) then
+		cookie = session.cookie
+	end
+	local headers = {}
+	headers[ "Cookie" ] = cookie
+	local r, c, h = http.request({
+		url = URL,
+		sink = ltn12.sink.table( t ),
+		headers = headers
+	})
+	r = table.concat( t, "" )
+	if ( h ) then
+		t = {}
+		for k, v in pairs( h ) do
+			if ( k == "set-cookie" ) then
+				-- We remove expiration data here since it has commas in the given
+				-- timestamps, so it doesn't break us separating individual cookies
+				-- below
+				v = string.gsub( v, "(expires=.-; )", "" )
+				-- Grab set-cookie and append an additional separator for gmatch
+				-- convenience
+				v = v .. ", "
+				for cookie in string.gmatch( v, "(.-), " ) do
+					cookie = string.match( cookie, "(.-);" )
+					table.insert( t, cookie )
+				end
+			end
+		end
+		cookie = table.concat( t, ";" )
+	else
+		cookie = nil
+	end
+	-- r is retcontent,c is retcode,cookie just cookie
+	return r, c, cookie
+end
+ 
+function facepunch.http.post( URL, session, postData )
+	local t = {}
+	local cookie = nil
+	if ( session and session.cookie ) then
+		cookie = session.cookie
+	end
+	postData = postData or ""
+	local headers = {}
+	headers[ "Content-Type" ] = "application/x-www-form-urlencoded"
+	headers[ "Content-Length" ] = string.len( postData )
+	headers[ "Cookie" ] = cookie
+	local r, c, h = http.request( {
+		url = URL,
+		source = ltn12.source.string( postData ),
+		sink = ltn12.sink.table( t ),
+		method = "POST",
+		headers = headers,
+	}, postData )
+	r = table.concat( t, "" )
+	if ( h ) then
+		t = {}
+		for k, v in pairs( h ) do
+			if ( k == "set-cookie" ) then
+				-- We remove expiration data here since it has commas in the given
+				-- timestamps, so it doesn't break us separating individual cookies
+				-- below
+				v = string.gsub( v, "(expires=.-; )", "" )
+				-- Grab set-cookie and append an additional separator for gmatch
+				-- convenience
+				v = v .. ", "
+				for cookie in string.gmatch( v, "(.-), " ) do
+					cookie = string.match( cookie, "(.-);" )
+					table.insert( t, cookie )
+				end
+			end
+		end
+		cookie = table.concat( t, ";" )
+	else
+		cookie = nil
+	end
+	return r, c, cookie
+end