SwiftIRC
IRC Discussion and Support
 
  Index  •  FAQ  •  Search  

It is currently Thu Aug 28, 2014 7:04 am




Post new topic Reply to topic  [ 2 posts ] 
 POST socket 
Author Message
 Post subject: POST socket
PostPosted: Mon Jan 04, 2010 4:48 am 
User
User

Joined: Sun Feb 15, 2009 7:11 am
Posts: 21
I'm using this code:
Code:
alias eRepinit {
  set %e_usrn $1
  set %e_pwd $2
  set %e_search $3
  sockopen einit www.erepublik.com 80
}
on *:sockopen:einit: {
  var -s %data remember=1&citizen_name= $+ %e_usrn $+ &citizen_password= $+ %e_pwd

  sockwrite -n $sockname POST /en/login HTTP/1.1
  sockwrite -n $sockname Host: www.erepublik.com

  sockwrite -n $sockname Content-Type: application/x-www-form-urlencoded
  sockwrite -n $sockname Content-Length: $len(%data)

  sockwrite -n $sockname $crlf $+ %data
}
on *:sockread:einit: {
  var %x
  sockread %x
  if (Set-Cookie:* iswm %x) {
    ;set -s %e_cookie $replace($remove($gettok(%x,2-,32),$chr(32)),;,&)
    set -s %e_cookie $remove($gettok(%x,2,32),;)
    ;set -s %e_cookie $replace($remove(%e_cookie,$chr(32)),;,&)
    eRepSearch
  }
}
alias eRepSearch {
  sockopen eSearch www.erepublik.com 80
}
on *:sockopen:eSearch: {
  ;http://www.erepublik.com/en/search/?q=sketchz&commit=
  sockwrite -n $sockname GET /en/search/?q= $+ %e_search $+ &commit= HTTP/1.1
  sockwrite -n $sockname Host: www.erepublik.com
  echo -s sockwrite -n $sockname Cookie: %e_cookie
  sockwrite -n $sockname Cookie: erpk=b387f42c14e7f0c856cca69ff69a0dfd
  sockwrite -n $sockname $crlf
}
on *:sockread:eSearch: {
  var %x
  sockread %x
  echo -s $iif(%x,%x,-null-)
}


But it's not logging me in correctly to even begin with. Any help?


Offline
 Profile  
 
 Post subject: Re: POST socket
PostPosted: Tue Jan 05, 2010 5:50 am 
User
User

Joined: Fri Sep 11, 2009 12:28 am
Posts: 45
Hey, I'm no expert with this stuff, but this is what I did and it worked for me.

First I loaded the login page using a plain old GET request:
Code:
GET /en/login HTTP/1.1<crlf>
Host: www.erepublik.com<crlf>
<crlf>


Important received lines:
Code:
Set-Cookie: erpk=932afcd254de6decc5c8004e09a5afef; path=/; domain=.erepublik.com
Set-Cookie: lfrc=0; expires=Fri, 08-Jan-2010 05:04:31 GMT; path=/
   <form class="login" method="post" action="/en/login"><input type="hidden" id="_token" name="_token" value="0067a84dff1c34baae800f22643d9b16" />      <div class="largepadded">


I then stored the cookies and the value of _token, and sent this POST request:
Code:
POST /en/login HTTP/1.1<crlf>
Host: www.erepublik.com<crlf>
Cookie: erpk=932afcd254de6decc5c8004e09a5afef; lfrc=0<crlf>
Content-Type: application/x-www-form-urlencoded<crlf>
Content-Length: 99<crlf>
<crlf>
_token=0067a84dff1c34baae800f22643d9b16&citizen_name=Mr_K_13&citizen_password=test&commit=Login<crlf>


If that's all good, you should get a response containing a Location header and some more cookies.
This means you've logged in.
Code:
Location: http://www.erepublik.com/en
Set-Cookie: lfrc=0; expires=Fri, 08-Jan-2010 05:04:33 GMT; path=/
Set-Cookie: lfrc=0; expires=Fri, 08-Jan-2010 05:04:33 GMT; path=/
Set-Cookie: erpk_mid=4c0d9a57a40df51b3677ec43ea0f2f4c; expires=Wed, 05-Jan-2011 05:04:33 GMT; path=/


Now just to make sure I was actually logged in, I loaded the page the Location header said, by sending the following:
Code:
GET /en HTTP/1.1<crlf>
Host: www.erepublik.com<crlf>
Cookie: erpk=932afcd254de6decc5c8004e09a5afef; lfrc=0; erpk_mid=4c0d9a57a40df51b3677ec43ea0f2f4c<crlf>
<crlf>


Like I said at the start.. I'm no expert on this stuff. I might have done something the long way. Hopefully not. =)

I hope this is enough info for you to do the same.

Good luck.


Offline
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 


 Who is online 

Users browsing this forum: Google [Bot], Yahoo [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 
Index  |  FAQ  |  Search

phpBB skin developed by: John Olson
Protected by Anti-Spam ACP
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group