The following is an implementation:
First, click the train ticket booking link to open the http: // Student Information Platform website/logstores trainsite. Asa page.
Overview of the logstores trainsite. Asa pageCodeAs follows:
Copy code The Code is as follows: <%
Response. Buffer = true
Response. expiresabsolute = now ()-1
Response. expires = 0
Response. cachecontrol = "no-Cache"
Response. addheader "Pragma", "No-Cache"
// Obtain the user name and password based on the user session
%>
<HTML>
<Body>
<Div style = 'display: none'>
<Form name = "myform" method = "Post" Action = "http: // train ticket booking website/loginfromothersite. aspx">
<Input type = "hidden" name = "username" value = "<% = username %>"/>
<Input type = "hidden" name = "userpwd" value = "<% = userpwd %>"/>
</Form>
</Div>
</Body>
</Html>
<Script language = "JavaScript">
Myform. Submit ();
</SCRIPT> the code for the loginfromothersite. aspx. CS page is roughly as follows:
Using (sqlconnection conn = new sqlconnection (sqlhelper. studentconnectionstring ))
{
String SQL = "select t_stuuser.id, t_stuuser.stunumber, t_stuuser.userpassword, t_stuuser.realname, v_stuuser.classname, v_stuuser.departmentname"
+ "From t_stuuser, v_stuuser where t_stuuser.stunumber = @ username and t_stuuser.userpassword = @ userpwd and v_stuuser.stunumber = @ username ";
Sqlcommand cmd = new sqlcommand (SQL, Conn );
Sqlparameter pusername = cmd. Parameters. Add ("@ username", sqldbtype. varchar, 30 );
Sqlparameter puserpwd = cmd. Parameters. Add ("@ userpwd", sqldbtype. varchar, 150 );
Pusername. value = request. Form ["username"];
Puserpwd. value = request. Form ["userpwd"];
Conn. open ();
Sqldatareader SDR = cmd. executereader (commandbehavior. closeconnection );
If (SDR. Read ())
{
Session ["userid"] = convert. tostring (SDR ["ID"]);
Session ["stuname"] = convert. tostring (SDR ["realname"]);
Session ["stunumber"] = convert. tostring (SDR ["stunumber"]);
Session ["academe"] = convert. tostring (SDR ["departmentname"]);
Session ["classname"] = convert. tostring (SDR ["classname"]);
Response. Redirect ("myorder. aspx"); // login successful
}
Else
{
Response. Redirect ("default. aspx"); // Logon Failed, incorrect username or password
}
}
After the loginfromothersite. ASPX page is processed, both websites are logged on. But I want to know where this method is not safe,
What security issues may be caused? I hope some friends can tell me.