Skip to content

Commit fabfe5d

Browse files
committed
1.1 update
1 parent 9413c67 commit fabfe5d

4 files changed

Lines changed: 525 additions & 401 deletions

File tree

auxiliary/updater.py

Lines changed: 99 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -3,108 +3,104 @@
33
# For example, it'll update the line numbers for the sections
44
# the header, and other basic information.
55

6-
7-
filename = "../src/vmaware.hpp"
8-
9-
# read file content
10-
#def read():
11-
with open(filename, 'r') as vmaware_read:
12-
header_content = vmaware_read.readlines()
13-
14-
#return header_content
15-
16-
# fetch important bits
17-
#def fetch(p_content):
18-
# keywords to scan
19-
enum = "enum enum_flags"
20-
cpu = "struct cpu {"
21-
memo = "struct memo {"
22-
util = "struct util {"
23-
techniques = "private: // START OF PRIVATE VM DETECTION TECHNIQUE DEFINITIONS"
24-
core = "struct core {"
25-
public = "public: // START OF PUBLIC FUNCTIONS"
26-
external = "// ============= EXTERNAL DEFINITIONS ============="
27-
28-
# set up the arrays
29-
pointer_array = []
30-
pair_array = []
31-
keywords = [enum, cpu, memo, util, techniques, core, public, external]
32-
scanner_keywords = [
33-
"__ENUM__",
34-
"__CPU__",
35-
"__MEMO__",
36-
"__UTIL__",
37-
"__TECHNIQUES__",
38-
"__CORE__",
39-
"__PUBLIC__",
40-
"__EXTERNAL__"
41-
]
42-
43-
# set the indexes
44-
file_pointer = 0
45-
array_index = 0
46-
47-
48-
# loop and append if keyword is found
49-
for line in header_content:
50-
if keywords[array_index] in line:
51-
if array_index != len(keywords) - 1:
52-
array_index += 1
53-
54-
pointer_array.append(file_pointer)
55-
56-
file_pointer += 1
57-
58-
59-
# create the pair array
60-
i = 0
61-
for scanner in scanner_keywords:
62-
tmp_pair = (scanner, pointer_array[i])
63-
pair_array.append(tmp_pair)
64-
if i != len(pointer_array) - 1:
65-
i += 1
66-
67-
68-
MACRO = 0
69-
FILE_LINE = 1
70-
index = 0
71-
banner = [
72-
" * - enums for publicly accessible techniques => line __ENUM__",
73-
" * - struct for internal cpu operations => line __CPU__",
74-
" * - struct for internal memoization => line __MEMO__",
75-
" * - struct for internal utility functions => line __UTIL__",
76-
" * - start of internal VM detection techniques => line __TECHNIQUES__",
77-
" * - struct for internal core components => line __CORE__",
78-
" * - start of public VM detection functions => line __PUBLIC__",
79-
" * - start of externally defined variables => line __EXTERNAL__",
80-
" */",
81-
""
82-
]
83-
84-
# replace the macro strings with the file line numbers
85-
for pair in pair_array:
86-
for line in banner:
87-
if pair[MACRO] in line:
88-
banner[index] = line.replace(pair[MACRO], str(pair[FILE_LINE]))
89-
index += 1
90-
continue
91-
92-
# manual filters
93-
tmp = banner[4]
94-
banner[4] = banner[5]
95-
banner[5] = tmp
96-
97-
# get the index file line of the section string
98-
section_line = 0
99-
section_str = " * ================================ SECTIONS =================================="
100-
for line in header_content:
101-
if section_str in line:
102-
break
6+
def update(filename):
7+
with open(filename, 'r') as vmaware_read:
8+
header_content = vmaware_read.readlines()
9+
10+
# fetch important bits
11+
enum = "enum enum_flags"
12+
cpu = "struct cpu {"
13+
memo = "struct memo {"
14+
util = "struct util {"
15+
techniques = "private: // START OF PRIVATE VM DETECTION TECHNIQUE DEFINITIONS"
16+
core = "struct core {"
17+
public = "public: // START OF PUBLIC FUNCTIONS"
18+
external = "// ============= EXTERNAL DEFINITIONS ============="
19+
20+
# set up the arrays
21+
pointer_array = []
22+
pair_array = []
23+
keywords = [enum, cpu, memo, util, techniques, core, public, external]
24+
scanner_keywords = [
25+
"__ENUM__",
26+
"__CPU__",
27+
"__MEMO__",
28+
"__UTIL__",
29+
"__TECHNIQUES__",
30+
"__CORE__",
31+
"__PUBLIC__",
32+
"__EXTERNAL__"
33+
]
34+
35+
# set the indexes
36+
file_pointer = 0
37+
array_index = 0
38+
39+
40+
# loop and append if keyword is found
41+
for line in header_content:
42+
if keywords[array_index] in line:
43+
if array_index != len(keywords) - 1:
44+
array_index += 1
45+
46+
pointer_array.append(file_pointer)
47+
48+
file_pointer += 1
49+
50+
51+
# create the pair array
52+
i = 0
53+
for scanner in scanner_keywords:
54+
tmp_pair = (scanner, pointer_array[i])
55+
pair_array.append(tmp_pair)
56+
if i != len(pointer_array) - 1:
57+
i += 1
58+
59+
60+
MACRO = 0
61+
FILE_LINE = 1
62+
index = 0
63+
banner = [
64+
" * - enums for publicly accessible techniques => line __ENUM__",
65+
" * - struct for internal cpu operations => line __CPU__",
66+
" * - struct for internal memoization => line __MEMO__",
67+
" * - struct for internal utility functions => line __UTIL__",
68+
" * - start of internal VM detection techniques => line __TECHNIQUES__",
69+
" * - struct for internal core components => line __CORE__",
70+
" * - start of public VM detection functions => line __PUBLIC__",
71+
" * - start of externally defined variables => line __EXTERNAL__",
72+
" */",
73+
""
74+
]
75+
76+
# replace the macro strings with the file line numbers
77+
for pair in pair_array:
78+
for line in banner:
79+
if pair[MACRO] in line:
80+
banner[index] = line.replace(pair[MACRO], str(pair[FILE_LINE]))
81+
index += 1
82+
continue
83+
84+
# manual filters
85+
tmp = banner[4]
86+
banner[4] = banner[5]
87+
banner[5] = tmp
88+
89+
# get the index file line of the section string
90+
section_line = 0
91+
section_str = " * ================================ SECTIONS =================================="
92+
for line in header_content:
93+
if section_str in line:
94+
break
95+
section_line += 1
10396
section_line += 1
104-
section_line += 1
10597

106-
# write to the header file
107-
for i in range(len(banner)):
108-
header_content[section_line + i] = banner[i] + '\n'
109-
with open(filename, 'w') as file:
110-
file.writelines(header_content)
98+
# write to the header file
99+
for i in range(len(banner)):
100+
header_content[section_line + i] = banner[i] + '\n'
101+
with open(filename, 'w') as file:
102+
file.writelines(header_content)
103+
104+
105+
update("../src/vmaware.hpp")
106+
update("../src/vmaware_mit.hpp")

src/cli.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ int main(int argc, char* argv[]) {
164164
checker(VM::KVM_REG, "KVM registries");
165165
checker(VM::KVM_DRIVERS, "KVM drivers");
166166
checker(VM::KVM_DIRS, "KVM directories");
167+
checker(VM::HKLM_REGISTRIES, "HKLM registries");
168+
checker(VM::AUDIO, "Audio device");
167169
std::printf("\n");
168170

169171
const std::string brand = VM::brand();

0 commit comments

Comments
 (0)