mIRC Home    About    Download    Register    News    Help

Print Thread
Sockets and cookies #128008 19/08/05 07:21 PM
Joined: Aug 2005
Posts: 3
K
Kuribo Offline OP
Self-satisified door
OP Offline
Self-satisified door
K
Joined: Aug 2005
Posts: 3
I'm trying to get an mIRC bot to log into a forum, but so far haven't succeeded.

What I have so far:

Code:
alias forum {
  sockopen forum forum.com 80
}

on *:sockopen:forum:{ 
  write -c forum.html
  sockwrite -n $sockname GET / HTTP/1.1
  sockwrite -n $sockname Host: $+(forum.com,$crlf, $crlf)
}

on *:sockread:forum:{
  if ($sockerr) {
    echo -a Error.
    halt
  }
  else {
    var %temptext
    sockread %temptext
    write forum.html %temptext
  }
}


I somehow need to send it the cookies, so it will recognize me as logged in.
I've tried things like: sockwrire -n $sokname Cookie: etc, but it didn't work.

Re: Sockets and cookies #128009 19/08/05 07:33 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You need to get the page you're logging into.

GET /login.php?u=nick&p=pass HTTP/1.1 for example.

Or just GET /login.php HTTP/1.1

-Andy

Re: Sockets and cookies #128010 19/08/05 07:48 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I recommend getting the IE plugin IEWatch if you're going to work with sockets and cookies. It allows you to view your http requests on a site and you can almost directly paste the results into mIRC's script (just sticking it after the sockwrite commands). If you have Firefox, I believe there's a way to see them in there as well.


Invision Support
#Invision on irc.irchighway.net
Re: Sockets and cookies #128011 20/08/05 10:45 PM
Joined: Sep 2004
Posts: 200
I
IR_n00b Offline
Fjord artisan
Offline
Fjord artisan
I
Joined: Sep 2004
Posts: 200
eww... IE..

use FireFox, search for Live HTTP Headers, then install it restart firefox, then check all the menus (file, ect) for it, then click on it, and go to the site.
FireFox tells you EXACLTY what was sent to it and what it sent out. You can go from there :tongue:

Re: Sockets and cookies #128012 21/08/05 12:29 PM
Joined: Aug 2005
Posts: 128
S
stefys99 Offline
Vogon poet
Offline
Vogon poet
S
Joined: Aug 2005
Posts: 128
Quote:
You need to get the page you're logging into.

GET /login.php?u=nick&p=pass HTTP/1.1 for example.

Or just GET /login.php HTTP/1.1

-Andy

Password data are usually sent with POST.

Code:
var %data = user=stefys&pass=mysecretpass
sockwrite -n $sockname POST /login.php HTTP/1.1
sockwrite -n $sockname Host: www.forum.com
sockwrite -n $sockname Content-Length: $len(%data)
sockwrite -n $sockname $crlf
sockwrite -n $sockname %data

But that won't work anyway.. since it's redirecting you to a page that sets cookies, and you won't have them set, since you don't have a real browser. You can read the Cookie: that server sent and set it in a variable. And next time you go to forum, use that cookie shocked

Re: Sockets and cookies #128013 25/08/05 11:40 PM
Joined: Aug 2005
Posts: 3
K
Kuribo Offline OP
Self-satisified door
OP Offline
Self-satisified door
K
Joined: Aug 2005
Posts: 3
I didn't think going to login.php would help much, cause that's where I get the cookie. I have tried it, and it gave me the "thank you for logging in" page.

I logged in with my browser and copied the cookie into mirc.

Code:
on *:sockopen:forum:{ 
  sockwrite -n $sockname GET / HTTP/1.1
  sockwrite -n $sockname Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, $+($chr(42),/,$chr(42)) $+ $crlf $+ $crlf
  sockwrite -n $sockname Accept-Language: nl $+ $crlf $+ $crlf
  sockwrite -n $sockname Accept-Encoding: gzip, deflate $+ $crlf $+ $crlf
  sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) $+ $crlf $+ $crlf
  sockwrite -n $sockname Host: www.forum.com $+ $crlf $+ $crlf
  sockwrite -n $sockname Connection: Keep-Alive $+ $crlf $+ $crlf
  sockwrite -n $sockname Cookie: bblastvisit=x; bblastactivity=x; bbuserid=x; bbpassword=x $+ $crlf $+ $crlf
}


That was what my browser was sending (I replaced the real cookie data with x's).
When I tried this, it gave the index page as though I wasn't logged in.

Last edited by Kuribo; 25/08/05 11:42 PM.
Re: Sockets and cookies #128014 26/08/05 12:20 AM
Joined: Sep 2004
Posts: 200
I
IR_n00b Offline
Fjord artisan
Offline
Fjord artisan
I
Joined: Sep 2004
Posts: 200
i think (not sure) that it only works with two crlfs after the last line youre sending

Re: Sockets and cookies #128015 26/08/05 03:13 PM
Joined: Aug 2005
Posts: 3
K
Kuribo Offline OP
Self-satisified door
OP Offline
Self-satisified door
K
Joined: Aug 2005
Posts: 3
Ah yes, only the last line needs crlfs.

Thank you. =D