-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcheckVM2.c
More file actions
39 lines (29 loc) · 796 Bytes
/
checkVM2.c
File metadata and controls
39 lines (29 loc) · 796 Bytes
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
#include <stdio.h>
#include <stdint.h>
#include <windows.h>
#include "beacon.h"
#define THRESHOLD 5000
uint64_t getTime()
{
uint32_t l, h;
__asm__ __volatile__("rdtsc" : "=a" (l), "=d" (h));
return ((uint64_t) h << 32) | l;
}
void go(char * args, int alen)
{
uint64_t delta;
uint64_t t1 = getTime(), t2 = 0;
__asm__ __volatile__("cpuid");
t2 = getTime();
BeaconPrintf(CALLBACK_OUTPUT, "t2 = %llu\n", t2);
BeaconPrintf(CALLBACK_OUTPUT, "t1 = %llu\n", t1);
BeaconPrintf(CALLBACK_OUTPUT, "Delta = %llu\n", t2 - t1);
if (t2 - t1 > THRESHOLD)
{
BeaconPrintf(CALLBACK_OUTPUT, "This is a virtual machine %llu\n", delta);
}
else
{
BeaconPrintf(CALLBACK_OUTPUT, "This is not a virtual machine %llu\n", delta);
}
}