mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
connecting to facebook via socks #196715 22/03/08 05:18 AM
Joined: Mar 2008
Posts: 24
T
tparry Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Mar 2008
Posts: 24
Is it possible to connect to facebook via mIRC?
Im using mIRC 6.16.
I have the SSL dlls in my mIRC and system32 ($sslready = $true).
I tried writing this script but the only output I get is "connection made". Any clues?

alias get.fb.login {
sockclose get.fb.login
sockopen -e get.fb.login login.facebook.com 443
}
on *:sockopen:get.fb.login:{
if (!$sockerr) {
var %form = email=me@gmail.com&pass=mypassword
//echo 4 -a connection made
sockwrite -n $sockname POST /login.php HTTP/1.1
sockwrite -n $sockname Host: login.facebook.com
sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
sockwrite -n $sockname Content-Length: $len(%form)
sockwrite -n $sockname Connection: Keep-Alive
sockwrite -n $sockname
sockwrite -n $sockname %form
}
else { //echo -a sockerr }
}

on *:sockread:get.fb.login:{
sockread %temp
//echo -a %temp
}

Re: connecting to facebook via socks [Re: tparry] #196723 22/03/08 12:07 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Change HTTP/1.1 to HTTP/1.0 and see if that helps. It's almost always best to use 1.0 for sockets.


Invision Support
#Invision on irc.irchighway.net
Re: connecting to facebook via socks [Re: Riamus2] #196744 22/03/08 07:58 PM
Joined: Mar 2008
Posts: 24
T
tparry Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Mar 2008
Posts: 24
Yeah I already tried changing to 1.0 before. No difference. Im not getting any output returned.

Re: connecting to facebook via socks [Re: tparry] #196748 22/03/08 08:05 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
This works fine for me.

Re: connecting to facebook via socks [Re: hixxy] #196751 22/03/08 09:03 PM
Joined: Mar 2008
Posts: 24
T
tparry Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Mar 2008
Posts: 24
Originally Posted By: hixxy
This works fine for me.


Hey thanks. That prompted me to try mIRC 6.21 and it works!
I got a popup about a certificate and I accepted it.

HTTP/1.1 302 Found
Date: Sat, 22 Mar 2008 21:01:51 GMT
Server: Apache/1.3.37.fb1
Location: http://www.facebook.com/common/browser.php
Keep-Alive: timeout=60, max=988
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
0


Its redirecting to this url:
http://www.facebook.com/common/browser.php

So now the problem is its saying my browser is not supported. Any way around this?

You are using an incompatible web browser.

Sorry, we're not cool enough to support your browser. Please keep it real with one of the following browsers:

* Firefox
* Opera
* Safari
* Flock


Last edited by tparry; 22/03/08 09:45 PM.
Re: connecting to facebook via socks [Re: tparry] #196754 22/03/08 09:53 PM
Joined: Dec 2002
Posts: 503
B
Bekar Offline
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Fake a User-Agent string.

Re: connecting to facebook via socks [Re: tparry] #196761 22/03/08 11:39 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Send this in your sockopen:

Quote:

User-agent: Opera/9.00 (Windows NT 4.0; U; en)


Invision Support
#Invision on irc.irchighway.net
Re: connecting to facebook via socks [Re: Riamus2] #196805 23/03/08 07:24 AM
Joined: Mar 2008
Posts: 24
T
tparry Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Mar 2008
Posts: 24
Great! Thanks works. Now I get past the browser check.
I seem to be having problems logging in though. I get the cookie, but I seem to end back at the login screen. Heres my code:

Code:
alias fb.login {
  sockclose fb.login
  unset %fb.cookie
  sockopen -e fb.login login.facebook.com 443
}
on *:sockopen:fb.login:{
  if (!$sockerr) {
    var %fb.login = $+(email=me@gmail.com,$chr(38),pass=mypass,$chr(38),persistent=1)
    //echo 4 -a %fb.login
    sockwrite -nt $sockname POST /login.php HTTP/1.1
    sockwrite -nt $sockname Host: login.facebook.com
    sockwrite -nt $sockname User-agent: Opera/9.00 (Windows NT 4.0; U; en)
    sockwrite -nt $sockname Content-Type: application/x-www-form-urlencoded
    sockwrite -nt $sockname Content-Length: $len(%fb.login)
;   sockwrite -nt $sockname Connection: Keep-Alive
    sockwrite -nt $sockname
    sockwrite -nt $sockname %fb.login
  }
  else { //echo -a sockerr }
}

on *:sockread:fb.login:{
  sockread %temp
  //echo -a Out: %temp
  if ($fb.cookie(%temp)) { tokenize 61 $v1 | hadd -m TB.hfs.cookie $1 $2 }
}

alias fb.cookie {
  var %r $regex($1-,/Set-Cookie:([^;]+)|$)/U)
  return $regml(1)
}


...and heres the output:

Code:
Out: HTTP/1.1 200 OK
Out: Date: Sun, 23 Mar 2008 07:17:11 GMT
Out: Server: Apache/1.3.37.fb1
Out: Expires: Mon, 26 Jul 1997 05:00:00 GMT
Out: Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Out: Pragma: no-cache
Out: P3P: CP="HONK"
Out: Set-Cookie: datr=ab0b5084325b9c190859d42801e2666643843c16938855febdd0125ef7bc919c; expires=Tue, 22-Apr-2008 07:17:11 GMT; path=/; domain=.facebook.com; httponly
Out: Set-Cookie: test_cookie=1; path=/; domain=.facebook.com; httponly
Out: Set-Cookie: login=+; path=/; domain=.facebook.com; httponly
Out: Set-Cookie: login_x=me%40gmail.com; expires=Thu, 17-Jul-2008 01:03:51 GMT; path=/; domain=.facebook.com; httponly
Out: Set-Cookie: reg_fb_gate=https%3A%2F%2Flogin.facebook.com%2Flogin.php; path=/; domain=.facebook.com; httponly
Out: Set-Cookie: reg_fb_ref=https%3A%2F%2Flogin.facebook.com%2Flogin.php; path=/; domain=.facebook.com; httponly
Out: Transfer-Encoding: chunked
Out: Content-Type: text/html; charset=utf-8
Out:
Out: 1c4b
Out: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Out: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Out: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="facebook">
Out: <head>
Out: <title>Login | Facebook</title>
Out: <meta http-equiv="Content-type" content="text/html; charset=utf-8" />


I truncated the output. Some lines are too long, and its pretty much just the login/registration form.

Can anyone see why its not logging in? I can log in from firefox, so its not account problem.

Re: connecting to facebook via socks [Re: tparry] #196806 23/03/08 07:49 AM
Joined: Mar 2008
Posts: 24
T
tparry Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Mar 2008
Posts: 24
If i include the Keep-Alive, I get this output. Should I be including it or not?

Code:
Out: HTTP/1.1 200 OK
Out: Date: Sun, 23 Mar 2008 07:46:43 GMT
Out: Server: Apache/1.3.37.fb1
Out: Expires: Mon, 26 Jul 1997 05:00:00 GMT
Out: Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Out: Pragma: no-cache
Out: P3P: CP="HONK"
Out: Set-Cookie: datr=d7f44881e462c6d90042d7e6c53970fcf1702b31f55f7e2e5c829e735b113e91; expires=Tue, 22-Apr-2008 07:46:43 GMT; path=/; domain=.facebook.com; httponly
Out: Set-Cookie: test_cookie=1; path=/; domain=.facebook.com; httponly
Out: Set-Cookie: login=+; path=/; domain=.facebook.com; httponly
Out: Set-Cookie: login_x=me%40gmail.com; expires=Thu, 17-Jul-2008 01:33:23 GMT; path=/; domain=.facebook.com; httponly
Out: Set-Cookie: reg_fb_gate=https%3A%2F%2Flogin.facebook.com%2Flogin.php; path=/; domain=.facebook.com; httponly
Out: Set-Cookie: reg_fb_ref=https%3A%2F%2Flogin.facebook.com%2Flogin.php; path=/; domain=.facebook.com; httponly
Out: Keep-Alive: timeout=60, max=917
Out: Connection: Keep-Alive
Out: Transfer-Encoding: chunked
Out: Content-Type: text/html; charset=utf-8
Out: Set-Cookie: NSC_mphjo=445236773660;expires=Sun, 23-Mar-08 08:01:32 GMT;path=/
Out:
Out: 1c47
Out: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
Out: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Out: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="facebook">
Out: <head>
Out: <title>Login | Facebook</title>
Out: <meta http-equiv="Content-type" content="text/html; charset=utf-8" />

Re: connecting to facebook via socks [Re: tparry] #196807 23/03/08 07:50 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
you *did* log in, that was actually a response for a successful login right there.

as far as subsequent requests go, you need to use that cookie information and send it back to the browser with each request you make (the point of cookies). Yes, you must store and send back all of the data in those Set-Cookie headers... each one. If you don't, facebook has no way of tracking your previous request and can't detect that you are indeed logged in-- even though *you are*.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: connecting to facebook via socks [Re: argv0] #196812 23/03/08 08:45 AM
Joined: Mar 2008
Posts: 24
T
tparry Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Mar 2008
Posts: 24
Originally Posted By: argv0
you *did* log in, that was actually a response for a successful login right there.

as far as subsequent requests go, you need to use that cookie information and send it back to the browser with each request you make (the point of cookies). Yes, you must store and send back all of the data in those Set-Cookie headers... each one. If you don't, facebook has no way of tracking your previous request and can't detect that you are indeed logged in-- even though *you are*.


Are you sure? Because normally when you login you're redirected to your home: http://www.facebook.com/home.php? and im not getting that data back.

Code:
alias get.hfs.recent {
  sockclose get.hfs.recent
  sockopen get.hfs.recent www.facebook.com 80
}

on *:sockopen:get.hfs.recent:{
  if (!$sockerr) {
    var %i 1
    while ($hget(TB.hfs.cookie,%i).item) { var %cookie %cookie $+($v1, =,$hget(TB.hfs.cookie,$v1),;) | inc %i }
    sockwrite -n $sockname GET /home.php? HTTP/1.1
    sockwrite -n $sockname Host: www.facebook.com
    sockwrite -n $sockname User-agent: Opera/9.00 (Windows NT 4.0; U; en)
    sockwrite -n $sockname Accept: */* 
    sockwrite -n $sockname Cookie: %cookie
    sockwrite -n $sockname
  }
  else { //echo -a sockerr }
}

on *:sockread:get.hfs.recent:{
  sockread %temp
  if (%temp != $NULL) {
    //echo -a OUT2: %temp
  }
}


...and the output:

Code:
OUT2: HTTP/1.1 302 Found
OUT2: Date: Sun, 23 Mar 2008 08:43:22 GMT
OUT2: Server: Apache/1.3.37.fb1
OUT2: Expires: Mon, 26 Jul 1997 05:00:00 GMT
OUT2: Cache-Control: private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0
OUT2: Pragma: no-cache
OUT2: P3P: CP="HONK"
OUT2: Set-Cookie: next=http%3A%2F%2Fwww.facebook.com%2Fhome.php%3F; path=/; domain=.facebook.com; httponly
OUT2: Set-Cookie: next_path=%2Fhome.php%3F; path=/; domain=.facebook.com; httponly
OUT2: Set-Cookie: next=http%3A%2F%2Fwww.facebook.com%2Fhome.php%3F; path=/; domain=.facebook.com; httponly
OUT2: Set-Cookie: next_path=%2Fhome.php%3F; path=/; domain=.facebook.com; httponly
OUT2: Location: http://www.facebook.com/login.php
OUT2: Transfer-Encoding: chunked
OUT2: Content-Type: text/html; charset=utf-8
OUT2: 0

Re: connecting to facebook via socks [Re: tparry] #196813 23/03/08 12:08 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
You are probably not redirected there because you aren't sending the cookie information. Basically, you log in, then it goes to redirect you and doesn't have the cookie information, so sends you back to the login screen.

And don't forget that 1.0 will be easier to work with later than 1.1.


Invision Support
#Invision on irc.irchighway.net
Re: connecting to facebook via socks [Re: Riamus2] #196816 23/03/08 01:26 PM
Joined: Mar 2008
Posts: 24
T
tparry Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Mar 2008
Posts: 24
Well after I login, I run "get.hfs.recent" (see my last reply) and im sending the cookie info. The output from that is redirecting me to the login screen. Which makes me believe it didnt login properly.

Re: connecting to facebook via socks [Re: tparry] #196817 23/03/08 02:57 PM
Joined: Mar 2008
Posts: 24
T
tparry Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Mar 2008
Posts: 24
I got it working now.
The only problem im left with is dealing with long strings.
How can I manipulate the html data when I get lines that are 1000+ characters long?

* /echo: line too long (line 28, script1.mrc)

Re: connecting to facebook via socks [Re: tparry] #196831 23/03/08 09:13 PM
Joined: Aug 2006
Posts: 182
T
Thrull Offline
Vogon poet
Offline
Vogon poet
T
Joined: Aug 2006
Posts: 182
I think the only solution is to use binary data, but as I don't do that very often I really can't offer much help with it. Sorry.


Yar
Re: connecting to facebook via socks [Re: tparry] #196832 23/03/08 09:45 PM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
As mentioned above you need to store the data in files or binary variables. /bset or /fopen would be good /help topics to look at


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: connecting to facebook via socks [Re: argv0] #196852 24/03/08 02:28 AM
Joined: Mar 2008
Posts: 24
T
tparry Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Mar 2008
Posts: 24
Originally Posted By: argv0
As mentioned above you need to store the data in files or binary variables. /bset or /fopen would be good /help topics to look at


Ok, so I guess I have no choice but to store it directly to a file. I presume like this:

on *:sockread:test:{ sockread -n &test | bwrite thetest.txt -1 -1 &test }

Since you cant manipulate binary variables, I guess my only choice is to read in the file and manipulate the data.

So do I have to use /fopen and $fread to handle files with really long lines? Is it the only way? The html code im trying to filter only has 200+ lines, but a few of the lines are over 65,000 characters long!

I need to go through the 65,000+ line and filter everything between the text:

<div class="results" (everything in here up to) </table></div>
The data inside is over 2,000 characters, so I'm not sure how im expected to use mIRC to pattern match that.

Is there an easy way to do that? Argh mIRC is so limited smirk

Re: connecting to facebook via socks [Re: tparry] #196856 24/03/08 03:05 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
well, mIRC's script language is built for IRC which has only a ~500 character limit... so what would you even do with more than that much data (in theory)?

The question is, do you really need to grab that much data at a time? most likely, you're only going to need about ~100 bytes of data at a time-- especially if youre planning on sending this over IRC ..

So, with that in mind, you can easily craft matches that return small amounts of data from the complete output

Though, if it were me, I'd just be using Ruby4mIRC, Tcl4mIRC or Python4mIRC to do the work. mIRC really isn't meant for sifting through large amounts of data.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Re: connecting to facebook via socks [Re: argv0] #196858 24/03/08 04:24 AM
Joined: Mar 2008
Posts: 24
T
tparry Offline OP
Ameglian cow
OP Offline
Ameglian cow
T
Joined: Mar 2008
Posts: 24
Correct, I only need small amounts of data which I will store in a hash table.
From the 66,000+ char line, I need to loop through 20 similar sections which contains about 3000 chars each, containing things like name, price, link, img. 95% of the data is just html that I need to discard.

Is it easy to do this in regular mIRC? Otherwise i'll have to get messy and call a perl script or something. I was hoping to keep it tidy and have it all done within mIRC.

I started writing a script (using fopen/fseek/$fread) which seeks through the long lines in sections of 200 bytes, but the problem is sometimes the data falls either side of the 200 byte chunks. Rather messy. smirk

Re: connecting to facebook via socks [Re: tparry] #196859 24/03/08 06:17 AM
Joined: Oct 2003
Posts: 3,918
A
argv0 Offline
Hoopy frood
Offline
Hoopy frood
A
Joined: Oct 2003
Posts: 3,918
how do you know you cant get at the data in first pass as it comes in from the sockread?

all you'd need to do would be apply a regex to the incoming data

Code:
sockread %temp
if ($regex(%temp,/<p class="username">(.+?)</p>/)) {
  echo -a username is $regml(1)
}


While it's not exactly the most robust solution, this approach works 95% of the time because there is usually some unique data string you can search for surrounding every piece of data you need to extract.


- argv[0] on EFnet #mIRC
- "Life is a pointer to an integer without a cast"
Page 1 of 2 1 2