Prerequisite: ISP has to support the way Web logons.
Description: Each ISP login page is not the same, but I estimate the algorithm is the same, so the solution should be similar, but the form key may not be the same.
First, analyze the login page.
The page head is inlaid with <script> tags, and all submissions related scripts are here. The key part of the page is two forms: F1 and F0. The whole f0 is invisible, but when you click on the F1 submission, you call F0 's submission instead of submitting yourself. The table layout of the form will not spit ...
Partial HTML
<form name= "F1" method= "post" action= "" onsubmit= "return ee ()" > <table border = "0" width= "100%" cellspacing= "1" cellpadding= "0" height= "100%" class= "F1" > ... <tr> <td height= "Width=" 35% "align=" > Account </td><td height= "width=" "64%" > <input name= "ddddd" type= "text" Maxlength= "class=" "Input-border" ></td> </tr> <tr> <td height= "width=" 35% "align=" right "> Password Password </td><td height=" width= "64%" > <input name= "upass" type= "Password" maxlength= "16" class= "Input-border" ></td> </tr> <tr> <td height= "-" width= "35%" > </td><td height= "width=" "64%" > <input type= "Submit" Name= "0MKKey" value= "" onclick= "CC (0)" class= "Login-b" > < Input type= "Submit" "Name=" "value=" "onclick=" reset (); return false; " ></td> </tr> ... </form>
As you can see here, click Submit, Call CC (0), call the EE () function when submitting
Part JS:
function CC (ss) {
F0. R1.value = SS;
}
function ee () {
if (F1). Ddddd.value = = "") {
alert ("Please enter your account number to enter your accounts number");
return false;
}
F0. Ddddd.value = F1. Ddddd.value
if (ps = = 0) {
f0.upass.value = Xproc1 (F1.upass.value);
} else {
Tmpchar = pid + f1.upass.v Alue + calg;
F0.upass.value = calcMD5 (Tmpchar) + Calg + pid;
F0. R2.value = 1;
}
Document.f0.submit ();
return false;
}
Obviously, when you click Submit, a series of assignments will be made to F0, and if there is no problem, it will be submitted F0
F0:
<form name= "F0" method= "POST" action= "" ><input type= "hidden" name= "ddddd" value= "0" ><input type= " Hidden "name=" UPass "value=" 0 "> <input type=" hidden "name=" R1 "
value=" 0 "><input type=" hidden "name=" R2 "value=" 0 "><input type=" hidden "name=" para "value=" > <input type= "hidden" name= "0MKKey" value= "
123456 ">
</form>
Refer to the content in JS, use Python dict to express F0 words like the following pseudo code:
f0={}
f0["ddddd"] = f1[' DDDD ']
f0[' upass '] = calcMD5 (pid + f1[' UPass '] + calg) + calg + pid;
f0["R1"] = SS
f0["R2"] = 1
f0["para"] =
f0["0MKKey"] = 123456
where SS, PID, Calg are constants, f1[' DDDD ', f1[' UPass ', respectively, are user-entered username and password strings
The key is the CALCMD5 algorithm.
From the function names and functions themselves, this function is an implementation of MD5. However, there are some problems in the process of porting JS code: JS and Python shift operation performance is different.
Since the entire f0[' upass ' field is constant in addition to the password entered by the user, it is possible to use JS to calculate the f0[' UPass '],python as long as the string is saved.
Check cookies found throughout the Web page without using cookies.
Login after the jump to the logout page, Analysis logout page found, log out only need to access a specific page on the line.
So the whole idea is very simple, POS login server Implementation login, get specified page logout. The implementation code is as follows:
Import SYS from
urllib import urlencode from
urllib2 import urlopen
username = "s10********"
upass = "669 6a3*********************************** "
LOGIN =" http://202.1**.***.***/"
LOGOUT =" http://202.1**.***.*** /f.htm "
def post (URL, data=none):
If data:
data = urlencode (data)
response = Urlopen (URL, data)
Return Response.read ()
def login ():
data={}
data["ddddd" = Username data[
"upass"] = UPass
data["R1"] = 0
data["R2"] = 1
data["para"] =
data["0MKKey"] = 123456
post (LOGIN, data)
Pass
def logout ():
post (LOGOUT)
def Main (argv):
if argv[0] in (' Login ', ' in ', ' I '):
login ()
elif argv[0] in (' Logout ', ' out ', ' O '):
logout () Pass pass
if __name__ = ' __main__ ':
Main (sys.argv[1:]);