Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class MySock {
- public:
- static MySock& Instance() {
- static MySock ms;
- return ms;
- }
- WSADATA wsaData;
- SOCKET mySocket;
- bool InitWinSock();
- struct addrinfo *results = NULL, *prt = NULL, hints;
- bool ConfigureSock();
- bool Connect();
- void Disconnect();
- bool Login(string buf);
- };
- bool MySock::InitWinSock() {
- if (int result = WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
- printf_s("WSAStartup failed: %d\n", result);
- return false;
- }
- return true;
- }
- bool MySock::ConfigureSock() {
- ZeroMemory(&hints, sizeof(hints));
- hints.ai_family = AF_INET;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_protocol = IPPROTO_TCP;
- int result = getaddrinfo("WEBSITE REMOVED", "80", &hints, &results);
- if (result != 0) {
- printf_s("getaddrinf failed: %d\n", result);
- WSACleanup();
- return false;
- }
- else {
- prt = results;
- }
- mySocket = socket(results->ai_family, results->ai_socktype, results->ai_protocol);
- if (mySocket == INVALID_SOCKET) {
- printf_s("Error at socket(): %l\n", WSAGetLastError());
- freeaddrinfo(results);
- WSACleanup();
- return false;
- }
- printf_s("Connected to: WEBSITE REMOVED \n");
- return true;
- }
- bool MySock::Connect() {
- int result = connect(mySocket, prt->ai_addr, (int)prt->ai_addrlen);
- if (result == SOCKET_ERROR) {
- freeaddrinfo(results);
- Disconnect();
- return false;
- }
- return true;
- }
- void MySock::Disconnect() {
- closesocket(mySocket);
- WSACleanup();
- cout << "Disconnected!" << endl;
- }
- bool MySock::Login(string buf) {
- if (!InitWinSock()) return false; //ok
- if (!ConfigureSock()) return false; //ok
- if (!Connect()) { //ok
- Disconnect();
- return false;
- }
- //send
- int result = send(mySocket, buf.c_str(), buf.size(), 0);
- if (result == SOCKET_ERROR) {
- printf_s("send failed: %d\n", WSAGetLastError());
- Disconnect();
- return false;
- }
- else {
- // cout << buf.c_str() << endl;
- printf_s("Sending...\n");
- printf_s("Bytes Sent: %ld\n", result);
- }
- result = shutdown(mySocket, SD_SEND);
- if (result == SOCKET_ERROR) {
- printf_s("shutdown failed: %d\n", WSAGetLastError());
- Disconnect();
- return false;
- }
- //recv
- int recvbuflen = 512;
- char recvbuf[512];
- result = recv(mySocket, recvbuf, recvbuflen, 0);
- if (result > 0) {
- printf_s("Bytes received: %d\n", result);
- printf_s("Checking...\n");
- string response = string(recvbuf);
- if (response.find("index_hwid.php") != string::npos) {
- printf_s("NO LOGIN!\n");
- }
- else if (response.find("login_success_HWID.php") != string::npos) {
- printf_s("LOGGED ON!\n");
- }
- // cout << response << endl;
- }
- else if (result == 0)
- printf_s("Connection closed\n");
- else
- printf_s("recv failed: %d\n", WSAGetLastError());
- Disconnect();
- return true;
- }
- class HwidF {
- public:
- static HwidF& Instance() {
- static HwidF hwidf;
- return hwidf;
- }
- void SystemLetter(TCHAR *vol);
- string ID();
- };
- void HwidF::SystemLetter(TCHAR *vol) {
- TCHAR buffer[30];
- GetSystemWindowsDirectory(buffer, 30);
- for (int i = 0; i < 2; i++)
- vol[i] = buffer[i];
- vol[2] = 0;
- }
- string HwidF::ID() {
- TCHAR vol[3];
- SystemLetter(vol);
- string letter = string(vol) + "\\";
- string ss;
- ss = "Err_StringIsNull";
- UCHAR szFileSys[255],
- szVolNameBuff[255];
- DWORD dwSerial;
- DWORD dwMFL;
- DWORD dwSysFlags;
- int error = 0;
- BOOL success = GetVolumeInformation(LPCTSTR(letter.c_str()), (LPTSTR)szVolNameBuff,
- 255, &dwSerial,
- &dwMFL, &dwSysFlags,
- (LPTSTR)szFileSys,
- 255);
- if (!success) {
- ss = "Err_Not_Elevated";
- }
- std::stringstream errorStream;
- errorStream << dwSerial;
- return string(errorStream.str().c_str());
- }
- char username[MAX_PATH];
- char password[MAX_PATH];
- cout << "Username:" << endl;
- cin >> username;
- cout << "Password:" << endl;
- cin >> password;
- string FinalID = HwidF::Instance().ID();
- cout << " === Summary ===" << endl;
- cout << " Username: " << username << " Password: " << password << endl;
- cout << " Your HWID: " << FinalID << endl;
- string logininfo = "user=" + string(username) + "&pass=" + string(password) + "&hwid=" + FinalID;
- int loginInfoSize = logininfo.length();
- string header;
- header = "POST /index_hwid.php HTTP/1.1\r\n";
- header += "Host: WEBSITE REMOVED:80\r\n";
- header += "Content-Type: application/x-www-form-urlencoded\r\n";
- header += "Content-Length: " + to_string(loginInfoSize) + "\r\n";
- header += "Accept-Charset: utf-8\r\n";
- header += "\r\n";
- header += logininfo + "\r\n";
- header += "\r\n";
- cout << " ===Send Form===" << endl;
- MySock::Instance().Login(header);
- while (true) {
- Sleep(1);
- }
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement