Hi, i am writing a program that allows me to chat at a website i have an account at. I made the following program which works, but i have to login first, then monitor the traffic and duplicate that.
use WWW::Mechanize; $password = "******"; $url = "https://www.chess.com/login"; my $mech = WWW::Mechanize->new(); $cookie_jar = HTTP::Cookies->new( ); $mech->cookie_jar( $cookie_jar ); $mech->get($url); $mech->submit_form( form_id => "LoginForm", fields => { username=>"tenny", password => $password }, ); die "hmmm" unless ($mech->success); $mech->get("http://live.chess.comlive?v=2014060601"); $req = HTTP::Request->new(POST => 'http://live.chess.com/cometd/'); $req->header(Host=> 'live.chess.com', User-Agent=> 'Mozilla/5.0 (Windows NT 5.1; rv=>14.0) Gecko/20100101 Fi +refox/14.0.1', Accept=> '*/*', Accept-Language=> 'nl,en-us;q=0.7,en;q=0.3', Accept-Encoding=> 'gzip, deflate', Connection=> 'keep-alive', Content-Type=> 'application/json;charset=UTF-8', X-Requested-With=> 'XMLHttpRequest', Referer=> 'http://live.chess.com/live?v=2014060601', Content-Length=> 141, Cookie=> 'Cookie: chess_mw_c16=0; tf_login_id=tenny; cal=eGOaKyvdaqatJ +Q9o6eYICNuw2YJh2%2FunOUYdbS2Jrxf2zmZc7rH8GGGJNqW5%2Bu31tOygjDSTb%2BP8 +NpPiv3gqnLkVQvzCUvNcXH%2BuQ2pFHVfAYjBRZ0e0CBIUB%2BFji7OLsUTdGgXy3qN%2 +FXHBjMXncOmrFm9OikTOGaGsiboJNlHE%3D; PHPSESSID=ihirv1mdt9lhtl94c2jut4 +r3c5; BAYEUX_BROWSER=cf61583lxupwtz2yhwen1hjh2k6; __gads=ID=2810c673b +5b73739:T=1402735047:S=ALNI_MZmG2Hxc2r0d4eiM4JMHXglgcofXg', Pragma=> 'no-cache', Cache-Control=> 'no-cache'); $req->content('{"channel":"/service/user","data":{"txt":"very bad +connection today","id":"R1","sid":"cserv","tid":"Chat"},"id":"2730"," +clientId":"o"}'); $res = $mech->request($req); if ($res->is_success) { print $res->content; } else { print $res->status_line, "\n"; }
Of course i dont want to do it like this so i try to get the required information the official way and by monitoring the http traffic i can see the following information being send to http://live.chess.com/cometd/handshake:
('{"clientFeatures":{"protocolversion":"1.03","clienttype":"LC4Full"," +clientname":"LC4Full v2014060601; Firefox/14; Windows","multiplegames +":true,"examineboard":true},"serviceChannels":["/service/user","/serv +ice/tournament","/service/game","/service/examine"],"version":"1.0"," +minimumVersion":"1.0","channel":"/meta/handshake","supportedConnectio +nTypes":["long-polling","ssl-long-polling","callback-polling"],"advic +e":{"timeout":60000,"interval":0},"id":"1","ext":{"ack":true,"timesyn +c":{"tc":1402752382334,"l":0,"o":0}}}')
After this you get an id nr and some more information needed. Now i tried duplicating this info but i get an error:
[{"id":"1","error":"403::Handshake denied","successful":false,"advice" +:{"reconnect":"none"},"channel":"/meta/handshake","ext":{"timesync {"ts":1402994052362,"t c":1402752382334,"a":-241670028,"p":4},"hfdetails":"authentication-fai +led"}}]
What i wanted to ask if someone can tell me what information is being provided here,and more importantly how does the browser know what info to provide? I hope you can understand my question.Ty
In reply to logging into webserver to enter the chat. by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |