mIRC Homepage
Posted By: Kuribo Sockets and cookies - 19/08/05 07:21 PM
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.
Posted By: SladeKraven Re: Sockets and cookies - 19/08/05 07:33 PM
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
Posted By: Riamus2 Re: Sockets and cookies - 19/08/05 07:48 PM
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.
Posted By: IR_n00b Re: Sockets and cookies - 20/08/05 10:45 PM
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:
Posted By: stefys99 Re: Sockets and cookies - 21/08/05 12:29 PM
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
Posted By: Kuribo Re: Sockets and cookies - 25/08/05 11:40 PM
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.
Posted By: IR_n00b Re: Sockets and cookies - 26/08/05 12:20 AM
i think (not sure) that it only works with two crlfs after the last line youre sending
Posted By: Kuribo Re: Sockets and cookies - 26/08/05 03:13 PM
Ah yes, only the last line needs crlfs.

Thank you. =D
© mIRC Discussion Forums