Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   С/С++, C#, Delphi, .NET, Asm (https://forum.antichat.xyz/forumdisplay.php?f=24)
-   -   [VK] base64 (https://forum.antichat.xyz/showthread.php?t=190766)

cel 27.03.2010 13:33

[VK] base64
 
Памогите пожалуйсто сделать автаризацию, я уже неделю голову ламаю.

Вот код:

PHP код:

var
 
PageText TStringList;
 
PostData TStringList;
 
TempStr  string;
 
I        Integer;
begin
    
Создаем объекты в памяти }
     
HTTP := TidHTTP.Create(nil);
     
Cookie := TidCookieManager.Create(HTTP);
     
PageText := TStringList.Create;
     
PostData := TStringList.Create;

    { 
Задаем нужные параметры }
     
HTTP.Request.UserAgent := 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ru; rv:1.9.1.7) Gecko/20091221 MRA 5.6 (build 03278) Firefox/3.5.7 sputnik unknown';
     
HTTP.Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
     
HTTP.Request.AcceptLanguage := 'ru,en-us;q=0.7,en;q=0.3';
     
HTTP.Request.Connection := 'keep-alive';
     
HTTP.Request.Referer := 'http://vk.com/login.php';
     
HTTP.Request.ContentType := 'application/x-www-form-urlencoded; charset=UTF-8';
     
HTTP.Request.AcceptCharset := 'windows-1251,utf-8;q=0.7,*;q=0.7';
     
HTTP.CookieManager := Cookie;
     
HTTP.AllowCookies := True;
     
HTTP.HandleRedirects := True;

    { 
1. Запрос на страницу }
     
HTTP.Post('http://vk.com/login.php'PostData);

    { 
2. Формируем запрос }
     
PostData.Add('act=login');
     
PostData.Add('email=' edit1.Text);
     
PostData.Add('pass=' edit2.Text);

     
PageText.Text := HTTP.Post('http://login.vk.com/'PostData);



     For 
:= 0 To PageText.Count -do
     
begin
       
If Pos('id=' #39 + 's' + #39, PageText[I]) <> 0 Then
       
begin
          TempStr 
:= PageText[I];
          
TempStr := Copy(TempStrPos('value='TempStr) +7Length(TempStr));
          
Delete(TempStrPos(#39, TempStr), Length(TempStr));
       
end;
     
end;

    { 
3. Отсылаем ключ на сервер }
     
PostData.Clear;
     
PostData.Add('op=slogin');
     
PostData.Add('s=' TempStr);

     
HTTP.Post('http://vk.com/login.php'PostData);

    
HTTP.GET('http://vk.com/profile.php');

     
PageText.Free;
     
PostData.Free

Он меня наченает кидать с профиля на логин
http://vk.com/login.php?u=1&to=cHJvZmlsZS5waHA-

cHJvZmlsZS5waHA- - base64 profile.php

Как это можно обойти,или как и куда приррутить decode base64 ?

cel 27.03.2010 14:23

Хм... разве некто не знает как это сделать?

Kaimi 27.03.2010 14:48

Цитата:

Хм... разве некто не знает как это сделать?
Хм... Разве так трудно воспользоваться поиском и найти пример авторизации?
http://u.nu/9xvw7
https://forum.antichat.ru/thread180075.html
https://forum.antichat.ru/thread175598.html

cel 27.03.2010 14:53

Цитата:

Сообщение от Kaimi
Хм... Разве так трудно воспользоваться поиском и найти пример авторизации?
http://u.nu/9xvw7
https://forum.antichat.ru/thread180075.html
https://forum.antichat.ru/thread175598.html

поиском я пользовался, жаль тока я не нашол раюочих ответов(

cel 27.03.2010 16:12

Подскажите хотябы напровление по теме

Jingo Bo 27.03.2010 16:47

Ня! недавно ток сделал, код кривой потому что декомпилированный и портированный, оптимизировать не составит труда.
Правда если в конце url "--" то меняй(в твоём случае)
Код:

      BASE64_CHARS : String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
на
Код:

      BASE64_CHARS : String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/-';
Вот сам код :
Код:

const version : String = '1.0.0';
      BASE64_CHARS : String = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
function encode(inStr : String) : String;
Var ba : TByteArray;
    utf : String;
Begin
    utf := AnsiToUtf8(inStr);
    SetLength(ba, Length(utf));
    Move(utf[1], ba[0], Length(utf));
    Result := encodeByteArray(ba);
end;
function encodeByteArray(data : TByteArray) : String;
Var inBuf : Array of Byte;
    i, j, k : Cardinal;
    outBuf : array[0..3] of Byte;
    dataPos : Cardinal;
Begin
    dataPos := 0; Result := '';
    i := 0;
    while (dataPos <= High(data)) do
    Begin
        SetLength(inBuf, 3);
        FillChar(inBuf[0], 3, 0);
        i := 0;
        while ((i < 3) and (dataPos <= High(data))) do
        Begin
            inBuf[i] := data[dataPos];
            i := i + 1;
            Inc(dataPos);
        end;
        outBuf[0] := (inBuf[0] and 252) shr 2;
        outBuf[1] := ((inBuf[0] and 3) shl 4) or (inBuf[1] shr 4);
        outBuf[2] := ((inBuf[1] and 15) shl 2) or (inBuf[2] shr 6);
        outBuf[3] := inBuf[2] and 63;
        while (i < 3) do
        Begin
            outBuf[(i + 1)] := 64;
            i := i + 1;
        end;
        k := 0;
        while (k < 4) do
        Begin
            Result := Result + BASE64_CHARS[outBuf[k]+1];
            k := k + 1;
        end;
    end;
end;

function decode (inStr : String) : String;
Var ba : TByteArray;
    utf : String;
Begin
    ba := decodeToByteArray(inStr);
    SetLength(utf, High(ba)+1);
    Move(ba[0], utf[1], High(ba)+1);
    Result := System.Utf8ToAnsi(utf);
end;

function decodeToByteArray(data : String) : TByteArray;
Var
    i, j, k : Cardinal;
    inBuf : Array[0..3] of Byte;
    outBuf : Array[0..2] of Byte;
    _HypArray : TByteArray;
    _HypLength : Cardinal;
const ReAlignStep = 1024*1024*512; {Эт для того что бы менеджер память по байту не насиловать}
Begin
    i := 0; _HypLength := 0;
    SetLength(_HypArray, ReAlignStep);
    while (i < Length(data)) do
    Begin
        j := 0;
        while ((j < 4) and (i + j < Length(data))) do
        Begin
            inBuf[j] := Pos(data[i + j + 1], BASE64_CHARS) - 1;
            Inc(j);
        end;
        outBuf[0] := (inBuf[0] shl 2) + ((inBuf[1] and 48) shr 4);
        outBuf[1] := ((inBuf[1] and 15) shl 4) + ((inBuf[2] and 60) shr 2);
        outBuf[2] := ((inBuf[2] and 3) shl 6) + inBuf[3];
        k := 0;
        while (k < 3) do
        Begin
            if (inBuf[(k + 1)] = 64) then
              Break;
            _HypArray[_HypLength] := outBuf[k];
            Inc(_HypLength);
            if _HypLength > High(_HypArray) then
                SetLength(_HypArray, High(_HypArray)+ReAlignStep+1);
            Inc(k);
        end;
        Inc(i, 4);
    end;
    SetLength(Result, _HypLength);
    Move(_HypArray[0], Result[0], _HypLength);
end;


cel 27.03.2010 17:14

как декодировать я знаю, я незнаю куда это применить

cel 27.03.2010 17:32

Актуально

cel 27.03.2010 19:30

ответце ктонебуть пожалуйсто

Fliplab 27.03.2010 19:42

http://s.3po.ru/trunk/ - сорсы Vkonpic. Смотри модуль Auth.


Время: 16:00