Recent

Author Topic: Use ShellExecute to send browser output to a file  (Read 13584 times)

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Use ShellExecute to send browser output to a file
« Reply #15 on: July 29, 2015, 06:53:11 pm »
this works, i get the same source as "view source" (except for an extra empty line at the end of file).
Now try to do the same with:
http://forum.lazarus.freepascal.org/index.php?action=profile;area=account
I'll bet you get a different page then when you do this, logged in the forum, with IE.

That's the whole point. bobonwhidbey want's to be able to access pages which are behind a login (is my guess) and doesn't have the password. So he/she needs to create a TWebBrowser for the user to login after which the page can be caught. After this first login the cookies need to be saved for subsequent page-access (without user-interaction).

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
Re: Use ShellExecute to send browser output to a file
« Reply #16 on: July 29, 2015, 07:24:00 pm »
rvk - you've described the situation correctly. The cookie (which is left after the user has logged in) is left in the user's default browser.

lainz#007 - your approach works very well BUT doesn't use the default browser, so the web site doesn't see the necessary cookie.

Retrieving the PHPSESSID cookie from the default browser is a gigantic task IMO, because each browser uses a different technique to store cookies. That's why I'm trying to use the default browser with ShellExecute.
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

lainz

  • Hero Member
  • *****
  • Posts: 4460
    • https://lainz.github.io/
Re: Use ShellExecute to send browser output to a file
« Reply #17 on: July 29, 2015, 07:46:07 pm »
Well, he can do the login that was discussed several times in this forum.

Why you don't want to embeed a browser in your application? The user can login and you can manage everything.

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Use ShellExecute to send browser output to a file
« Reply #18 on: July 29, 2015, 08:23:20 pm »
That's the whole point. bobonwhidbey want's to be able to access pages which are behind a login (is my guess) and doesn't have the password.
Please forgive my ignorance rvk, but i find that highly suspicious.

If you can login with a browser you can also login using any of the other techniques suggested. This sound to me as an attempt to hijacking a session. At least i can not think of another situation in which this would be required.

rvk

  • Hero Member
  • *****
  • Posts: 6112
Re: Use ShellExecute to send browser output to a file
« Reply #19 on: July 29, 2015, 09:04:57 pm »
That's the whole point. bobonwhidbey want's to be able to access pages which are behind a login (is my guess) and doesn't have the password.
Please forgive my ignorance rvk, but i find that highly suspicious.
Yeah... but that's what he/she's asking for.

I already suggested creating a TWebBrowser where the end-user can login. This would be a one time action. After that the program can save the cookie (for how long the website would allow) and do what it wants. That way the user gives permission inside the program and knows what he/she's doing.

Another option would be to do a createprocess and catch the browser and try to manipulate it through its handle but you would have to take all possible browsers into account. So just going with embedding the TWebBrowser is the best way... but bobonwhidbey has to agree that the user has to login within a browser-window the program provides.

bobonwhidbey

  • Hero Member
  • *****
  • Posts: 592
    • Double Dummy Solver - free download
Re: Use ShellExecute to send browser output to a file
« Reply #20 on: July 29, 2015, 10:45:29 pm »
Thank you all for trying to solve my problem. There is nothing nefarious going on here. The international bridge site https://www.bridgebase.com/ now requires the user to login to look at bridge results. My program use to get these results directly. The login process leaves a cookie in your browser - for a full month.

I already suggested creating a TWebBrowser where the end-user can login. This would be a one time action. After that the program can save the cookie (for how long the website would allow) and do what it wants. That way the user gives permission inside the program and knows what he/she's doing.

I'll look into this approach.
Lazarus 3.0RC2, FPC 3.2.2 x86_64-win64-win32/win64

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Use ShellExecute to send browser output to a file
« Reply #21 on: July 29, 2015, 11:03:05 pm »
@bobonwhidbey:

It might not look nefarious from your point of view, but from other people's point of view it most certainly does.

What you are effectively trying to accomplish using your method is to 'hijack' the browser after the user logged in. You have any idea how insecure that would be if any program is able to 'take over' a browser session that way ?

It leaves the browser completely insecure and open to any kind of attacks that the program has in mind (or not in your case, but how can we tell ?).

Why are you not able to login using your own lazarus form (asking for username and password), and open a _secure_ session to that site for your own ? Even wget is able to do that for you if you like to refrain from manually managing secure sessions.

in my humble opinion there is absolutely no need for you to attempt to use the users default browser to 'scrape' results from a website. There are far beter tools equipped to do that job, fphttpclient being one of them.

fwiw: my security software prohibits your proposed initial solution by default: no other program is allowed to initiate my browser without permission.

 

TinyPortal © 2005-2018