Solved

Get the source of an html page- behind a username/password

Posted on 2004-10-09
5
133 Views
Last Modified: 2006-11-17
Hey there,

Here is a fairly ticky one.
I have a website that has a username and password on it, this just a simple form user/pass - it dosn't use the htaccess - just a login using a form, like hotmail (but this isn't hotmail). So the question is, can I somehow enter the username/password, submit that form and then get the source of the html beind it.

So basically, login and get the html code from behind the login part. Is that do-able at all?
0
Comment
Question by:wildzero
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 10

Author Comment

by:wildzero
ID: 12265606
Ah I just semi answered myself in the last 10 minutes
However the problem is this
When the page first loads, to enter the name and password - a variable is assigned (a sid hash) and I need that to pass thou
Example
When the page first loads I get this
site.com/index.php?sid=iufdglkjlkdsfg
then if I tag on
&user=this&password=that then I can login - so would I have to load up the page once, grab the sid, then reload it wiith the username and password?

The sid is located in the form post data.
So when it first loads, if you look at the form it as index.php?sid=iufdglkjlkdsfg as the address to post to, so I guess that would have to be collected some how.
0
 
LVL 10

Author Comment

by:wildzero
ID: 12265681
Sure enough, almost got it.

What I need is the code for
Load page and extract the text from between the tags
<form action="GETWHATSINHERE" method="post"> - which could be anything
and also check for the hidden value -SID and if it exists get the form action and that value.

Could look like this
<form action="GETWHATSINHERE" method="post"><input type="hidden" name="SID" value="GETWHATSINHERE" />

The GETWHATSINHERE changes all the time.

Phew :D
0
 
LVL 3

Expert Comment

by:NewJorg
ID: 12265860
You could use the client url library functions from php (http://www.php.net/manual/en/ref.curl.php)
to post the values (SID, username, password) and get the html source of the page behind the login.
0
 
LVL 5

Accepted Solution

by:
basiclife earned 250 total points
ID: 12271234
Ok, something like:

$PageHandle=@fopen("http://setiweb.ssl.berkeley.edu/show_user.php?userid=$userid","r"); //Read stats
if ($PageHandle) {
      $Page='';
      while (!feof($PageHandle)) {
        $Page .= fread($PageHandle, 8192);
      }
      fclose($PageHandle);
      $start=strpos($Page, "<input type=\"hidden\" .......") + strlen("<input type=\"hidden\" ......."); //Put the entire hidden tag in here up to the 1st " of the value
      $ends=strpos($Page, "\"", $start); //Find the closing " (first " after the start)
      $SID = substr($Page, $start, $ends-$start); //SID is the bit between the 2 values you just found

Now print your own form / url with the SID you just ripped form the site. Is this what you were after?




} else {
      die("Unable to read URL");
}
0
 
LVL 5

Expert Comment

by:basiclife
ID: 12271251
Sorry, you need to update the @fopen statement with your own URL - that was just where I carelessly copied and pasted *hangs head in shame*
0

Featured Post

Why Off-Site Backups Are The Only Way To Go

You are probably backing up your data—but how and where? Ransomware is on the rise and there are variants that specifically target backups. Read on to discover why off-site is the way to go.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question