Advertisement
Guest User

Untitled

a guest
Aug 18th, 2018
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. #define _WIN32_WINNT 0x0400
  2.  
  3. #include <windows.h>
  4. #include <stdio.h>
  5. #include <iostream>
  6. #include <string.h>
  7. #include <winsock2.h>
  8. #include <vector>
  9. #include <locale>
  10. #include <sstream>
  11. #pragma comment(lib,"ws2_32.lib")
  12.  
  13.  
  14.  
  15.  
  16.  
  17. using namespace std;
  18.  
  19. void auth()
  20. {
  21.     HW_PROFILE_INFO hwProfileInfo;
  22.  
  23.     if (GetCurrentHwProfile(&hwProfileInfo) != NULL) {
  24.         string hwidPro = hwProfileInfo.szHwProfileGuid;
  25.         string hwidName = hwProfileInfo.szHwProfileName;
  26.  
  27.         WSADATA wsaData;
  28.         SOCKET Socket;
  29.         SOCKADDR_IN SockAddr;
  30.         int lineCount = 0;
  31.         int rowCount = 0;
  32.         struct hostent *host;
  33.         locale local;
  34.         char buffer[10000];
  35.         int i = 0;
  36.         int nDataLength;
  37.         string website_HTML;
  38.  
  39.         // website url
  40.         string url = "MY URL IS HERE" + "?a=" + hwidPro; // This can be either but, the databse must contain the HWID
  41.  
  42.         //HTTP GET
  43.         string get_http = "GET / HTTP/1.1\r\nHost: " + url + "\r\nConnection: close\r\n\r\n";
  44.  
  45.  
  46.         if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
  47.             cout << "WSAStartup failed.\n";
  48.             system("pause");
  49.             //return 1;
  50.         }
  51.  
  52.         Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  53.         host = gethostbyname(url.c_str());
  54.  
  55.         SockAddr.sin_port = htons(80);
  56.         SockAddr.sin_family = AF_INET;
  57.         SockAddr.sin_addr.s_addr = *((unsigned long*)host->h_addr);
  58.  
  59.         if (connect(Socket, (SOCKADDR*)(&SockAddr), sizeof(SockAddr)) != 0) {
  60.             cout << "Could not connect";
  61.             system("pause");
  62.             //return 1;
  63.         }
  64.  
  65.         // send GET / HTTP
  66.         send(Socket, get_http.c_str(), strlen(get_http.c_str()), 0);
  67.  
  68.         // recieve html
  69.         while ((nDataLength = recv(Socket, buffer, 10000, 0)) > 0) {
  70.             int i = 0;
  71.             while (buffer[i] >= 32 || buffer[i] == '\n' || buffer[i] == '\r') {
  72.  
  73.                 website_HTML += buffer[i];
  74.                 i += 1;
  75.             }
  76.         }
  77.  
  78.         closesocket(Socket);
  79.         WSACleanup();
  80.  
  81.  
  82.         if (website_HTML.find("true") != std::string::npos) {
  83.             std::cout << "You are authenticated!" << '\n';
  84.         }
  85.         else {
  86.             std::cout << "Failed Authencating!" << endl;
  87.         }
  88.  
  89.  
  90.  
  91.     }
  92.     else {
  93.         return 0;
  94.     }
  95.  
  96.     getchar();
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement