Skip to content

Commit 3b2548a

Browse files
author
Requiem
committed
adjusted scores + fixed updater.py for unicode support
1 parent 2dbe5e6 commit 3b2548a

File tree

3 files changed

+33
-39
lines changed

3 files changed

+33
-39
lines changed

auxiliary/updater.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242

4343
def update_sections(filename):
44-
with open(filename, 'r') as vmaware_read:
44+
with open(filename, 'r', encoding='utf-8', errors='ignore') as vmaware_read:
4545
header_content = vmaware_read.readlines()
4646

4747
enum = "enum enum_flags"
@@ -112,7 +112,7 @@ def update_sections(filename):
112112
for i, new_line in enumerate(banner):
113113
header_content[section_line + i] = new_line + '\n'
114114

115-
with open(filename, 'w') as file:
115+
with open(filename, 'w', encoding='utf-8', errors='ignore') as file:
116116
file.writelines(header_content)
117117

118118

@@ -126,7 +126,7 @@ def update_date(filename):
126126
date_arg = arg
127127
break
128128

129-
with open(filename, 'r') as file:
129+
with open(filename, 'r', encoding='utf-8', errors='ignore') as file:
130130
header_content = file.readlines()
131131

132132
banner_line = " * ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ "
@@ -143,7 +143,6 @@ def find_pattern(base_str):
143143
print(f"Version number not found for {red}{bold}{base_str}{ansi_exit}, aborting")
144144
sys.exit(1)
145145

146-
147146
header_version = find_pattern(header_content[index])
148147
arg_version = find_pattern(date_arg) if date_arg else header_version
149148
new_date = datetime.now().strftime("%B %Y")
@@ -157,13 +156,11 @@ def find_pattern(base_str):
157156

158157
header_content[index] = new_content + '\n'
159158

160-
with open(filename, 'w') as file:
159+
with open(filename, 'w', encoding='utf-8', errors='ignore') as file:
161160
file.writelines(header_content)
162161

163162

164-
165-
166-
with open(vmaware_file, 'r') as file:
163+
with open(vmaware_file, 'r', encoding='utf-8', errors='ignore') as file:
167164
file_content = file.readlines()
168165

169166

@@ -207,6 +204,7 @@ def __init__(self, enum_name="", line=0, platform_emojis="", score=0, descriptio
207204
self.notes = notes
208205
self.code_link = code_link
209206

207+
210208
class array_dict(dict):
211209
def __getitem__(self, key):
212210
return self.get(key)
@@ -218,6 +216,7 @@ def init_as_list(self, key):
218216

219217
technique = array_dict()
220218

219+
221220
def fetch_lib_info(enum_list):
222221
for enum in enum_list:
223222
technique.init_as_list(enum)
@@ -231,13 +230,11 @@ def fetch_lib_info(enum_list):
231230
technique[enum].line = i + 1
232231
break
233232

234-
235233
# generate the code implementation link
236234
link = "[link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L"
237235
for enum in enum_list:
238236
technique[enum].code_link = link + str(technique[enum].line) + ")"
239237

240-
241238
# fetch scores
242239
start = "// START OF TECHNIQUE TABLE"
243240
end = "// END OF TECHNIQUE TABLE"
@@ -253,7 +250,6 @@ def fetch_lib_info(enum_list):
253250
end_ptr = index
254251
break # Stop after first end marker
255252

256-
257253
if start_ptr == -1 or end_ptr == -1:
258254
print("Error: Start or end marker not found")
259255
else:
@@ -265,7 +261,6 @@ def fetch_lib_info(enum_list):
265261
if match:
266262
technique[enum].score = int(match.group(1))
267263

268-
269264
# fetch more stuff
270265
for enum in enum_list:
271266
start_line = end_line = technique[enum].line
@@ -322,7 +317,6 @@ def fetch_lib_info(enum_list):
322317
technique[enum].notes = line.split("@note", 1)[-1]
323318

324319

325-
326320
def update_docs(enum_list):
327321
technique_array = []
328322

@@ -340,7 +334,7 @@ def update_docs(enum_list):
340334

341335
technique_array.append("| " + " | ".join(str(item).strip() for item in order) + " |")
342336

343-
with open(vmaware_docs, 'r') as file:
337+
with open(vmaware_docs, 'r', encoding='utf-8', errors='ignore') as file:
344338
docs_content = file.readlines()
345339

346340
docs_start = "<!-- START OF TECHNIQUE DOCUMENTATION -->"
@@ -367,7 +361,7 @@ def update_docs(enum_list):
367361

368362
docs_content[start_ptr:end_ptr - 1] = [line + '\n' for line in technique_array]
369363

370-
with open(vmaware_docs, 'w', newline='\n') as f:
364+
with open(vmaware_docs, 'w', encoding='utf-8', errors='ignore', newline='\n') as f:
371365
f.writelines(docs_content)
372366

373367

docs/documentation.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -458,14 +458,14 @@ VMAware provides a convenient way to not only check for VMs, but also have the f
458458
| `VM::DMIDECODE` | Check if dmidecode output matches a VM brand | 🐧 | 55% | Admin | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L4423) |
459459
| `VM::DMESG` | Check if dmesg output matches a VM brand | 🐧 | 65% | Admin | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L4557) |
460460
| `VM::HWMON` | Check if /sys/class/hwmon/ directory is present. If not, likely a VM | 🐧 | 35% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L4594) |
461-
| `VM::DLL` | Check for VM-specific DLLs | 🪟 | 25% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6563) |
461+
| `VM::DLL` | Check for VM-specific DLLs | 🪟 | 50% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6563) |
462462
| `VM::REGISTRY_KEYS` | Check for VM-specific registry values | 🪟 | 50% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6594) |
463463
| `VM::HWMODEL` | Check if the sysctl for the hwmodel does not contain the "Mac" string | 🍏 | 100% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6341) |
464464
| `VM::DISK_SIZE` | Check if disk size is under or equal to 50GB | 🐧🪟 | 60% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5335) |
465465
| `VM::VBOX_DEFAULT` | Check for default RAM and DISK sizes set by VirtualBox | 🐧🪟 | 25% | Admin | | Admin only needed for Linux | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5351) |
466466
| `VM::VBOX_NETWORK` | Check for VirtualBox network provider string | 🪟 | 100% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6704) |
467467
| `VM::WINE` | Check if the function "wine_get_unix_file_name" is present and if the OS booted from a VHD container | 🪟 | 100% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6734) |
468-
| `VM::POWER_CAPABILITIES` | Check what power states are enabled | 🪟 | 50% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6774) |
468+
| `VM::POWER_CAPABILITIES` | Check what power states are enabled | 🪟 | 90% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6774) |
469469
| `VM::PROCESSES` | Check for any VM processes that are active | 🐧 | 40% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5310) |
470470
| `VM::LINUX_USER_HOST` | Check for default VM username and hostname for linux | 🐧 | 10% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L4604) |
471471
| `VM::GAMARUE` | Check for Gamarue ransomware technique which compares VM-specific Window product IDs | 🪟 | 10% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6815) |
@@ -476,10 +476,10 @@ VMAware provides a convenient way to not only check for VMs, but also have the f
476476
| `VM::MAC_SIP` | Check if System Integrity Protection is disabled (likely a VM if it is) | 🍏 | 40% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6546) |
477477
| `VM::REGISTRY_VALUES` | Check HKLM registries for specific VM strings | 🪟 | 50% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6868) |
478478
| `VM::VPC_INVALID` | Check for official VPC method | 🪟 | 75% | | 32-bit | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L6969) |
479-
| `VM::SIDT` | Check for uncommon IDT virtual addresses | 🐧🪟 | 45% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5445) |
480-
| `VM::SGDT` | Check for sgdt instruction method | 🪟 | 45% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L7025) |
481-
| `VM::SLDT` | Check for sldt instruction method | 🪟 | 45% | | 32-bit | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L7088) |
482-
| `VM::SMSW` | Check for SMSW assembly instruction technique | 🪟 | 45% | | 32-bit | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L7144) |
479+
| `VM::SIDT` | Check for uncommon IDT virtual addresses | 🐧🪟 | 50% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5445) |
480+
| `VM::SGDT` | Check for sgdt instruction method | 🪟 | 50% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L7025) |
481+
| `VM::SLDT` | Check for sldt instruction method | 🪟 | 50% | | 32-bit | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L7088) |
482+
| `VM::SMSW` | Check for SMSW assembly instruction technique | 🪟 | 50% | | 32-bit | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L7144) |
483483
| `VM::VMWARE_IOMEM` | Check for VMware string in /proc/iomem | 🐧 | 65% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L4633) |
484484
| `VM::VMWARE_IOPORTS` | Check for VMware string in /proc/ioports | 🐧 | 70% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5143) |
485485
| `VM::VMWARE_SCSI` | Check for VMware string in /proc/scsi/scsi | 🐧 | 40% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L4942) |
@@ -495,7 +495,7 @@ VMAware provides a convenient way to not only check for VMs, but also have the f
495495
| `VM::CUCKOO_PIPE` | Check for Cuckoo specific piping mechanism | 🪟 | 30% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L7324) |
496496
| `VM::HYPERV_HOSTNAME` | Check for default Azure hostname format (Azure uses Hyper-V as their base VM brand) | 🐧🪟 | 30% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5544) |
497497
| `VM::GENERAL_HOSTNAME` | Check for commonly set hostnames by certain VM brands | 🐧🪟 | 10% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5584) |
498-
| `VM::DISPLAY` | Check for display configurations related to VMs | 🪟 | 20% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L7351) |
498+
| `VM::DISPLAY` | Check for display configurations related to VMs | 🪟 | 35% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L7351) |
499499
| `VM::DEVICE_STRING` | Check if bogus device string would be accepted | 🪟 | 25% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L7399) |
500500
| `VM::BLUESTACKS_FOLDERS` | Check for the presence of BlueStacks-specific folders | 🐧 | 5% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L4649) |
501501
| `VM::CPUID_SIGNATURE` | Check for signatures in leaf 0x40000001 in CPUID | 🐧🪟🍏 | 95% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L4132) |
@@ -527,10 +527,10 @@ VMAware provides a convenient way to not only check for VMs, but also have the f
527527
| `VM::FILE_ACCESS_HISTORY` | Check if the number of accessed files are too low for a human-managed environment | 🐧 | 15% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5218) |
528528
| `VM::AUDIO` | Check if no waveform-audio output devices are present in the system | 🪟 | 25% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L8039) |
529529
| `VM::NSJAIL_PID` | Check if process status matches with nsjail patterns with PID anomalies | 🐧 | 75% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5245) |
530-
| `VM::TPM` | Check if the system has a physical TPM by matching the TPM manufacturer against known physical TPM chip vendors | 🪟 | 50% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L8081) |
531-
| `VM::PCI_DEVICES` | Check for PCI vendor and device IDs that are VM-specific | 🐧🪟 | 95% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5985) |
530+
| `VM::TPM` | Check if the system has a physical TPM by matching the TPM manufacturer against known physical TPM chip vendors | 🪟 | 100% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L8081) |
531+
| `VM::PCI_DEVICES` | Check for PCI vendor and device IDs that are VM-specific | 🐧🪟 | 50% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L5985) |
532532
| `VM::QEMU_PASSTHROUGH` | Check for QEMU's hot-plug signature | 🪟 | 90% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L8164) |
533-
| `VM::TRAP` | Check for two traps being raised at the same RIP, a hypervisor interferes with the instruction pointer delivery | 🪟 | 50% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L8269) |
533+
| `VM::TRAP` | Check for two traps being raised at the same RIP, a hypervisor interferes with the instruction pointer delivery | 🪟 | 100% | | | | [link](https://github.com/kernelwernel/VMAware/tree/main/src/vmaware.hpp#L8338) |
534534

535535
<!-- END OF TECHNIQUE DOCUMENTATION -->
536536

src/vmaware.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* ██║ ██║██╔████╔██║███████║██║ █╗ ██║███████║██████╔╝█████╗
55
* ╚██╗ ██╔╝██║╚██╔╝██║██╔══██║██║███╗██║██╔══██║██╔══██╗██╔══╝
66
* ╚████╔╝ ██║ ╚═╝ ██║██║ ██║╚███╔███╔╝██║ ██║██║ ██║███████╗
7-
* ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ Experimental post-2.3.0 (May 2025)
7+
* ╚═══╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝ Experimental post-2.3.0 (June 2025)
88
*
99
* C++ VM detection library
1010
*
@@ -53,10 +53,10 @@
5353
* - struct for internal cpu operations => line 717
5454
* - struct for internal memoization => line 1042
5555
* - struct for internal utility functions => line 1183
56-
* - struct for internal core components => line 8359
56+
* - struct for internal core components => line 8428
5757
* - start of VM detection technique list => line 1993
58-
* - start of public VM detection functions => line 8874
59-
* - start of externally defined variables => line 9802
58+
* - start of public VM detection functions => line 8943
59+
* - start of externally defined variables => line 9871
6060
*
6161
*
6262
* ============================== EXAMPLE ===================================
@@ -10006,15 +10006,15 @@ std::pair<VM::enum_flags, VM::core::technique> VM::core::technique_list[] = {
1000610006
// START OF TECHNIQUE TABLE
1000710007
#if (WINDOWS)
1000810008
std::make_pair(VM::GPU_CAPABILITIES, VM::core::technique(100, VM::gpu_capabilities)),
10009-
std::make_pair(VM::TRAP, VM::core::technique(50, VM::trap)),
10010-
std::make_pair(VM::TPM, VM::core::technique(50, VM::tpm)),
10009+
std::make_pair(VM::TRAP, VM::core::technique(100, VM::trap)),
10010+
std::make_pair(VM::TPM, VM::core::technique(100, VM::tpm)),
1001110011
std::make_pair(VM::QEMU_PASSTHROUGH, VM::core::technique(90, VM::qemu_passthrough)),
10012-
std::make_pair(VM::POWER_CAPABILITIES, VM::core::technique(50, VM::power_capabilities)),
10012+
std::make_pair(VM::POWER_CAPABILITIES, VM::core::technique(90, VM::power_capabilities)),
1001310013
std::make_pair(VM::DISK_SERIAL, VM::core::technique(100, VM::disk_serial_number)),
1001410014
std::make_pair(VM::IVSHMEM, VM::core::technique(100, VM::ivshmem)),
10015-
std::make_pair(VM::SGDT, VM::core::technique(45, VM::sgdt)),
10016-
std::make_pair(VM::SLDT, VM::core::technique(45, VM::sldt)),
10017-
std::make_pair(VM::SMSW, VM::core::technique(45, VM::smsw)),
10015+
std::make_pair(VM::SGDT, VM::core::technique(50, VM::sgdt)),
10016+
std::make_pair(VM::SLDT, VM::core::technique(50, VM::sldt)),
10017+
std::make_pair(VM::SMSW, VM::core::technique(50, VM::smsw)),
1001810018
std::make_pair(VM::DRIVERS, VM::core::technique(100, VM::drivers)),
1001910019
std::make_pair(VM::REGISTRY_VALUES, VM::core::technique(50, VM::registry_values)),
1002010020
std::make_pair(VM::REGISTRY_KEYS, VM::core::technique(50, VM::registry_keys)),
@@ -10024,8 +10024,8 @@ std::pair<VM::enum_flags, VM::core::technique> VM::core::technique_list[] = {
1002410024
std::make_pair(VM::VIRTUAL_PROCESSORS, VM::core::technique(100, VM::virtual_processors)),
1002510025
std::make_pair(VM::HYPERV_QUERY, VM::core::technique(100, VM::hyperv_query)),
1002610026
std::make_pair(VM::AUDIO, VM::core::technique(25, VM::audio)),
10027-
std::make_pair(VM::DISPLAY, VM::core::technique(20, VM::display)),
10028-
std::make_pair(VM::DLL, VM::core::technique(25, VM::dll)),
10027+
std::make_pair(VM::DISPLAY, VM::core::technique(35, VM::display)),
10028+
std::make_pair(VM::DLL, VM::core::technique(50, VM::dll)),
1002910029
std::make_pair(VM::VBOX_NETWORK, VM::core::technique(100, VM::vbox_network_share)),
1003010030
std::make_pair(VM::VMWARE_BACKDOOR, VM::core::technique(100, VM::vmware_backdoor)),
1003110031
std::make_pair(VM::WINE, VM::core::technique(100, VM::wine)),
@@ -10041,8 +10041,8 @@ std::pair<VM::enum_flags, VM::core::technique> VM::core::technique_list[] = {
1004110041

1004210042
#if (LINUX || WINDOWS)
1004310043
std::make_pair(VM::FIRMWARE, VM::core::technique(100, VM::firmware)),
10044-
std::make_pair(VM::PCI_DEVICES, VM::core::technique(95, VM::pci_devices)),
10045-
std::make_pair(VM::SIDT, VM::core::technique(45, VM::sidt)),
10044+
std::make_pair(VM::PCI_DEVICES, VM::core::technique(50, VM::pci_devices)),
10045+
std::make_pair(VM::SIDT, VM::core::technique(50, VM::sidt)),
1004610046
std::make_pair(VM::DISK_SIZE, VM::core::technique(60, VM::disk_size)),
1004710047
std::make_pair(VM::HYPERV_HOSTNAME, VM::core::technique(30, VM::hyperv_hostname)),
1004810048
std::make_pair(VM::VBOX_DEFAULT, VM::core::technique(25, VM::vbox_default_specs)),

0 commit comments

Comments
 (0)