How to use scripts to mimic landing process _php techniques

Source: Internet
Author: User
Tags strlen
Check the code on his landing page to see which page he is submitting to and what the variable is.
Copy Code code as follows:

<form method= "POST" action= "login.jsp" >
<table align= "center" width= "40%" style= "font-size:12px" border= "0" cellpadding= "0" cellspacing= "2" >
<tr>
&LT;TD width= "30%" align= "right" bgcolor= "#0073AA" style= "Font-size:12px;color: #ffffff" >name:</td>
&LT;TD width= "70%" ><input type= "text" size= "" name= "username" ></td>
</tr>
<tr>
&LT;TD width= "30%" align= "right" bgcolor= "#0073AA" style= "Font-size:12px;color: #ffffff" >password:</td>
&LT;TD width= "70%" ><input type= "password" "size=" Name= "passwd" ></td>
</tr>
<tr>
&LT;TD colspan= "2" align= "right" >
<input type= "Submit" name= "Submit" value= "Login" >
<input type= "button" name= "Submit" value= "Regest" onclick= "location.href= ' regest.jsp '" ">
</td>
</tr>
</table>
</form>

Obviously, if you want to log in, you need to post the username, passwd, submit these several variables to login.jsp, and Submit=login
Use the following code:
Copy Code code as follows:

<?php
$postData = "Username=your_name&password=your_password&submit=login";
$posturl = "http://......../../login.jsp";

$POSTURL = Parse_url ($posturl);
$host = $POSTURL [host]? $POSTURL [host]: "";
$port = $POSTURL [port]? $POSTURL [port]: 80;
$path = $postUrl [path]? $POSTURL [path]: "/";



$FSP = Fsockopen ($host, $port, & $errno, & $errstr, 30);
if (! $fsp) {
Print "\nopen socket failed\n";
}else{
Fwrite ($FSP, "POST". $path. " Http/1.1\r\n ");
Fwrite ($FSP, "Accept:image/gif, Image/x-xbitmap, Image/jpeg, Image/pjpeg, Application/x-shockwave-flash, application /vnd.ms-excel, Application/vnd.ms-powerpoint, Application/msword, */*\r\n ");
Fwrite ($FSP, "accept-language:zh-cn\r\n");
Fwrite ($FSP, "content-type:application/x-www-form-urlencoded\r\n");
Fwrite ($FSP, "user-agent:mozilla/4.0" (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon) \ r \ n ");
Fwrite ($FSP, "Host:". $host. " \ r \ n ");
Fwrite ($FSP, "Content-length:". strlen ($postData). " \r\n\r\n ");
Fwrite ($FSP, $postData);

$resp = "";
do{
if (strlen ($out =fread ($FSP, 1024)) = = 0) break;
$resp. = $out;
}while (TRUE);

echo "<br><br>". NL2BR ($RESP);

Fclose ($FSP);

}
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.