Jump to content

PHP Script to login to external web pages


matthewlesh

Recommended Posts

Hey there everyone..

 

This is something which i have wanted to be able to do for ages,

 

Well anyway what i would like this script to do is :

 

  1. Login Using POST to an SSL Server (The login system uses cookies)

  3. Go to a page after login and get the information into a variable

 

Any help with this would be very great.

Link to comment
Share on other sites

look into the curl functions

 

OK,

 

I've had a look around a bit... but now i have come into another problem...

 

I don't know how to use curl and there doesn't seem to be much around about it.

 

What i need to do now it work out how to :

 

  1. Go to a page and pick up some cookies

  2. Send post information to another page with those cookies being sent

  3. Set more cookies after that form has been sent

  4. View a page with the cookies being sent

 

I have had a look at a few page and found out how to just do the post part.. but everything else i am extremely confused about:

define('POSTURL', '<website to send post>');
define('POSTVARS', 'send=yes&q=$data');  // POST VARIABLES TO BE SENT

// INITIALIZE ALL VARS
$Email='';
$ch='';
$Rec_Data='';
$Temp_Output='';

if($_SERVER['REQUEST_METHOD']==='POST') {  // REQUIRE POST OR DIE

$ch = curl_init(POSTURL);
curl_setopt($ch, CURLOPT_POST      ,1);
curl_setopt($ch, CURLOPT_POSTFIELDS    ,POSTVARS);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION  ,1); 
curl_setopt($ch, CURLOPT_HEADER      ,0);  // DO NOT RETURN HTTP HEADERS 
curl_setopt($ch, CURLOPT_RETURNTRANSFER  ,1);  // RETURN THE CONTENTS OF THE CALL
$Rec_Data = curl_exec($ch);

ob_start();
header("Content-Type: text/html");
$Temp_Output = ltrim(rtrim(trim(strip_tags(trim(preg_replace ( "/\s\s+/" , " " , html_entity_decode($Rec_Data)))),"\n\t\r\h\v\0 ")), "%20");
$Temp_Output = ereg_replace (' +', ' ', trim($Temp_Output));
$Temp_Output = ereg_replace("[\r\t\n]","",$Temp_Output);
$Temp_Output = substr($Temp_Output,307,200);
echo $Temp_Output;
$Final_Out=ob_get_clean();
echo $Final_Out;  
curl_close($ch);
} else die('Hacking attempt Logged!');

exit; 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.