-
Notifications
You must be signed in to change notification settings - Fork 214
/
generate_fingerprint.py
422 lines (358 loc) · 20.3 KB
/
generate_fingerprint.py
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
import os
import sys
import argparse
import logging
import winreg
import random
import log_helper
import system_fingerprint
import hardware_fingerprint
import telemetry_fingerprint
import random_utils
import registry_helper
from registry_helper import RegistryKeyType, Wow64RegistryEntry
from system_utils import is_x64os, platform_version
logger = log_helper.setup_logger(name="antidetect", level=logging.INFO, log_to_file=False)
def generate_telemetry_fingerprint():
"""
IDs related to Windows 10 Telemetry
All the telemetry is getting around the DeviceID registry value
It can be found in the following kays:
HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\SQMClient
HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Diagnostics\\DiagTrack\\SettingsRequests
"""
windows_ver = platform_version()
if not windows_ver.startswith("Windows-10"):
logger.warning("Telemetry ID replace available for Windows 10 only")
return
current_device_id = registry_helper.read_value(
key_hive="HKEY_LOCAL_MACHINE",
key_path="SOFTWARE\\Microsoft\\SQMClient",
value_name="MachineId")
if current_device_id[1] == winreg.REG_SZ:
logger.info("Current Windows 10 Telemetry DeviceID is {0}".format(current_device_id[0]))
else:
logger.warning("Unexpected type of HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\SQMClient Value:MachineId Type:%d" %
current_device_id[1])
return
telemetry_fp = telemetry_fingerprint.TelemetryFingerprint()
device_id = telemetry_fp.random_device_id_guid()
device_id_brackets = "{%s}" % telemetry_fp.random_device_id_guid()
logger.info("New Windows 10 Telemetry DeviceID is {0}".format(device_id_brackets))
registry_helper.write_value(key_hive="HKEY_LOCAL_MACHINE",
key_path="SOFTWARE\\Microsoft\\SQMClient",
value_name="MachineId",
value_type=winreg.REG_SZ,
key_value=device_id_brackets)
# Replace queries
query_path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Diagnostics\\DiagTrack\\SettingsRequests"
setting_requests = registry_helper.enumerate_key_subkeys(key_hive="HKEY_LOCAL_MACHINE",
key_path=query_path)
logger.debug("SettingsRequest subkeys: {0}".format(setting_requests))
for request in setting_requests:
query_params = registry_helper.read_value(key_hive="HKEY_LOCAL_MACHINE",
key_path="%s\\%s" % (query_path, request),
value_name="ETagQueryParameters")
if query_params[1] != winreg.REG_SZ:
logger.warning("Unexpected type of %s\\%s Value:MachineId Type:%d" % (query_path, request, query_params[1]))
return
query_string = query_params[0]
new_query_string = query_string.replace(current_device_id[0], device_id)
registry_helper.write_value(key_hive="HKEY_LOCAL_MACHINE",
key_path="%s\\%s" % (query_path, request),
value_name="ETagQueryParameters",
value_type=winreg.REG_SZ,
key_value=new_query_string)
logger.debug("DeviceID has been replaced from %s to %s" % (current_device_id, device_id))
def generate_network_fingerprint():
"""
Generate network-related identifiers:
Hostname (from pre-defined list)
Username (from pre-defined list)
MAC address (from pre-defined list)
"""
random_host = random_utils.random_hostname()
random_user = random_utils.random_username()
random_mac = random_utils.random_mac_address()
logger.info("Random hostname value is {0}".format(random_host))
logger.info("Random username value is {0}".format(random_user))
logger.info("Random MAC addresses value is {0}".format(random_mac))
hive = "HKEY_LOCAL_MACHINE"
logger.debug("Tcpip\\Parameters NV Hostname={0}".format(random_host))
registry_helper.write_value(key_hive=hive,
key_path="SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters",
value_name="NV Hostname",
value_type=RegistryKeyType.REG_SZ,
key_value=random_host)
logger.debug("Tcpip\\Parameters Hostname={0}".format(random_host))
registry_helper.write_value(key_hive=hive,
key_path="SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters",
value_name="Hostname",
value_type=RegistryKeyType.REG_SZ,
key_value=random_host)
logger.debug("Tcpip\\Parameters ComputerName={0}".format(random_host))
registry_helper.write_value(key_hive=hive,
key_path="SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName",
value_name="ComputerName",
value_type=RegistryKeyType.REG_SZ,
key_value=random_host)
logger.debug("ComputerName\\ActiveComputerName ComputerName={0}".format(random_host))
registry_helper.write_value(key_hive=hive,
key_path="SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName",
value_name="ComputerName",
value_type=RegistryKeyType.REG_SZ,
key_value=random_host)
logger.debug("Windows NT\\CurrentVersion RegisteredOwner={0}".format(random_user))
registry_helper.write_value(key_hive=hive,
key_path="SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
value_name="RegisteredOwner",
value_type=RegistryKeyType.REG_SZ,
key_value=random_user,
access_type=Wow64RegistryEntry.KEY_WOW32_64)
def generate_windows_fingerprint():
"""
Generate common Windows identifiers, responsible for fingerprinting:
BuildGUID
BuildLab
BuildLabEx
CurrentBuild
CurrentBuildNumber
CurrentVersion
DigitalProductId
DigitalProductId4
EditionID
InstallDate
ProductId
ProductName
IE SvcKBNumber
IE ProductId
IE DigitalProductId
IE DigitalProductId4
IE Installed Date
"""
system_fp = system_fingerprint.WinFingerprint()
# Windows fingerprint
hive = "HKEY_LOCAL_MACHINE"
version_path = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
logger.debug("Windows NT\\CurrentVersion BuildGUID")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="BuildGUID",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_build_guid(),
access_type=Wow64RegistryEntry.KEY_WOW32_64)
logger.debug("Windows NT\\CurrentVersion BuildLab")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="BuildLab",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_build_lab(),
access_type=Wow64RegistryEntry.KEY_WOW32_64)
logger.debug("Windows NT\\CurrentVersion BuildLabEx")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="BuildLabEx",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_build_lab_ex(),
access_type=Wow64RegistryEntry.KEY_WOW32_64)
logger.debug("Windows NT\\CurrentVersion CurrentBuild")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="CurrentBuild",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_current_build(),
access_type=Wow64RegistryEntry.KEY_WOW32_64)
logger.debug("Windows NT\\CurrentVersion CurrentBuildNumber")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="CurrentBuildNumber",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_current_build(),
access_type=Wow64RegistryEntry.KEY_WOW32_64)
logger.debug("Windows NT\\CurrentVersion CurrentVersion")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="CurrentVersion",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_current_version(),
access_type=Wow64RegistryEntry.KEY_WOW32_64)
logger.debug("Windows NT\\CurrentVersion DigitalProductId")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="DigitalProductId",
value_type=RegistryKeyType.REG_BINARY,
key_value=random_utils.bytes_list_to_array(system_fp.random_digital_product_id()))
logger.debug("Windows NT\\CurrentVersion DigitalProductId4")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="DigitalProductId4",
value_type=RegistryKeyType.REG_BINARY,
key_value=random_utils.bytes_list_to_array(system_fp.random_digital_product_id4()))
logger.debug("Windows NT\\CurrentVersion EditionID")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="EditionID",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_edition_id(),
access_type=Wow64RegistryEntry.KEY_WOW32_64)
logger.debug("Windows NT\\CurrentVersion InstallDate")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="InstallDate",
value_type=RegistryKeyType.REG_DWORD,
key_value=system_fp.random_install_date())
logger.debug("Windows NT\\CurrentVersion ProductId")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="ProductId",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_product_id(),
access_type=Wow64RegistryEntry.KEY_WOW32_64)
logger.debug("Windows NT\\CurrentVersion ProductName")
registry_helper.write_value(key_hive=hive,
key_path=version_path,
value_name="ProductName",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_product_name(),
access_type=Wow64RegistryEntry.KEY_WOW32_64)
# IE fingerprint
logger.debug("Microsoft\\Internet Explorer svcKBNumber")
registry_helper.write_value(key_hive=hive,
key_path="SOFTWARE\\Microsoft\\Internet Explorer",
value_name="svcKBNumber",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_ie_service_update(),
access_type=Wow64RegistryEntry.KEY_WOW32_64)
logger.debug("Microsoft\\Internet Explorer ProductId")
registry_helper.write_value(key_hive=hive,
key_path="SOFTWARE\\Microsoft\\Internet Explorer\\Registration",
value_name="ProductId",
value_type=RegistryKeyType.REG_SZ,
key_value=system_fp.random_product_id())
logger.debug("Microsoft\\Internet Explorer DigitalProductId")
registry_helper.write_value(key_hive=hive,
key_path="SOFTWARE\\Microsoft\\Internet Explorer\\Registration",
value_name="DigitalProductId",
value_type=RegistryKeyType.REG_BINARY,
key_value=random_utils.bytes_list_to_array(system_fp.random_digital_product_id()))
logger.debug("Internet Explorer\\Registration DigitalProductId")
registry_helper.write_value(key_hive=hive,
key_path="SOFTWARE\\Microsoft\\Internet Explorer\\Registration",
value_name="DigitalProductId4",
value_type=RegistryKeyType.REG_BINARY,
key_value=random_utils.bytes_list_to_array(system_fp.random_digital_product_id4()))
ie_install_date = system_fp.random_ie_install_date()
logger.info("IEDate={0}".format(ie_install_date))
logger.debug("Internet Explorer\\Migration IE Installed Date")
registry_helper.write_value(key_hive=hive,
key_path="SOFTWARE\\Microsoft\\Internet Explorer\\Migration",
value_name="IE Installed Date",
value_type=RegistryKeyType.REG_BINARY,
key_value=ie_install_date,
access_type=Wow64RegistryEntry.KEY_WOW32_64)
logger.info("Random build GUID {0}".format(system_fp.random_build_guid()))
logger.info("Random BuildLab {0}".format(system_fp.random_build_lab()))
logger.info("Random BuildLabEx {0}".format(system_fp.random_build_lab_ex()))
logger.info("Random Current Build {0}".format(system_fp.random_current_build()))
logger.info("Random Current Build number {0}".format(system_fp.random_current_build()))
logger.info("Random Current Version {0}".format(system_fp.random_current_version()))
logger.info("Random Edition ID {0}".format(system_fp.random_edition_id()))
logger.info("Random Install Date {0}".format(system_fp.random_install_date()))
logger.info("Random product ID {0}".format(system_fp.random_product_id()))
logger.info("Random Product name {0}".format(system_fp.random_product_name()))
logger.debug("Random digital product ID {0}".format(system_fp.random_digital_product_id()))
logger.debug("Random digital product ID 4 {0}".format(system_fp.random_digital_product_id4()))
logger.debug("Random IE service update {0}".format(system_fp.random_ie_service_update()))
logger.debug("Random IE install data {0}".format(system_fp.random_ie_install_date()))
def generate_hardware_fingerprint():
"""
Generate hardware-related identifiers:
HwProfileGuid
MachineGuid
Volume ID
SusClientId
SusClientIDValidation
"""
hardware_fp = hardware_fingerprint.HardwareFingerprint()
hive = "HKEY_LOCAL_MACHINE"
# Hardware profile GUID
logger.debug("Hardware Profiles\\0001 HwProfileGuid")
registry_helper.write_value(key_hive=hive,
key_path="SYSTEM\\CurrentControlSet\\Control\\IDConfigDB\\Hardware Profiles\\0001",
value_name="HwProfileGuid",
value_type=RegistryKeyType.REG_SZ,
key_value=hardware_fp.random_hw_profile_guid())
# Machine GUID
logger.debug("Microsoft\\Cryptography MachineGuid")
registry_helper.write_value(key_hive=hive,
key_path="SOFTWARE\\Microsoft\\Cryptography",
value_name="MachineGuid",
value_type=RegistryKeyType.REG_SZ,
key_value=hardware_fp.random_machine_guid())
# Windows Update GUID
logger.debug("CurrentVersion\\WindowsUpdate SusClientId")
registry_helper.write_value(key_hive=hive,
key_path="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate",
value_name="SusClientId",
value_type=RegistryKeyType.REG_SZ,
key_value=hardware_fp.random_win_update_guid())
logger.debug("CurrentVersion\\WindowsUpdate SusClientIDValidation")
registry_helper.write_value(key_hive=hive,
key_path="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate",
value_name="SusClientIDValidation",
value_type=RegistryKeyType.REG_BINARY,
key_value=random_utils.bytes_list_to_array(hardware_fp.random_client_id_validation()))
dir_name = os.path.join(os.path.dirname(__file__), "bin")
volume_id = random_utils.random_volume_id()
logger.info("VolumeID={0}".format(volume_id))
volume_id_path = os.path.join(dir_name, "VolumeID{0}.exe C: {1}".format("64" if is_x64os() else "", volume_id))
os.system(volume_id_path)
logger.info("Random Hardware profile GUID {0}".format(hardware_fp.random_hw_profile_guid()))
logger.info("Random Hardware CKCL GUID {0}".format(hardware_fp.random_performance_guid()))
logger.info("Random Machine GUID {0}".format(hardware_fp.random_machine_guid()))
logger.info("Random Windows Update GUID {0}".format(hardware_fp.random_win_update_guid()))
logger.debug("Random Windows Update Validation ID {0}".format(hardware_fp.random_win_update_guid()))
def main():
"""
Generate and change/spoof Windows identification to protect user from local installed software
:return: Exec return code
"""
parser = argparse.ArgumentParser(description='Command-line parameters')
parser.add_argument('--telemetry',
help='Generate Windows 10 Telemetry IDs',
action='store_true',
required=False,
default=False)
parser.add_argument('--network',
help='Generate network-related fingerprint',
action='store_true',
required=False,
default=False)
parser.add_argument('--system',
help='Generate fingerprint based on system version and identifiers',
action='store_true',
required=False,
default=False)
parser.add_argument('--hardware',
help='Generate fingerprint based on hardware identifiers',
action='store_true',
required=False,
default=False)
args = parser.parse_args()
# Selected nothing means select all
if args.telemetry is False and args.network is False and args.system is False and args.hardware is False:
args.network = True
args.system = True
args.hardware = True
if args.telemetry:
generate_telemetry_fingerprint()
if args.network:
generate_network_fingerprint()
if args.system:
generate_windows_fingerprint()
if args.hardware:
generate_hardware_fingerprint()
return 0
###########################################################################
if __name__ == '__main__':
sys.exit(main())