Welp, it works, but what a monster of a code... :tongue:

The problem I encountered is first of all, that I need a crucial temp cookie before being able to login, so I cannot even start of with immediately using POST to login, since I need part of this temp cookie in the POST address.

Apart from that I suppose it goes well.

Here's how it works.

  1. You issue /bb.getid, which is the code to retrieve the temporary cookie, which contains the sid, which we need.
  2. Once we have saved this sid in a global variable, along with another temporary cookie (data), we can login using POST.

    The temp cookie is %bb.tmpcookie, and contains the following:

    a mysql_sid part, which we will keep using throughout the code
    a mysql_data part, which will be replaced with another value once we've logged in.
  3. Use /bb.login, which will prompt you for a username and password, to login. The POST will do it's job, making you login, and creating the permanent cookie with the correct data. This cookie is stored in %bb.cookie. We'll use this cookie to make a new thread in the general discussion forum.
  4. Since the cookie is done, we can now post a thread, with /bb.post. I've added some prefab subject and body to be messaged, you will see it in the code. The text needs to be encoded, I've added a $bb.encode identifier that takes care of that.
  5. Welp, that's it, once you've posted, you will find it on the specified forum.

  • Some things to mention:
  • Basically ever forum on that link you gave me, has an index number. Fex the first forum there, General Discussion, the one I tested in has ID 10, which you can see by hovering over the link, it will say: http://www.kakkoiitranslations.net/phpBB2/viewforum.php?f=10

    So the f=10 is what we want to know.
  • However, we want to post in this forum, a new thread. I follow the link to view the forum, and now navigate over the New Topic button, which gives: http://www.kakkoiitranslations.net/phpBB2/posting.php?mode=newtopic&f=10

    That's the Referer that I use when using POST to send the message. The important part here is the last part: mode=newtopic&f=10
    which will be part of the message sent as you will see in the code.

Now the code (mamma mia):

Code:
alias bb.encode {
  var %a = 1, %b = $replace($1-,$chr(32),+), %c, %d
  while $mid(%b,%a,1) {
    %c = $v1
    %d = %d $+ $iif($regex(%c,/[a-z+]/i),%c,% $+ $base($asc(%c),10,16,2))
    inc %a
  }
  return %d
}
 [color:red]  [/color] 
alias bb.getid {
  sockopen bb.getid kakkoiitranslations.net 80
}
 [color:red]  [/color] 
on *:sockopen:bb.getid:{
  if $sockerr { echo -a error: $v1 | return }
  var %s = sockwrite -n $sockname
  %s GET /phpBB2/login.php HTTP/1.1
  %s Host: www.kakkoiitranslations.net $str($crlf,2)
}
 [color:red]  [/color] 
on *:sockread:bb.getid:{
  if $sockerr { echo -a error: $v1 | return }
  var %a
  sockread %a
  tokenize 32 %a
  if $1 == Set-Cookie: { %bb.tmpcookie = %bb.tmpcookie $2 }
  elseif $1 == $null {
    sockclose bb.getid
    if $numtok(%bb.tmpcookie,32) == 2 {
      echo 04 -a Successfully retrieved temp cookie, you may now login. (/bb.login)
    }
    else echo 04 -a Error retrieving temp cookie
  }
}
 [color:red]  [/color] 
alias bb.login {
  var %userpass = $input(Enter user name,eo) $input(Enter password,eop)
  if $numtok(%userpass,32) != 2 {
    echo -a /bb.login: you must specify both username and password to login
    return
  }
  sockopen bb.login kakkoiitranslations.net 80
  sockmark $sock(bb.login) %userpass
}
 [color:red]  [/color] 
on *:sockopen:bb.login:{
  if $sockerr { echo -a error: $v1 | return }
  tokenize 32 $sock(bb.login).mark
  var %s = sockwrite -n $sockname
  var %data = $+(username=,$1,&password=,$2,&redirect=&login=Log+in)
  ; Here's the first reason why we needed that temp cookie, that is the sid value is part of the login.
  %s POST /phpBB2/login.php?sid= $+ $gettok($gettok(%bb.tmpcookie,2,32),2,61) HTTP/1.1
  %s Referer: http://www.kakkoiitranslations.net/phpBB2/login.php
  %s Content-Type: application/x-www-form-urlencoded
  %s Host: www.kakkoiitranslations.net
  %s Content-Length: $len(%data)
  %s Connection: Keep-Alive
  ; Here's the second reason we needed that temp cookie: to get the final cookie.
  ; I tried, it does not work without sending a temp cookie first.
  %s Cookie: %bb.tmpcookie
  %s
  %s %data
}
 [color:red]  [/color] 
on *:sockread:bb.login:{
  if $sockerr { echo -a error: $v1 | return }
  var %a
  sockread %a
  tokenize 32 %a
  if $1 == Set-Cookie: { %bb.cookie = $2 $gettok(%bb.tmpcookie,2,32) }
  elseif $1 == $null {
    sockclose bb.login
    if $numtok(%bb.cookie,32) != 2 {
      echo 04 -a Could not login with the specified user/pass, please try again
    }
    else echo 04 -a Logged in. You can now create a new post if you like. (/bb.post)
  }
}
 [color:red]  [/color] 
alias bb.post {
  sockopen bb.post kakkoiitranslations.net 80
}
 [color:red]  [/color] 
on *:sockopen:bb.post:{
  if $sockerr { echo -a error: $v1 | return }
  var %s = sockwrite -n $sockname
  var %subject = $bb.encode(some more tests)
  var %subject = subject= $+ %subject
  var %message = $&
    This is a small test to see if I can post a new topic with the user of $&
    sockets in mIRC. $str($crlf,2) $&
    I'll post the quote that I use in my mIRC signature, being: $str($crlf,2) $&
    "In theory, there is no difference between theory and practice, $&
    but in practice there is." $str($crlf,3) $&
    Well that's it for now, I think it works pretty well, although the $&
    retrieving of the cookie is kinda annoying. $str($crlf,2) $&
    Greets, $crlf FiberOPtics
  var %message = &message= $+ $bb.encode(%message)
  var %append = &mode=newtopic&f=10&post=Submit
  var %data = $+(%subject,%message,%append)
  %s POST /phpBB2/posting.php HTTP/1.1
  %s Referer: http://www.kakkoiitranslations.net/phpBB2/posting.php?mode=newtopic&f=10
  %s Content-Type: application/x-www-form-urlencoded
  %s Host: www.kakkoiitranslations.net
  %s Content-Length: $len(%data)
  %s Connection: close
  %s Cookie: %bb.cookie
  %s
  %s %data
  echo 04 -a Posting new thread on forums...
}


I think that should suffice to help you well on your way. Some suggestions:

Since you can sockwrite binvars, you could create the message in a text file, run /filter over it with -k flag (or any other means), to encode each line with the $bb.encode identifier. Then when you are going to post the message, bread it in a binvar, and make sure you put the subject first, and the append thing last, as showed in the code. You'll figure it out.

Another thing, I don't know what the limit is, but I'm sure there's a limit for the length of the subject, so that might give a problem if you take one that is too long. That means you should parse the reply that you get after POSTing. That'd be a sockread event for socket bb.post.

I have put all code seperate, that is instead of using one sockread event bb.* I've kept it seperate so that you don't get lost in all the code. NOrmally I'd probably make it quite smaller by incorporating all code together.

Another issue: I don't know how long the cookie lasts, in my tests I could keep posting new threads with the same cookie information, so that all you need after going through all steps, is /bb.post. At one point, I can imagine the cookie to expire, so you should check for that too by parsing the html received after trying to make a thread.

Btw don't go through the steps of /bb.getid and /bb.login before unsetting the previous cookies lol, or it definitely won't work.

There could be more things to add, but well, I'll leave it over to you, after all, it's your script, not mine smile

Man, I feel like I could make all of this a lot prettier, and have some optimizations here and there, but to be honest, I feel very lazy :tongue:


Gone.