This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wbox.h
88 lines (74 loc) · 2.69 KB
/
wbox.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
#pragma once
#ifndef id_83DB5799_5792_4F64_BC72_4086C9C0C735
#define id_83DB5799_5792_4F64_BC72_4086C9C0C735
#include <windows.h>
#include "helpers.h"
#include "getaddr.h"
class JobbedProcessManager {
AutoHandle hProcess, hShocker;
AutoHandle hJob;
AutoHandle hStdin, hStdout, hStderr;
JOBOBJECT_EXTENDED_LIMIT_INFORMATION extLimits;
JOBOBJECT_BASIC_UI_RESTRICTIONS uiLimits;
GUID guid;
WCHAR szGuid[40];
LPWSTR szUsername, szPassword, szDirectory, szExecutable, szEnvBlock;
LPWSTR szCmdLine, szInjectX86, szInjectX64;
LPSTR szInjectFunction;
bool tle_, mle_, terminate_shocker;
unsigned long long memory_, memory_limit;
DWORD cpu_time_;
LARGE_INTEGER liStart;
double qpc_freq, execution_time, time_limit;
static DWORD CALLBACK s_ShockerProc(LPVOID lpParam);
DWORD CALLBACK ShockerProc();
static bool canX86, canX64;
static struct _init {
_init() {
SYSTEM_INFO si;
GetNativeSystemInfo(&si);
switch (si.wProcessorArchitecture) {
#ifdef _WIN64
case PROCESSOR_ARCHITECTURE_AMD64:
canX64 = TRUE;
#endif
case PROCESSOR_ARCHITECTURE_INTEL:
canX86 = TRUE;
break;
}
}
} _initializer;
static BYTE asmX86[], asmX64[];
static bool inject(HANDLE hProcess, BOOL x64, LPCWSTR szDllPath, LPCSTR szFunctionName);
public:
JobbedProcessManager();
virtual ~JobbedProcessManager();
virtual bool spawn();
virtual bool terminate(unsigned code);
JobbedProcessManager &time(double seconds);
JobbedProcessManager &memory(size_t bytes);
JobbedProcessManager &processes(int count);
JobbedProcessManager &withLogin(LPCWSTR szUsername, LPCWSTR szPassword);
JobbedProcessManager &command(LPCWSTR szCmdLine);
JobbedProcessManager &executable(LPCWSTR szExecutable);
JobbedProcessManager &directory(LPCWSTR szDirectory);
JobbedProcessManager &injectX86(LPCWSTR szExecutable);
JobbedProcessManager &injectX64(LPCWSTR szExecutable);
JobbedProcessManager &injectFunction(LPCSTR szFunction);
JobbedProcessManager &environment(LPCWSTR szEnvBlock, size_t cbBytes);
unsigned long long memory() { return memory_; }
double executionTime() { return execution_time; }
bool tle() { return tle_; }
bool mle() { return mle_; }
DWORD return_code();
bool wait(DWORD time = INFINITE);
AutoHandle &process() { return hProcess; }
AutoHandle &job() { return hJob; }
// stdin is apparently a macro. *facepalm*
AutoHandle &stdIn() { return hStdin; }
AutoHandle &stdOut() { return hStdout; }
AutoHandle &stdErr() { return hStderr; }
static void updateAsmX86(LPCWSTR szExecutable);
static void updateAsmX64(LPCWSTR szExecutable);
};
#endif