PHP Code:
#include <Windows.h>
#include "functions.h"
int WINAPI DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) {
switch (reason) {
case DLL_PROCESS_ATTACH:
char posts[128];
if (GetUserInformation(1, posts) == 0) {
MessageBoxA(0, "Ein Fehler ist aufgetreten. Sie sind kein Elitepvpers Mitglied oder Sie haben keine HWID eingetragen.", "Fehler", 0);
} else {
if (posts > 0) {
MessageBoxA(0, posts, "", 0);
CreateThread(0, 0, (LPTHREAD_START_ROUTINE) MainThread, 0, 0, 0);
}
}
break;
}
return 1;
}
PHP Code:
#include <Windows.h>
#include "stdafx.h"
#include <iostream>
#include <wininet.h>
#pragma comment(lib, "Wininet.lib")
using namespace std;
void MainThread(){
for(;;){
Sleep(200);
}
}
void MD5Hash(char str[], int sz, char sec[], int nBufSize)
{
HCRYPTPROV hProv = 0, hHash = 0 ;
BYTE rgbHash[16] ;
DWORD cbHash = 0 ;
char finalhash[33], dig[] = "0123456789abcdef" ;
DWORD l = 0 ;
BYTE *hash = new BYTE[sz+1] ;
strcpy_s((char*)hash, sz+1, str) ;
CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT) ;
CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash) ;
CryptHashData(hHash, hash, sz, 0) ;
cbHash = 16 ;
CryptGetHashParam(hHash, HP_HASHVAL, rgbHash, &cbHash, 0) ;
for(DWORD i=0; i < cbHash; ++i) {
finalhash[l]=dig[rgbHash[i]>>4] ;
l++ ;
finalhash[l]=dig[rgbHash[i] & 0x0F] ;
l++ ;
}
for(l = 32; l < strlen(finalhash); ++l)
finalhash[l] = 0 ;
strcpy_s(sec, nBufSize, finalhash) ;
CryptDestroyHash(hHash) ;
CryptReleaseContext(hProv, 0) ;
delete hash ;
}
void GetHWID(char *szHWID, int nLen)
{
char szWindowsDir [128] ;
char szVolumeName [MAX_PATH + 1] ;
char szFileSysName[MAX_PATH + 1] ;
char szRawHWID [512] ;
DWORD dwVolumeSerial ;
HW_PROFILE_INFOA hwProfile ;
if (!GetWindowsDirectoryA(szWindowsDir, 128))
return ;
for (DWORD i=0; i < strlen(szWindowsDir); ++i) {
if (szWindowsDir[i] == '\\')
szWindowsDir[i+1] = 0 ;
}
if (!GetVolumeInformationA(
szWindowsDir,
szVolumeName,
MAX_PATH + 1,
&dwVolumeSerial,
0, 0,
szFileSysName,
MAX_PATH + 1))
return ;
if (!GetCurrentHwProfileA(&hwProfile))
return ;
sprintf_s(szRawHWID, "%s%d", hwProfile.szHwProfileGuid, dwVolumeSerial) ;
memset(szHWID, 0, nLen);
MD5Hash(szRawHWID, strlen(szRawHWID), szHWID, nLen) ;
}
string GetXMLElement(string szXML, string szElement)
{
int nSize = szElement.size() + 4;
char *pszBuf = new char[nSize];
sprintf_s(pszBuf, nSize, "<%s>", szElement.c_str() );
int nBegin = szXML.find(pszBuf);
if (nBegin == string::npos) {
delete pszBuf;
return "";
}
nBegin += strlen(pszBuf);
sprintf_s(pszBuf, nSize, "</%s>", szElement.c_str() );
int nEnd = szXML.find(pszBuf, nBegin);
if (nEnd == string::npos) {
delete pszBuf;
return "";
}
nEnd += strlen(pszBuf);
string szTemp = szXML.substr(nBegin, nEnd - nBegin - strlen(pszBuf) );
delete pszBuf;
return szTemp;
}
int GetUserInformation(int data, const char* ret) {
char szHWID[35];
char szURL[512];
HINTERNET hINet;
HINTERNET hFile;
DWORD dwBytesReceived = 0;
char szServerResponse[2048];
memset(szServerResponse, 0, 2048);
GetHWID(szHWID, 34) ;
hINet = InternetOpenA("HWID Tool", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
if (!hINet)
return 0;
sprintf_s(szURL, "http://www.elitepvpers.com/api/hwid.php?hash=%s", szHWID);
hFile = InternetOpenUrlA(hINet, szURL, 0, 0, 0, 0);
if (!hFile)
return 0;
if (!InternetReadFile(hFile, &szServerResponse, 2048, &dwBytesReceived))
return 0;
InternetCloseHandle(hFile) ;
InternetCloseHandle(hINet) ;
string szXML = szServerResponse;
switch (data) {
case 0: ret = GetXMLElement(szXML, "username").c_str();
break;
case 1: ret = GetXMLElement(szXML, "posts").c_str();
break;
case 2: ret = GetXMLElement(szXML, "thanks").c_str();
break;
case 3: ret = GetXMLElement(szXML, "userid").c_str();
break;
case 4: ret = GetXMLElement(szXML, "usergroup").c_str();
break;
}
}