Measurements for debugger transparency.
More...
#include "pch.h"
|
unsigned long long | TransparentModeRdtscDiffVmexit () |
| get the difference clock cycles between two rdtsc(s)
|
|
unsigned long long | TransparentModeRdtscVmexitTracing () |
| get the difference clock cycles between rdtsc+cpuid+rdtsc
|
|
int | TransparentModeCpuidTimeStampCounter (UINT64 *Average, UINT64 *StandardDeviation, UINT64 *Median) |
| compute the average, standard deviation and median if rdtsc+cpuid+rdtsc
|
|
int | TransparentModeRdtscEmulationDetection (UINT64 *Average, UINT64 *StandardDeviation, UINT64 *Median) |
| compute the average, standard deviation and median if rdtsc+rdtsc
|
|
BOOLEAN | TransparentModeCheckHypervisorPresence (UINT64 *Average, UINT64 *StandardDeviation, UINT64 *Median) |
| compute the average, standard deviation and median if rdtsc+cpuid+rdtsc
|
|
BOOLEAN | TransparentModeCheckRdtscpVmexit (UINT64 *Average, UINT64 *StandardDeviation, UINT64 *Median) |
| compute the average, standard deviation and median if rdtsc+rdtsc
|
|
Measurements for debugger transparency.
- Author
- Sina Karvandi (sina@.nosp@m.hype.nosp@m.rdbg..nosp@m.org)
- Version
- 0.1
- Date
- 2020-07-07
- Copyright
- This project is released under the GNU Public License v3.
◆ TransparentModeCheckHypervisorPresence()
compute the average, standard deviation and median if rdtsc+cpuid+rdtsc
detects the presence of hypervisor
- Parameters
-
Average | a pointer to save average on it |
StandardDeviation | a pointer to standard deviation average on it |
Median | a pointer to save median on it |
- Returns
- int
197{
198
199
200
202 {
205 }
206 else
207 {
210 }
211}
#define TRUE
Definition BasicTypes.h:55
#define FALSE
Definition BasicTypes.h:54
double Median(vector< double > Cases)
get the median of a vector
Definition gaussian-rng.cpp:22
T Average(const vector< T > &vec)
get the average of a vector
Definition gaussian-rng.cpp:53
VOID ShowMessages(const char *Fmt,...)
Show messages.
Definition libhyperdbg.cpp:96
int TransparentModeCpuidTimeStampCounter(UINT64 *Average, UINT64 *StandardDeviation, UINT64 *Median)
compute the average, standard deviation and median if rdtsc+cpuid+rdtsc
Definition transparency.cpp:109
◆ TransparentModeCheckRdtscpVmexit()
compute the average, standard deviation and median if rdtsc+rdtsc
detects the presence of rdtsc/p vm-exits
- Parameters
-
Average | a pointer to save average on it |
StandardDeviation | a pointer to standard deviation average on it |
Median | a pointer to save median on it |
- Returns
- int
227{
228
229
230
232 {
235 }
236 else
237 {
240 }
241}
int TransparentModeRdtscEmulationDetection(UINT64 *Average, UINT64 *StandardDeviation, UINT64 *Median)
compute the average, standard deviation and median if rdtsc+rdtsc
Definition transparency.cpp:151
◆ TransparentModeCpuidTimeStampCounter()
int TransparentModeCpuidTimeStampCounter |
( |
UINT64 * | Average, |
|
|
UINT64 * | StandardDeviation, |
|
|
UINT64 * | Median ) |
compute the average, standard deviation and median if rdtsc+cpuid+rdtsc
- Parameters
-
Average | a pointer to save average on it |
StandardDeviation | a pointer to standard deviation average on it |
Median | a pointer to save median on it |
- Returns
- int
112{
113 double Avg = 0;
114 double MeasuredTime = 0;
115 vector<double> Results;
116
118 {
120 Avg = Avg + MeasuredTime;
121
122 Results.push_back(MeasuredTime);
123
124
125
126
127 }
128
129 if (
Average != NULL && StandardDeviation != NULL &&
Median != NULL)
130 {
131
132
133
135 }
136
138 return (Avg < 1000 && Avg > 0) ?
FALSE :
TRUE;
139}
VOID GuassianGenerateRandom(vector< double > Data, UINT64 *AverageOfData, UINT64 *StandardDeviationOfData, UINT64 *MedianOfData)
Calculate and generate random gaussian number.
Definition gaussian-rng.cpp:158
unsigned long long TransparentModeRdtscDiffVmexit()
get the difference clock cycles between two rdtsc(s)
Definition transparency.cpp:22
◆ TransparentModeRdtscDiffVmexit()
unsigned long long TransparentModeRdtscDiffVmexit |
( |
| ) |
|
get the difference clock cycles between two rdtsc(s)
- Returns
- unsigned long long
23{
24 unsigned long long ret, ret2;
25 int cpuid_result[4] = {0};
26
27
28
29
30
31
32
33
34
35
36 ret = __rdtsc();
37
38
39
40
41
42
43
44
45
46
47
48 __cpuid(cpuid_result, 0);
49
50
51
52
53
54
55
56
57
58
59 ret2 = __rdtsc();
60
61 return ret2 - ret;
62}
◆ TransparentModeRdtscEmulationDetection()
int TransparentModeRdtscEmulationDetection |
( |
UINT64 * | Average, |
|
|
UINT64 * | StandardDeviation, |
|
|
UINT64 * | Median ) |
compute the average, standard deviation and median if rdtsc+rdtsc
- Parameters
-
Average | a pointer to save average on it |
StandardDeviation | a pointer to standard deviation average on it |
Median | a pointer to save median on it |
- Returns
- int
154{
155 double Avg = 0;
156 double MeasuredTime = 0;
157 vector<double> Results;
158
160 {
162 Avg = Avg + MeasuredTime;
163
164 Results.push_back(MeasuredTime);
165
166
167
168
169 }
170
171 if (
Average != NULL && StandardDeviation != NULL &&
Median != NULL)
172 {
173
174
175
177 }
178
180 return (Avg < 750 && Avg > 0) ?
FALSE :
TRUE;
181}
unsigned long long TransparentModeRdtscVmexitTracing()
get the difference clock cycles between rdtsc+cpuid+rdtsc
Definition transparency.cpp:70
◆ TransparentModeRdtscVmexitTracing()
unsigned long long TransparentModeRdtscVmexitTracing |
( |
| ) |
|
get the difference clock cycles between rdtsc+cpuid+rdtsc
- Returns
- unsigned long long
71{
72 unsigned long long ret, ret2;
73
74
75
76
77
78
79
80
81
82
83 ret = __rdtsc();
84
85
86
87
88
89
90
91
92
93
94 ret2 = __rdtsc();
95
96 return ret2 - ret;
97}