Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string mppass(string e,string s)
- {
- string request;
- request += "GET /login.jsp HTTP/1.1\r\n";
- request += "Host: minecraft.net\r\n\r\n";
- //request += "username="+e+"&password="+s+"\r\n";
- SOCKET http;
- char *ipaddress = "69.175.14.242";
- int porta = 80;
- http = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- sockaddr_in lime;
- memset(&lime, 0, sizeof(lime));
- lime.sin_family = AF_INET;
- lime.sin_addr.s_addr = inet_addr(ipaddress);
- lime.sin_port = htons((unsigned short) porta);
- connect(http, (struct sockaddr *) &lime, sizeof(lime));
- send(http, request.c_str(), request.length(), 0);
- //get response
- string response = "";
- int BUFFERSIZE = 512;
- char buffer[512];
- int resp_leng= BUFFERSIZE;
- while (resp_leng == BUFFERSIZE)
- {
- resp_leng= recv(http, (char*)&buffer, BUFFERSIZE, 0);
- if (resp_leng>0)
- response+= string(buffer).substr(0,resp_leng);
- }
- string cookie = "";
- int find = response.find("Set-Cookie:");
- cookie = response.substr(find+string("Set-Cookie: ").length(),32);
- // cerr<<"\n\n"<<"COOKIE:\n"<<cookie<<"\n:COOKIE\n\n";
- //cerr<<response<<"\n";
- request = "";
- request += "POST /login.jsp HTTP/1.1\r\n";
- request += "Host: minecraft.net\r\n";
- request += "Cookie: "+cookie+"\r\n";
- request += "username="+e+"&password="+s+"\r\n\r\n";
- cerr<<request<<"\n\n";
- cerr<<"\n\nGOTRESPONCE\n\n";
- response = "";
- BUFFERSIZE = 512;
- for(int i = 0; i<512; i++)
- buffer[i] = 0;
- resp_leng= BUFFERSIZE;
- while (resp_leng == BUFFERSIZE)
- {
- resp_leng= recv(http, (char*)&buffer, BUFFERSIZE, 0);
- if (resp_leng>0)
- response+= string(buffer).substr(0,resp_leng);
- cerr<<string(buffer).substr(0,resp_leng);
- }
- closesocket(http);
- return "HI";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement