Sunday 3 June 2012

Easy way to hack in a website

If you want to autopost in a website without wasting time to visit that page and filling forms manually, you can do it simply by php curl function.. for this you have to know the html code of that registration page you want to fill. for eg:
<form id="RegisterForm" class="styled" action="registerme.asp" method="post">
<fieldset>
<ol>
<li class="form-row">
<label>Title:</label>
<input style="width:50px" name="txtTitle" type="text" class="required"/>
</li>
<li class="form-row">
<label>First name:</label>
<input style="width:100px" name="txtFirstName" type="text" class="required"/>
</li>

<li class="form-row">
<label>Email:</label>
<input style="width:300px" name="txtEmail" type="text" class="required email"/>
</li>
<li class="form-row">
<label>Password:</label>
<input name="txtPassword" type="password" class="required password"/>
<br/>Password must be alpha-numeric with between 6 and 15 characters
</li>
</ol>
</fieldset>
<input type="submit" value="Register" class="submit background_lightest colour_darkest" name="submitbtn"  />
Here is the code to autopost:-
Here you have to specify the url in which you want to autopost. in the above html code you know that the form action is going to http://sitename/registerme.asp
from the code
<form id="RegisterForm" class="styled" action="registerme.asp" method="post">
so we specify url as http://sitename/registerme.asp
next we have to find the field names:- and looking from the above site we know that field names are:-
# txtTitle
#txtFirstName
#txtEmail
#txtPassword

and also in submit action maybe the the programmer checks the submit button is set or not. so we have to asign submit button name to true. also while doing this you should note whether any hidden values are passed in the form.if any hidden values are passed,don't forget to pass that values in your code.
so provide values to these variables in the field string. so final code is:-


<?php
set_time_limit(0);
$user = "Your title";
$d = "true";

$auth = "Name";
$email="name@gmail.com";
$pass="243434gh";// anything you like

$user_agent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9";

$fields = array(
            'txtTitle'=>$user,'txtFirstName'=>$auth,'txtEmail'=>$email,'txtPassword'=>$pass,'submitbtn'=>"true"
        );

$fields_string='';
foreach($fields as $key=>$value) {
$fields_string .= $key.'='.$value.'&';
}

define("COOKIE_FILE", "c:\cookie.txt");

$url='http://www.sitename/registarationpage';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);   //
curl_setopt($ch,CURLOPT_MAXREDIRS,2); //
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch,CURLOPT_USERAGENT,$user_agent);
curl_setopt($ch,CURLOPT_REFERER,'http://google.com');
curl_setopt($ch,CURLOPT_HEADER,true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
$result = curl_exec($ch);
curl_setopt($ch,CURLOPT_POST,0);
print_r(curl_getinfo($ch));
$d=curl_getinfo($ch);
echo "haai";
print_r(curl_error($ch));
   echo $curl_errno = curl_errno($ch);
echo"lool";

if ($curl_errno > 0) {
                echo "cURL Error ($curl_errno): $curl_error\n";
        } else {
echo $result;
}

?>

No comments:

Post a Comment