473,399 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Is this possible? Login to remote site using cURL, then pass credentials to browser.

JDS
So, I'd like to create the following scenario:

1) Use cURL library within PHP (cURL + "Cookie Jar", et.al) to create a
virtual browser session that "logs in" to a remote site. (For example:

here:
http://curl.haxx.se/libcurl/php/examples/cookiejar.html

and here:
http://curl.haxx.se/libcurl/php/exam...bay_login.html
2) Save the login credentials -- cookies, session vars, whatever -- and
pass that to the web browser so that now the web browser is logged in.

Is that possible?

How can one take the values in the cookie jar and create the same cookies
in the browser session?

etc.

Thanks!

--
JDS

May 15 '07 #1
3 10344
On May 15, 6:01 pm, JDS <jeff...@invalid.addresswrote:
So, I'd like to create the following scenario:

1) Use cURL library within PHP (cURL + "Cookie Jar", et.al) to create a
virtual browser session that "logs in" to a remote site. (For example:

here:http://curl.haxx.se/libcurl/php/examples/cookiejar.html

and here:http://curl.haxx.se/libcurl/php/exam...bay_login.html

2) Save the login credentials -- cookies, session vars, whatever -- and
pass that to the web browser so that now the web browser is logged in.

Is that possible?

How can one take the values in the cookie jar and create the same cookies
in the browser session?

etc.

Thanks!

--
JDS
in the traditional model of client<->server1.com<->server2.com the
credentials (if stored as cookies) will only be valid for domain
server1.com, so you cannot hand off the credentials to the client

however if you use some client side scripting to map only part of
server2.com's domain space to server1.com the rest making a straight
through connection to server2.com then it is possible under certain
circumstances. (those being that server2.com uses the session id as an
authentication token)

For instance: foxy proxy within firefox, which proxies a request for a
URL matching server2.com/login.php via a machine on which server1.com
runs AND vhost server2.com, and which has a DNS/host entry for
server2.com pointing to itself. This machine makes a cURL requests
logging on to server2.com using its real IP address. It returns the
credentials to the client back though the proxy, meanwhile all the
images and so forth have been downloaded from the server2.com to the
client unproxied. The cookie would then appear to have been sent by a
header from the correct host and now you can continue using
server2.com from the client and the client will send the correct
cookie.

I have tested this and use it routinely to overcome same domain
restrictions in order to inject code into the webpages I view to make
the user experience better for me, removing adverts or simply
returning a larger dataset, etc... for fun rather than for profit.

There are of course situations in which this technique would not work,
but give it a go.

May 15 '07 #2
JDS
On Tue, 15 May 2007 10:16:35 -0700, shimmyshack wrote:
>
in the traditional model of client<->server1.com<->server2.com the
credentials (if stored as cookies) will only be valid for domain
server1.com, so you cannot hand off the credentials to the client


Okay, so, I think I have my original answer: "NO"

That's okay. I found an acceptable workaround. Note: This workaround may
not be acceptable to everyone as it uses JavaScript and depends on client
side behavior!

Solution:

1) Create PHP script that gathers creds and maps them to the proper
username/password.

2) Embed an HTML form that mimics the POST form I need to circumvent

3) Use the onload() and submit() events to submit creds via POST method

This works! Yay!
--
JDS | je*****@example.invalid
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/
May 21 '07 #3
On May 21, 10:43 pm, JDS <jeff...@example.invalidwrote:
On Tue, 15 May 2007 10:16:35 -0700, shimmyshack wrote:
in the traditional model of client<->server1.com<->server2.com the
credentials (if stored as cookies) will only be valid for domain
server1.com, so you cannot hand off the credentials to the client

Okay, so, I think I have my original answer: "NO"

That's okay. I found an acceptable workaround. Note: This workaround may
not be acceptable to everyone as it uses JavaScript and depends on client
side behavior!

Solution:

1) Create PHP script that gathers creds and maps them to the proper
username/password.

2) Embed an HTML form that mimics the POST form I need to circumvent

3) Use the onload() and submit() events to submit creds via POST method

This works! Yay!
--
JDS | jeff...@example.invalid
|http://www.newtnotes.com
DJMBS |http://newtnotes.com/doctor-jeff-master-brainsurgeon/
now this /is/ possible as you describe, however it isnt a virtual
session, but rather, a real one, directly between the browser and the
site.
You can of course write a proxy routine, that posts the data using
cURL, and hands back not the session id, but the protected content,
and integrate that into the pages. This would work well where you
control both the site you /were/ on and the site that needs to be
"logged in to" you can mix and match data scross domains this way
although it is not recommended as it's basically XSS and is bound to
be gradually harder to pull off under tighter models in the furture.

May 21 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: cshennan | last post by:
Hi, I'm not sure if this can be done, but here goes. I'm currently trying writing an activex component to allow me to browse a directory held on a remote machine. I've been looking into the...
1
by: nabilo | last post by:
I want to know if it's possible to call, within my cgi page, using javascript, a remote url and get the result without changing my actual page. To say more, I have a page result appaired to the...
9
by: Mike Von Stein | last post by:
Maybe I'm missing something obvious, but if I several MDB's that use the same secure workgroup MDW file and the user logs into one of them is there a way through code that I can open other...
6
by: Access Newbie | last post by:
I'm using Access 2000 and I'm trying to create a pass-through query to append all the data from a local table to a remote table. I'm using the SQL query editor in MS Access to create the query (I...
0
by: Craig Burkett | last post by:
I am needing to access a remote share using a set of credentials (ie a userid and a password that are not what I am logged in with) with a UNC name (I am not allowed to access the share by mounting...
0
by: mlfblom | last post by:
Hi, I am running visual studio 2005 on a Vista Ultimate client. I have created a remote site on a Windows 2003 R2 server. This site has about 100 aspx, many App_Code files and several references...
3
by: buzz2050 | last post by:
Hi all, I am using cURL for the first time. I need to login to a site and my cURL code to do the same is as follows: //curlScript.php <?php function getContent($url, $referer,...
2
by: csihosting | last post by:
I would like to dispaly some images from a remote site (I have permission) on my asp.net page. The site required authentication. How do I retrieve the images and send the credentials without the user...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.