Conexão via socket com o Orkut

7
Jan/09
0

Esse código eu fiz há muito tempo atrás, só fiz algumas alterações e coloquei algumas frases em inglês pra ficar mais bonito. Mas vamos explicar um pouco antes de mostrar o código.

A conexão com o Orkut é beeem fresca, você precisa capturar 2 cookies: Auth & orkut_state.

Pegando o Auth

Faça uma conexão normal (porta 80) com www.google.com.

GET https://www.google.com/accounts/ClientLogin?Email=seu-email&Passwd=sua-senha&service=orkut HTTP/1.1

Caso tenha dado tudo certo, retornará algo mais ou menos assim:

HTTP/1.1 200 OK
Content-Type: text/plain
Cache-control: no-cache, no-store
Pragma: no-cache
Expires: Mon, 01-Jan-1990 00:00:00 GMT
Date: Wed, 07 Jan 2009 21:01:12 GMT
X-Content-Type-Options: nosniff
Content-Length: 563
Server: GFE/1.3
Connection: Close

SID=DQAAAHYAAADowNeryYp…
LSID=DQAAAHgAAABYeM3q3a…
Auth=DQAAAHgAAABYeM3q3a

Salve o valor do Auth e faça uma nova conexão.

Pegando o orkut_state

Abra conexão com o www.orkut.com e mande o GET:

GET /RedirLogin.aspx?auth=valor-do-auth HTTP/1.1

Retornará o orkut_state, nosso segundo cookie-mor.

HTTP/1.1 302 Moved Temporarily
Cache-control: no-cache, must-revalidate, no-cache="Set-Cookie", private
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Pragma: no-cache
Set-Cookie: orkut_state=ORKUTPREF=ID=5495970435752129405:INF=0:SET=33642447:LNG=79:CNT=10:RM=0:USR=bW9yZXR0eUBnbWFpbC5jb20=:...
Domain=www.orkut.com; Path=/; HttpOnly
Set-Cookie: S=neworkut_borg=ADTzEmsvDlBZ4Rh...; Path=/; HttpOnly
Content-Type: text/html; charset=UTF-8

Navegando no Orkut

E agora, finalmente, você poderá fazer uma conexão direta com a Home.aspx, por exemplo… Tendo o orkut_state, você pode navegar em qualquer página do Orkut.

GET /Home.aspx HTTP/1.1
Cookie: orkut_state=valor-do-orkut_state

Código de exemplo feito por mim

alias orkutCookie {
sockclose orkutCookie
sockopen orkutCookie www.google.com 80
hadd -m userSettings logIn $1
hadd userSettings passWd $2-
}

on *:sockopen:orkutCookie: {
echo -a -> Connecting… Getting Auth, LSID and SID cookies from Google.
var %l = sockwrite -n $sockname
%l GET https://www.google.com/accounts/ClientLogin?Email= $+ $hget(userSettings, logIn) $+ &Passwd= $+ $hget(userSettings, passWd) $+ &service=orkut HTTP/1.1
%l Host: www.google.com
%l Connection: Close
%l
}

on *:sockread:orkutCookie: {
sockread %b
if ($regex(%b,^(\w+)=(.+)$)) hadd -m orkutCookies $regml(1) $regml(2)
}

on *:sockclose:orkutCookie:{
echo -a -> Done! Send Auth cookie to Orkut.
sendOrkutCookie
}

;sending auth cookie

alias sendOrkutCookie {
sockclose sendOrkutCookie
sockopen sendOrkutCookie www.orkut.com 80
}

on *:sockopen:sendOrkutCookie: {
var %l = sockwrite -n $sockname
%l GET /RedirLogin.aspx?auth= $+ $hget(orkutCookies, Auth) HTTP/1.1
%l Host: www.orkut.com
%l Connection: Close
%l
}

on *:sockread:sendOrkutCookie: {
sockread %b
if ($regex(%b,^Set-Cookie: orkut_state=(.+)$)) { hadd -m orkutCookies state $regml(1) }
}

on *:sockclose:sendOrkutCookie: {
echo -a -> OK! Orkut state caught! Now, connecting with orkut_state cookie on Orkut.com.
orkutCall
}

alias orkutCall {
sockclose orkutCall
sockopen orkutCall www.orkut.com 80
}

on *:sockopen:orkutCall: {
var %l = sockwrite -n $sockname
%l GET /Home.aspx HTTP/1.1
%l Host: www.orkut.com
%l Cookie: orkut_state= $+ $hget(orkutCookies,state)
%l Connection: Close
%l
}

on *:sockread:orkutCall: {
sockread %b

if ($regex(%b,JSHDF\['uid'\] = '(\d+)')) hadd -m orkutData profileUid $regml(1)
}

on *:sockclose:orkutCall: {
echo -a -> Profile Uid data saved.
echo -a -> author: Thaynã Moretti.
}

Comments (0) Trackbacks (0)

No comments yet.

Leave a comment

No trackbacks yet.