Advertisement
Guest User

Untitled

a guest
Jun 9th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.25 KB | None | 0 0
  1. string mppass(string e,string s)
  2. {
  3.      string request;
  4.      request += "GET /login.jsp HTTP/1.1\r\n";
  5.      request += "Host: minecraft.net\r\n\r\n";
  6.      //request += "username="+e+"&password="+s+"\r\n";
  7.  
  8.  
  9.             SOCKET http;
  10.             char *ipaddress = "69.175.14.242";
  11.             int porta = 80;
  12.             http = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  13.             sockaddr_in lime;
  14.             memset(&lime, 0, sizeof(lime));
  15.             lime.sin_family      = AF_INET;
  16.             lime.sin_addr.s_addr = inet_addr(ipaddress);
  17.             lime.sin_port        = htons((unsigned short) porta);
  18.             connect(http, (struct sockaddr *) &lime, sizeof(lime));
  19.             send(http, request.c_str(), request.length(), 0);
  20.                 //get response
  21.             string response = "";
  22.             int BUFFERSIZE = 512;
  23.             char buffer[512];
  24.             int resp_leng= BUFFERSIZE;
  25.             while (resp_leng == BUFFERSIZE)
  26.             {
  27.             resp_leng= recv(http, (char*)&buffer, BUFFERSIZE, 0);
  28.             if (resp_leng>0)
  29.                 response+= string(buffer).substr(0,resp_leng);
  30.             }
  31.  
  32.             string cookie = "";
  33.             int find = response.find("Set-Cookie:");
  34.             cookie = response.substr(find+string("Set-Cookie: ").length(),32);
  35. //            cerr<<"\n\n"<<"COOKIE:\n"<<cookie<<"\n:COOKIE\n\n";
  36.  
  37.             //cerr<<response<<"\n";
  38.  
  39.  
  40.             request = "";
  41.             request += "POST /login.jsp HTTP/1.1\r\n";
  42.             request += "Host: minecraft.net\r\n";
  43.             request += "Cookie: "+cookie+"\r\n";
  44.             request += "username="+e+"&password="+s+"\r\n\r\n";
  45.  
  46.             cerr<<request<<"\n\n";
  47.             cerr<<"\n\nGOTRESPONCE\n\n";
  48.  
  49.             response = "";
  50.             BUFFERSIZE = 512;
  51.             for(int i = 0; i<512; i++)
  52.                 buffer[i] = 0;
  53.             resp_leng= BUFFERSIZE;
  54.             while (resp_leng == BUFFERSIZE)
  55.             {
  56.             resp_leng= recv(http, (char*)&buffer, BUFFERSIZE, 0);
  57.             if (resp_leng>0)
  58.                 response+= string(buffer).substr(0,resp_leng);
  59.                 cerr<<string(buffer).substr(0,resp_leng);
  60.             }
  61.             closesocket(http);
  62.             return "HI";
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement