SRL Archive - General

Help using GetHTTPPage


Shady?

2014-10-18 02:10:42

Hi guys! I'm trying to log into facebook using simba. It seems like I'm able to do the POST and GET requests and read the headers just right, but I can't get any response out of those requests:

(disregard the login part and just focus on getting a response out of this GET request):

program new;
var
c:integer;
begin
c:= InitializeHTTPClient( true );
SetHTTPUserAgent( c, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.160 Safari/537.22' );
writeln(gethttppage(c,'https://m.facebook.com/'));
writeln(Getrawheaders(c));
end.

I dont know why it won't output anything. Getting other sites is fine. My guess is that this has something to do with X-Frame-Options: DENY but I have no idea why, lol.

Thanks in advance for any help!
(Also, I think you need OpenSSL to use https and simba? that's not my problem since I can get other https pages)

bg5

2014-10-18 08:13:03

I copied exact header from firefox and did not receive body too. Parameters in response header are same as in firefox and on sites like this http://web-sniffer.net/ . It has rather something to do with Simba and https…

After some testing I see, that Simba gets a lot of encrypted data in response, seemingly it just can't handle them. My suggestion is to try Brandon's plugin https://villavu.com/forum/showthread.php?t=108744

Shady?

2014-10-19 02:37:07

Thank you very much! I tried Brandon's plugin and it worked great.
I have a new concern now, is this correct for sending a POST request?


HT.Create('https://m.facebook.com/touchedittimeline/write/?edittype=basic_info', 443);
HT.SetParameter('accept','text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8');
HT.SetParameter('accept-encoding','gzip,deflate');
HT.SetParameter('accept-language','es,en-US;q=0.8,en;q=0.6');
HT.SetParameter('method','POST');
HT.SetParameter('Cookie',fbcookie);
HT.SetParameter('content-type','application/x-www-form-urlencoded');
HT.SetParameter('origin','https://m.facebook.com');
HT.SetParameter('refeer','https://m.facebook.com/profile/edit/infotab/section/forms/?section=basic-info');
HT.SetParameter('content-length','536');
HT.SetParameter('fb_dtsg',fb_dtsg);
HT.SetParameter('charset_test',between('name="charset_test" value="','"',response));
HT.SetParameter('birthday_day','19');
HT.SetParameter('birthday_month','11');
HT.SetParameter('birthday_year','1995');
//SomeMoreParams)
response := HT.GetRawPage;
writeln(response);


Because I can't seem to get the response I'm expecting.
Thanks once again!

Brandon

2014-10-19 15:42:48

From: Shady?
Thank you very much! I tried Brandon's plugin and it worked great.
I have a new concern now, is this correct for sending a POST request?


HT.Create('https://m.facebook.com/touchedittimeline/write/?edittype=basic_info', 443);

Because I can't seem to get the response I'm expecting.
Thanks once again!


URL doesn't exist.. at least not for me. That URL's page is blank and the parent page isn't found.

What exactly are you trying to do?

Shady?

2014-10-19 16:17:53

I'm trying to edit my facebook account's birthdate. You first go to https://m.facebook.com/profile/edit/infotab/section/forms/?section=basic-info, edit it, and when pressing Save, a POST request is sent to that url https://m.facebook.com/touchedittimeline/write/?edittype=basic_info

This would be the function:


procedure editdate;
var
HT,hts: HTTPS;
response:string;
begin
HTs.Create('https://m.facebook.com/profile/edit/infotab/section/forms/?section=basic-info', 443);
HTs.SetParameter('accept','text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8');
HTs.SetParameter('accept-encoding','gzip,deflate');
HTs.SetParameter('accept-language','es,en-US;q=0.8,en;q=0.6');
//HTs.SetParameter('method','POST');
HTs.SetParameter('Cookie',fbcookie);// this is a global var, if you want to test it, you can use this cookie instead: "locale=es_LA; xs=32%3A0_ywu0z4PTxi1g%3A2%3A1413711201%3A2414; lu=RwK8ZLUinWhXHGpGWEeqvQag; fr=0T4RcxHZcOhKnc0H3.AWVzkRtxxLlia7oXd7K6vlS2tn0.BUQ4Vh.MK.AAA.0.AWV7mw1R; c_user=100004876963421; p=75; m_user=0%3A0%3A0%3A0%3Av_1%2Cwidth_1920%2Cpxr_1%2Cgps_1%3A1413711201%3A2;"
response := HTs.GetRawPage;
//writeln(response);
//terminatescript;
//fb_dtsg := between('"fb_dtsg" value="','"',response);

//HTs.SetParameter('Cookie',fbcookie);
HTs.Free;

HT.Create('https://m.facebook.com/touchedittimeline/write/?edittype=basic_info', 443);
HT.SetParameter('accept','text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8');
HT.SetParameter('accept-encoding','gzip,deflate');
HT.SetParameter('accept-language','es,en-US;q=0.8,en;q=0.6');
//HT.SetParameter('method','POST');
HT.SetParameter('Cookie',fbcookie); // same as above
HT.SetParameter('content-type','application/x-www-form-urlencoded');
HT.SetParameter('origin','https://m.facebook.com');
HT.SetParameter('refeer','https://m.facebook.com/profile/edit/infotab/section/forms/?section=basic-info');

//HT.SetParameter('content-length','536');

//ToStr(Length(Data))

HT.SetParameter('fb_dtsg',between(' name="fb_dtsg" value="','"',response));
HT.SetParameter('charset_test',between('name="charset_test" value="','"',response));
HT.SetParameter('birthday_day','19');
HT.SetParameter('birthday_month','11');
HT.SetParameter('birthday_year','1995');
HT.SetParameter('privacy[8787510733]',between('name="privacy[8787510733]" value="','"',response));
HT.SetParameter('privacy[8787805733]',between('name="privacy[8787805733]" value="','"',response));
HT.SetParameter('sex_visibility','1');
HT.SetParameter('gender','1');
HT.SetParameter('privacy[8787590733]',between('name="privacy[8787590733]" value="','"',response));
HT.SetParameter('privacy[8787625733]',between('name="privacy[8787625733]" value="','"',response));
HT.SetParameter('privacy[8787645733]',between('name="privacy[8787645733]" value="','"',response));
HT.SetParameter('privacy[8787640733]',between('name="privacy[8787640733]" value="','"',response));
HT.SetParameter('religion','0');
HT.SetParameter('religion_text','');
HT.SetParameter('religion_desc','');
HT.SetParameter('politics','0');
HT.SetParameter('politics_text','');
HT.SetParameter('politics_desc','');
HT.SetParameter('save','Save');
response := HT.GetRawPage;
writeln(response);
HT.Free;
end;

Olly

2014-10-19 16:27:45

Yes, the reason why Simba doesn't read https pages is the fact that you dont have OpenSSL on your computer, In Brandons plugin he static links it hence why it works, and you dont hear anything more about it.

This can't be done in Simba because the two licences aren't compatible (gpl, apache (iirc)). Also according to Dgby what Brandon does breaks their license (not that anyone would care).

I did ask to Wizzup about putting in the plugins updater, and I didn't get a no.. more like he would want some updated openssl because 0.97 or (whatever simba uses) is awful, or something. But I would have to build OpenSSL, and get these libs, But i dont want/know how to do this. :(

Shady?

2014-10-19 16:41:26

I see. I actually have OpenSSL installed, and I can get simba to read other HTTPS pages like https://google.com or https://httpbin.org/post, for example. But on facebook's case, I think they use that X-Frame-Options: DENY header to prevent their pages from being loaded within an iframe… Again, this is just my guess, I'm not sure why simba can't handle that nor why Brandon's plugin does, I'm not nearly as skilled as any of you :/ lol. Let me thank all of you again for your input!

Olly

2014-10-19 16:54:23

From: Shady?
I see. I actually have OpenSSL installed, and I can get simba to read other HTTPS pages like https://google.com or https://httpbin.org/post, for example. But on facebook's case, I think they use that X-Frame-Options: DENY header to prevent their pages from being loaded within an iframe… Again, this is just my guess, I'm not sure why simba can't handle that nor why Brandon's plugin does, I'm not nearly as skilled as any of you :/ lol. Let me thank all of you again for your input!


Yea, I now read that was more your problem but there's a good post out there now for people who wonder why Simba can't read pages (ie Github) for them!

Brandon

2014-10-19 19:15:45

From: Olly
This can't be done in Simba because the two licences aren't compatible (gpl, apache (iirc)). Also according to Dgby what Brandon does breaks their license (not that anyone would care).



Don't know where he got that from but: http://www.apache.org/licenses/GPL-compatibility.html

GPL3 projects can safely use Apache licensed projects perfectly fine.

Also, OpenSSL uses a BSD style license and GPL3 is compatible with the revised license.

OpenSSL license: https://www.openssl.org/source/license.html


I'm distributing a binary (.dll/.so). A binary file is NOT required to print any of the licenses (I could.. I guess). For example, tons of servers use all of the above licenses but they don't print that to your screen every time you connect. They usually keep the licenses in a folder.

However, since none of the code on my github actually contains any of their headers, I'm not required to acknowledge anyone. I didn't copy paste their headers or code into my github. If someone wants to build the plugin, they must compile the external libraries (OpenSSL, ZLib, etc..) on their own.. Now the problem becomes distribution of the plugin.

The problem is that I cannot link GPL code with a BSD built library and re-distribute it. However, I can add the exception to the the lic as described here: http://curl.haxx.se/legal/licmix.html

So all in all, I could be nice and say "this library uses blah blah".. but I don't have to because I don't actually include anyone else's work. I might just have to add "This library uses blah.." or the exception clause now that I looked into it. If I don't, then the GPL copy-right (on my own code) is invalid. In any case, that will basically make the project un-licensed and won't affect anyone.

Example:

In addition, as a special exception, the copyright holders give
permission to link the code of portions of this program with the
OpenSSL library under certain conditions as described in each
individual source file, and distribute linked combinations including
the two.
.
You must obey the GNU General Public License in all respects for all
of the code used other than OpenSSL. If you modify file(s) with this
exception, you may extend this exception to your version of the
file(s), but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version. If you delete
this exception statement from all source files in the program, then
also delete it here.

Olly

2014-10-19 20:01:34

From: Brandon
…


Iirc it's apache 1.0 and that and gpl 3 don't go together.

On phone so it's kinda hard to delete that long post but keep a reply e: removed it!