Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _WIN32_WINNT 0x0400
- #include <windows.h>
- #include <stdio.h>
- #include <iostream>
- #include <string.h>
- #include <winsock2.h>
- #include <vector>
- #include <locale>
- #include <sstream>
- #pragma comment(lib,"ws2_32.lib")
- using namespace std;
- void auth()
- {
- HW_PROFILE_INFO hwProfileInfo;
- if (GetCurrentHwProfile(&hwProfileInfo) != NULL) {
- string hwidPro = hwProfileInfo.szHwProfileGuid;
- string hwidName = hwProfileInfo.szHwProfileName;
- WSADATA wsaData;
- SOCKET Socket;
- SOCKADDR_IN SockAddr;
- int lineCount = 0;
- int rowCount = 0;
- struct hostent *host;
- locale local;
- char buffer[10000];
- int i = 0;
- int nDataLength;
- string website_HTML;
- // website url
- string url = "MY URL IS HERE" + "?a=" + hwidPro; // This can be either but, the databse must contain the HWID
- //HTTP GET
- string get_http = "GET / HTTP/1.1\r\nHost: " + url + "\r\nConnection: close\r\n\r\n";
- if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
- cout << "WSAStartup failed.\n";
- system("pause");
- //return 1;
- }
- Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- host = gethostbyname(url.c_str());
- SockAddr.sin_port = htons(80);
- SockAddr.sin_family = AF_INET;
- SockAddr.sin_addr.s_addr = *((unsigned long*)host->h_addr);
- if (connect(Socket, (SOCKADDR*)(&SockAddr), sizeof(SockAddr)) != 0) {
- cout << "Could not connect";
- system("pause");
- //return 1;
- }
- // send GET / HTTP
- send(Socket, get_http.c_str(), strlen(get_http.c_str()), 0);
- // recieve html
- while ((nDataLength = recv(Socket, buffer, 10000, 0)) > 0) {
- int i = 0;
- while (buffer[i] >= 32 || buffer[i] == '\n' || buffer[i] == '\r') {
- website_HTML += buffer[i];
- i += 1;
- }
- }
- closesocket(Socket);
- WSACleanup();
- if (website_HTML.find("true") != std::string::npos) {
- std::cout << "You are authenticated!" << '\n';
- }
- else {
- std::cout << "Failed Authencating!" << endl;
- }
- }
- else {
- return 0;
- }
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement