Repository navigation
Expand file tree
/
Copy pathdata_analysis.py
More file actions
2540 lines (2328 loc) · 96.3 KB
/
Copy pathdata_analysis.py
File metadata and controls
2540 lines (2328 loc) · 96.3 KB
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from collections import Counter
import json
import hashlib
import logging
import math
import os
import re
import subprocess
import sys
# winreg is Windows-only — use conditional import so this module works on all platforms
if sys.platform == 'win32':
import winreg
else:
winreg = None
from cryptography.fernet import Fernet
# Visualization imports. The application is a Flask server, not a desktop GUI;
# force a non-interactive backend so matplotlib never creates Tkinter objects
# that can be finalized from a worker thread during shutdown.
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import seaborn as sns
# Data processing imports
import pandas as pd
import numpy as np
from scipy import stats
# Provided data
data = '3=U³\\¬¶6|cò\\u000fã£Ü\\u001bn>]UãÊOM³YWl®cÕ\\u0017«ÔñqZÓZÖø\\u005cæ\\u0017ÙGµZ.ôSv²5\\u001f;Ì͸Õ\'Ö<\\u001eYã.ËôðâøxãµtøªÓ3/VÍÆµrÜfÚczlzjÎvfñfÎÔO\\u00177iËG§tÍ£=ðÙ\\u0017챺+¼=êqÇV\\u005cG«ig\']+>geµÜñ\\u001e¶±§ÊÚx|<͸|¥ìáÚ.é\\u001bn£³¦]véeô<y¸ãÉã\\u001dò>Ö\\u001e¼Æv\'§êÌvtn6Ó¥³læ:µl\'>jélOfÇ7ÉkÌWÔ\\u001fSÕå\'§\\u001e\\u001fÉ®\\u001b§\\u001bnáx;Åô¥¶gu¦ÊÍcÓÖÑ©¹ð¶KêÊ>\\u001b;9«ª|K¹\\u001eÜ£;.¶ÅWðø´Ü£Õæxs\\u005c®\\u005cìÌuÑÓimn²\\u001f6Ö\\u005c]VÓ¬êÆôðkcm\\u005cÚ¦|iv\\u001døUOK³.>xm6vf¹en²vMñ.OSkS:sM¶´\\u001f<;ð;\\u001e[q;67Myj]VÚcz²µM§Å³±¬O+òtm3¦©ÓGn9y<ÇZ;\\u001eÅÚ>ÑÓØ²¹\\u001eÚY/Gãð³\\u001by£zÒÎNµxø\\u005cUám\\u001eÕVκ67.z¼rÜc¹l³ÒñãNγ.Çfº9ñâ®l±¶<¶GÙ\\u0017§isêÚ¦øt«¥/él7:Õ¸ñ5>lñ[3æØ|SnGѵ:>â;Ôj>-<WGN|¥W5uSã©mZømÇ3S[¥v+m²¼VUìrÕxãYÙMWìc>3ÖØø¬Õ+Ó\\u001bmZÙÃ\\u001dØÍc«9ñæVËÌW<ÕY³:êqéiGÓ\\u005cÜéÖZgSÙNéÌnÌ=qø®ÃÓ6^<\\u0017ÍK[¥å\\u001dæÔWSs:®jvÊ^j«:ÍGñSåÑ[\\u005cÕ^\\u001b^¦Ú\\u000fÇrÇSÚ´yqì\\u001dã´yɵ+>^j]Ysé¼ä;£ZÇzrãV/ÅÓNvM«Ëi].§±;:ñ6ͬô-ºÅò±WÌ^Åy:Nvè\\u000f¼cÖ5^ª\\u001f-ÖY=KñGÓ-Õ´ØUnѶªòÔôr¼<«.W5åm¥|Ñãª>fòØ7âñM§9^\\u000f^Åã±|eêÑÓr;¬ôV[SÇtÇ5znµ:7Mnq\\u001f6|ÆÍæK¹xã¸]+³NÇ£áñcÙÆìÊ[yK¼Nãx;¶[ÙÌkâ³\\u001eÅÜ´]-[ÎrSò\\u001f\'>Ã|:mÆ|²ÉØ«£Ü£¶´Ír§3Ç<¶xñʦ/âê<ôVµÒ/Mu+òاªyj¹KÕfná|\\u001et\\u001flkÅkzNôÚtÌÔêjøÃËVu´uÌÙ|¼èêèÜ´m馫£ºq츹+ÖèÜG\\u000fÜèË\\u001b\\u001bºxvÑg´OxËÒ\\u001f<[MÚô¥zÑ/âÖÑMæUY|5µ6¶xÓ©\\u001e³â®ä|Zg/á§rW©§\\u005cÙØ|ªn-Õª>MÇÑ/ªµtÎr¶Ø\\u001fâò[Ô\\u001fiÇä³´µÖÌn¬mø3s3|jå¼É§\\u001bu¥ø©Oz<7|ÃÓf®\\u001bø\\u001bê3g.Ó±.¼eueô©ñg\\u001dܱÚjWÆ7ry-ê²/Ìê+ÜÔ\\u001fìf[ðÍS娼ܱåeéWjOÃOÒÊ7è]Æ6ÕØº6s;ÃñG˱éMãKºZæÚ\\u001e¹GêU\\u001f|èrv¸vqÖVô9nnÆè\\u001fÅ\\u001fKºµ¬º\\u001eµð/KW9ÙjÎU6ìÉ\\u001f\\u001eÕG;èÜi¼\\u001e^ávù£=¥3Ü3ktytºKÎòtÓ\\u000fº:^-µÑåfµYváòONO-ÙUµÆË3µ±¶©n<§ò'
def analyze_data(data):
"""
Generate a Fernet key for encrypting the provided data.
NOTE: This used to run a large amount of debug analysis (hex-dumping the
entire input, computing entropy/chi-squared statistics, and rendering
matplotlib plots to disk) on every call. Since the generated key never
actually depended on that analysis, and callers invoke this per scanned/
quarantined file, that overhead made scans and quarantining extremely
slow (flooding logs with full file hex dumps), leaked unclosed
matplotlib figures (RuntimeWarning: More than 20 figures have been
opened), and has been observed to crash the server outright on large
files. The analysis has been removed; this now just returns a fresh
Fernet key as it always did.
Args:
data (str or bytes): The data to analyze.
Returns:
bytes: A newly generated Fernet key.
"""
# Validate input data
if not data:
print('Error: Input data is empty. Please provide valid data.')
return Fernet.generate_key()
# Convert to bytes if data is a string
if isinstance(data, str):
data = data.encode('latin-1') # Convert to bytes using latin-1 encoding
# Compute entropy and character frequency from the actual data
# and save updated plots to static/. Limit plotting to the first
# 4 KB so large files do not slow down scans.
sample = data[:4096]
frequency = Counter(sample)
total = len(sample) if sample else 1
entropy = -sum((freq / total) * math.log2(freq / total) for freq in frequency.values() if freq > 0)
print(f'Computed entropy: {entropy:.4f} for {len(sample)} bytes')
try:
os.makedirs('static', exist_ok=True)
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message="Starting a Matplotlib GUI outside of the main thread will likely fail.")
warnings.filterwarnings("ignore", category=FutureWarning, message="Passing `palette` without assigning `hue` is deprecated")
freq_df = pd.DataFrame(list(frequency.items()), columns=['Byte', 'Count'])
freq_df = freq_df.sort_values('Count', ascending=False).head(30)
plt.figure(figsize=(12, 6))
sns.barplot(x='Byte', y='Count', data=freq_df, hue='Byte', palette='viridis', legend=False)
plt.title('Top 30 Character Frequencies')
plt.xlabel('Byte Value')
plt.ylabel('Count')
plt.tight_layout()
plt.savefig('static/char_freq.png')
plt.close()
plt.figure(figsize=(8, 4))
sns.set_style('whitegrid')
plt.plot([entropy], marker='o')
plt.title('Entropy Visualization')
plt.xlabel('Segment')
plt.ylabel('Entropy')
plt.grid()
plt.savefig('static/entropy.png')
plt.close()
except Exception as e:
print(f'Could not save analysis plots: {e}')
return Fernet.generate_key()
def _analyze_data_debug(data):
"""Retained for reference: the original verbose debug analysis that used
to run on every call to analyze_data(). Not called anywhere."""
print('Initial Data Length:', len(data)) # Log the initial length of the data
print('Raw Data (hex):', data.hex()) # Log the raw data in hex
# Frequency analysis
frequency = Counter(data)
print('Character Frequency:', frequency)
# --- Plot Character Frequency ---
if frequency:
# Prepare data for plotting
freq_df = pd.DataFrame(list(frequency.items()), columns=['Byte', 'Count'])
freq_df = freq_df.sort_values('Count', ascending=False)
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message="Starting a Matplotlib GUI outside of the main thread will likely fail.")
warnings.filterwarnings("ignore", category=FutureWarning, message="Passing `palette` without assigning `hue` is deprecated")
plt.figure(figsize=(12, 6))
# Use hue='Byte' and legend=False to future-proof against Seaborn deprecation
sns.barplot(x='Byte', y='Count', data=freq_df.head(30), hue='Byte', palette='viridis', legend=False)
plt.title('Top 30 Character Frequencies')
plt.xlabel('Byte Value')
plt.ylabel('Count')
plt.tight_layout()
os.makedirs('static', exist_ok=True)
plt.savefig('static/char_freq.png')
plt.close()
# --- Header and Payload Extraction ---
# The header is the first byte. The payload is everything after the header.
header = data[0:1]
print(f'Header (first byte): {header}')
# Header validation: Only '3' (0x33) is considered valid for this format.
# If your data format changes, update this check accordingly.
if header != b'3':
print(f'Warning: Unexpected header value: {header!r} (expected b"3" / 0x33)')
if len(data) <= 1:
print('Error: No payload found after header.')
payload = b''
else:
payload = data[1:]
print(f'Payload extracted after header (length={len(payload)} bytes).')
# Grouped diagnostics for context
print('Diagnostics:')
print(f' Header (hex): {header.hex()}')
print(f' Payload (hex, first 32 bytes): {payload[:32].hex()}...')
print(f' Full data (surrounding, hex): {data[max(0, 1 - 10):1 + len(payload) + 10].hex()}')
# Search for specific patterns (only call once per pattern)
search_for_pattern(data, b'3=U') # Example pattern to search for
# Entropy calculation
total_chars = sum(frequency.values())
expected_frequency = total_chars / len(frequency)
entropy = -sum((freq / total_chars) * math.log2(freq / total_chars) for freq in frequency.values())
print('Entropy:', entropy)
# Print the actual byte values of the first few bytes of the data
print('Actual byte values of the first few bytes:', data[:20])
# Check if the first few bytes match the custom magic number
# Use a raw bytes literal or escape the backslash for \u000f
custom_magic_number = b'3=U\xb3\xac\xb66|c\xf2\\u000f\xe3\xa3\xdc' # Ensure this matches the expected header
# Alternatively, if you want the actual byte value 0x0f, use:
# custom_magic_number = b'3=U\xb3\xac\xb66|c\xf2\x0f\xe3\xa3\xdc'
print('Checking for custom magic number...')
if data.startswith(custom_magic_number):
print('File format identified: Custom File Format')
else:
print('File format could not be identified')
# Known file headers (magic numbers)
file_signatures = {
b'\x89PNG': 'PNG Image',
b'GIF8': 'GIF Image',
b'\xFF\xD8': 'JPEG Image',
b'%PDF': 'PDF Document',
b'PK': 'ZIP Archive',
b'RIFF': 'WAV/AVI File',
b'\x7FELF': 'ELF Executable',
b'\x42\x5A': 'BZ2 Compressed',
b'TXT': 'Text File',
b'\xFF\xFB': 'MP3 Audio',
b'\x00\x00\x00\x20ftyp': 'MP4 Video',
b'<!DOCTYPE html>': 'HTML Document',
b'<?xml': 'XML Document',
b'PK\x03\x04': 'ZIP Archive (File Header)',
b'\x52\x61\x72\x21': 'RAR Archive',
b'\x1F\x8B': 'GZIP Compressed',
b'\x4D\x5A': 'EXE Executable',
b'\x30\x26\xB2\x75': 'WMV Video',
b'\x66\x74\x79\x70': 'FLV Video',
b'\x7B\x5C': 'JSON Document',
b'\x25\x50\x44\x46': 'PDF Document',
b'\x4D\x53\x57\x4F': 'MS Word Document',
b'\x4D\x53\x45\x58': 'MS Excel Document',
b'\x4D\x53\x50\x50': 'MS PowerPoint Document',
b'\x4D\x53\x41\x43': 'MS Access Database',
b'\x4D\x53\x50\x53': 'MS Project File',
b'\x4D\x53\x56\x42': 'MS Visio File',
b'\x4D\x53\x49\x4D': 'MS Image File',
b'\x4D\x53\x49\x43': 'MS Icon File',
b'\x4D\x53\x49\x42': 'MS Bitmap File',
b'\x4D\x53\x49\x50': 'MS Picture File',
b'\x4D\x53\x49\x47': 'MS GIF File',
b'\x4D\x53\x49\x4A': 'MS JPEG File',
b'\x4D\x53\x49\x50\x4E\x47': 'MS PNG File',
b'\x4D\x53\x49\x42\x4D\x50': 'MS BMP File',
b'\x4D\x53\x49\x43\x4F\x4E': 'MS ICO File',
b'\x4D\x53\x49\x43\x55\x52': 'MS CUR File',
b'\x4D\x53\x49\x41\x4E\x49': 'MS ANI File',
}
# Update the file_signatures dictionary with additional known signatures
file_signatures.update({
b'3=U': 'Custom Format',
b'3=U\xb3': 'Possible Format',
# Add more signatures as necessary
})
# Check for known file signatures
for signature, file_type in file_signatures.items():
if data.startswith(signature):
print(f'Identified file format: {file_type}')
break
else:
print('File format could not be identified')
# Define the packet structure according to the protocol
packet_structure = {
'header': {'type': 'byte', 'length': 1},
'length': {'type': 'int', 'length': 4},
'payload': {'type': 'bytes', 'length': None}, # Length will be defined by the 'length' field
'checksum': {'type': 'byte', 'length': 1}
}
# Function to parse the packet based on the defined structure
def parse_packet(data):
print('Raw Data:', data) # Print the raw data for debugging
offset = 0
parsed_data = {}
# Print raw data for debugging in a readable format
print('Raw data (hex):', data.hex())
# Parse header
parsed_data['header'] = data[offset:offset + packet_structure['header']['length']]
offset += packet_structure['header']['length']
# Print the header bytes
header_bytes = parsed_data['header']
print('Header Bytes (hex):', header_bytes.hex())
print('Full Data (hex):', data.hex())
print('Surrounding Data (hex):', data[max(0, offset - 10):offset + 10].hex())
# Before extracting length
print('Current Offset before length extraction:', offset)
# Parse length using a new method
length_bytes = data[offset:offset + 4] # Read 4 bytes for the length
print('Raw Length Bytes:', length_bytes) # Print the raw length bytes
print('Raw Length Bytes (hex):', length_bytes.hex()) # Print the raw length bytes in hex
parsed_length = int.from_bytes(length_bytes, 'big') # Change to big-endian
print('Parsed Length (int):', parsed_length) # Print the parsed length
print('Parsed Length (hex):', parsed_length.to_bytes(4, 'little').hex()) # Print the parsed length in hex
print('Parsed Length (bin):', bin(parsed_length)) # Print the parsed length in binary
print('Parsed Length (oct):', oct(parsed_length)) # Print the parsed length in octal
if parsed_length <= 0 or parsed_length > len(data) - offset:
print(f"Error: Invalid payload length {parsed_length} at offset {offset}.")
return parsed_data
parsed_data['length'] = parsed_length
offset += 4
# Debugging information for length
print('Parsed Length:', parsed_data['length'])
print('Total Data Length:', len(data))
print('Offset:', offset)
try:
# Parse payload
parsed_data['payload'] = data[offset:offset + parsed_data['length']]
offset += parsed_data['length']
# Debugging information
print('Parsed Data:', parsed_data) # Print the entire parsed_data dictionary
except IndexError as e:
print(f"Error: {e}. Check data structure and length.")
return parsed_data
# Parse checksum
parsed_data['checksum'] = data[offset:offset + packet_structure['checksum']['length']]
print('Parsed Packet:', parsed_data)
return parsed_data
# Function to calculate checksum
def calculate_checksum(data):
return sum(data) % 256 # Simple checksum calculation (mod 256)
# Call the parse_packet function with the data
parsed_packet = parse_packet(data)
print('Parsed Packet:', parsed_packet)
# Calculate and validate the checksum
if 'payload' in parsed_packet:
calculated_checksum = calculate_checksum(parsed_packet['payload'])
if calculated_checksum == parsed_packet['checksum'][0]: # Assuming checksum is a single byte
print('Checksum is valid.')
else:
print('Checksum is invalid.')
else:
print('Error: Payload not found in parsed packet.')
# Frequency Test
freq_deviation = {char: freq - expected_frequency for char, freq in frequency.items()}
print('Frequency Test Deviation:')
for char, deviation in freq_deviation.items():
print(f'{char}: {deviation}')
# Runs Test
runs = 0
last_char = None
for char in data:
if char != last_char:
runs += 1
last_char = char
print(f'Runs Test: {runs} runs found.')
# Chi-Squared Test
chi_squared = sum((freq - expected_frequency) ** 2 / expected_frequency for freq in frequency.values())
print(f'Chi-Squared Test Statistic: {chi_squared}')
# Extract features
features = {'entropy': entropy}
features.update(frequency)
df = pd.DataFrame(list(features.items()), columns=['Feature', 'Value'])
print('Extracted Features:')
print(df)
# Visualize character frequencies
plt.figure(figsize=(12, 6))
sns.set_style('whitegrid')
sns.barplot(x=list(frequency.keys()), y=list(frequency.values()))
plt.title('Character Frequency Distribution')
plt.xlabel('Characters')
plt.ylabel('Frequency')
plt.xticks(rotation=90)
plt.tight_layout()
plt.savefig('static/char_freq.png')
print('Character frequency plot saved to static/char_freq.png')
# Visualize entropy
plt.figure(figsize=(8, 4))
sns.set_style('whitegrid')
plt.plot([entropy], marker='o')
plt.title('Entropy Visualization')
plt.xlabel('Segment')
plt.ylabel('Entropy')
plt.grid()
plt.savefig('static/entropy.png')
print('Entropy plot saved to static/entropy.png')
# Always generate and return a Fernet key at the very end
try:
key = Fernet.generate_key()
print(f'Generated key: {key.decode()}')
return key
except Exception as e:
print(f'Error generating key: {e}')
# Return a fallback key if something goes wrong (should never happen)
return Fernet.generate_key()
def search_for_pattern(data, pattern):
if pattern in data:
print(f'Pattern {pattern} found in data.')
else:
print(f'Pattern {pattern} not found in data.')
def compute_entropy(data):
"""Compute Shannon entropy for a bytes-like object."""
if not data:
return 0.0
from collections import Counter
total = len(data)
counts = Counter(data)
entropy = 0.0
for count in counts.values():
p = count / total
if p > 0:
entropy -= p * math.log2(p)
return entropy
MALWARE_FAMILIES = [
'wannacry', 'emotet', 'trickbot', 'qakbot', 'qbot', 'dridex', 'locky',
'notpetya', 'petya', 'ryuk', 'conti', 'revil', 'sodinokibi', 'blackcat',
'alphv', 'babuk', 'hive', 'blackmatter', 'darkside', 'hancitor', 'icedid',
'bokbot', 'sload', 'teslacrypt', 'cryptolocker', 'gandcrab', 'sekmet',
'ragnarok', 'maze', 'dharma', 'phobos', 'xtbl', 'medusalocker', 'nefilim',
'cobaltstrike', 'metasploit', 'mimikatz', 'azorult', 'lokibot', 'remcos',
'nanocore', 'darkcomet', 'njrat', 'quasar', 'asyncrat', 'warzone',
'revengerat', 'predatorthethief', 'stealer', 'agenttesla', 'formbook',
'xloader', 'redline', 'raccoon', 'vidar', 'stealc', 'lumma', 'prilex',
'snakelogger', 'smokeloader', 'grandoreiro', 'buer', 'pikabot',
'apt', 'apt1', 'apt28', 'apt29', 'lazarus', 'fin7', 'molerats',
'charmingkitten', 'turla', 'apt34', 'apt35', 'apt40', 'apt41',
'equation', 'regin', 'stuxnet', 'duqu', 'flame', 'gauss', 'tilded',
# Ransomware families
'lockbit', 'play', 'royal', 'akira', 'blackbasta', 'cuba', 'monti',
'incransom', 'bianlian', 'donex', 'vhd', 'fog', 'vex', 'inter',
'jigsaw', 'cerber', 'cryptowall', 'cryptxxx', 'ctblocker', 'globe',
'maktub', 'petya', 'saturn', 'shaded', 'spora', 'troldesh', 'wildfire',
'xorist', 'zzzz', 'badrabbit', 'satana', 'wannacrypt',
# Banking / info stealers
'zeus', 'citadel', 'spyeye', 'carberp', 'shifu', 'bebloh', 'caphaw',
'dyre', 'bugat', 'heodo', 'tinba', 'vawtrak', 'neverquest', 'kronos',
'osiris', 'urlzone', 'gozi', 'matsnu', 'murofet', 'fobber', 'xdedic',
'hawkeye', 'lokibot', 'formbook', 'agenttesla', 'redline', 'raccoon',
'vidar', 'stealc', 'lumma', 'prilex', 'snakelogger', 'azorult',
'grandoreiro', 'ursnif', 'gootkit', 'flubot', 'teabot', 'copperstealer',
# RATs / backdoors
'njrat', 'asyncrat', 'quasar', 'warzone', 'revengerat', 'darkcomet',
'nanocore', 'remcos', 'proton', 'adwind', 'alien', 'ap0calypse',
'beast', 'bifrost', 'blackshades', 'bluebanana', 'bozok', 'cybergate',
'dendroid', 'desertfalcon', 'diamondfox', 'ghostrat', 'glacier',
'jrat', 'netwire', 'poisonivy', 'pupy', 'shadowpad', 'spynote',
'sub7', 'xtreme', 'xagent', 'comrat', 'carbon', 'invisimole',
'empire', 'p0wn', 'chthonic', 'dridex', 'trickbot', 'emotet',
# Miners
'xmrig', 'minerd', 'cpuminer', 'nicehash', 'minergate', 'stratum',
'nanopool', 'xmrrig', 'xmrstak', 'ccminer', 'sgminer', 'cgminer',
'claymore', 'phoenixminer', 'trex', 'nbminer', 'gminer', 'lolminer',
# IoT / botnets
'mirai', 'satori', 'owari', 'masuta', 'reaper', 'hajime', 'brickerbot',
'gafgyt', 'fbot', 'tsunami', 'moobot', 'bigpipe', 'demonbot',
]
def yara_risk_score(rule_names):
"""Map YARA rule names to a 0-100 risk contribution.
Rules are grouped by severity. The score is capped at 100.
"""
if not rule_names:
return 0.0
score = 0.0
for rule in rule_names:
name = rule.lower()
# Malware families use word-boundary matching to avoid substring false positives (e.g. "apt" inside "adapt").
if any(re.search(r'\\b' + re.escape(family) + r'\\b', name) for family in MALWARE_FAMILIES):
score += 40.0
elif re.search(r'\\b(ransomware|persistence|credential)\\b', name):
score += 35.0
elif re.search(r'\\b(trojan|backdoor|rat)\\b', name):
score += 25.0
elif re.search(r'\\b(dropper|loader|downloader)\\b', name):
score += 20.0
elif re.search(r'\\b(adware|pua|pup)\\b', name):
score += 10.0
elif re.search(r'\\b(info|helper|tool)\\b', name):
score += 5.0
else:
score += 15.0
return min(100.0, score)
MITRE_TECHNIQUES = {
'ransomware': 'TA0040 (Impact)',
'persistence': 'TA0003 (Persistence)',
'credential': 'TA0006 (Credential Access)',
'trojan': 'TA0011 (Command and Control)',
'backdoor': 'TA0011 (Command and Control)',
'rat': 'TA0011 (Command and Control)',
'dropper': 'TA0023 (Resource Development)',
'loader': 'TA0023 (Resource Development)',
'downloader': 'TA0010 (Exfiltration)',
'adware': 'TA0042 (Resource Development)',
'pua': 'TA0042 (Resource Development)',
'pup': 'TA0042 (Resource Development)',
'stealer': 'TA0006 (Credential Access)',
'keylogger': 'TA0006 (Credential Access)',
'apt': 'TA0043 (Reconnaissance)',
'cobaltstrike': 'TA0011 (Command and Control)',
'mimikatz': 'TA0006 (Credential Access)',
'emotet': 'TA0008 (Lateral Movement)',
'trickbot': 'TA0006 (Credential Access)',
'qakbot': 'TA0008 (Lateral Movement)',
'dridex': 'TA0006 (Credential Access)',
'wannacry': 'TA0040 (Impact)',
'notpetya': 'TA0040 (Impact)',
'lockbit': 'TA0040 (Impact)',
'miner': 'TA0049 (Impact)',
'xmrig': 'TA0049 (Impact)',
}
def yara_mitre_tags(rule_names):
"""Return a list of MITRE ATT&CK technique tags for the matched YARA rules."""
if not rule_names:
return []
tags = set()
for rule in rule_names:
name = rule.lower()
for keyword, tag in MITRE_TECHNIQUES.items():
if re.search(r'\\b' + re.escape(keyword) + r'\\b', name):
tags.add(tag)
return sorted(tags)
PACKED_ENCODERS = [
'upx', 'aspack', 'pecompact', 'fsg', 'mpress', 'petite', 'telock',
'themida', 'winlicense', 'vmprotect', 'enigma', 'execryptor', 'armadillo',
'obsidium', 'krypton', 'shrinker', 'neolite', 'pespin', 'rlpack',
'nspack', 'expressor', 'acprotect', 'sdprotect', 'xcrypt', 'y0da',
'dingboy', 'wxpack', 'andpakk', 'lamecrypt', 'noreborg', 'pep', 'bxp',
'mew', 'bero', 'morphine', 'hackshield', 'themida', 'safengine',
'securom', 'starforce', 'tages', 'protectdisc', 'cdilla',
'packed', 'packed2', 'packer', 'cryptor', 'protector',
]
def packed_encoder_score(file_path, sample=8192):
"""Return a small risk score if the file contains known packer/encoder names."""
if not os.path.exists(file_path):
return 0.0
try:
with open(file_path, 'rb') as f:
data = f.read(sample)
lowered = data.lower()
score = 0.0
for name in PACKED_ENCODERS:
if name.encode() in lowered:
score += 5.0
return min(30.0, score)
except Exception:
return 0.0
EXPLOIT_MARKERS = {
b'cve-': 'CVE Reference',
b'eternalblue': 'EternalBlue (MS17-010)',
b'printnightmare': 'PrintNightmare',
b'log4j': 'Log4j RCE',
b'proxylogon': 'ProxyLogon',
b'proxyshell': 'ProxyShell',
b'sigred': 'SIGRed',
b'zerologon': 'Zerologon',
b'petitpotam': 'PetitPotam',
b'sambacry': 'SambaCry',
b'shellshock': 'Shellshock',
b'heartbleed': 'Heartbleed',
b'bluekeep': 'BlueKeep',
b'bluekeep-dbg': 'BlueKeep',
b'ms17-010': 'MS17-010',
b'ms14-058': 'MS14-058',
b'ms15-051': 'MS15-051',
b'ms16-032': 'MS16-032',
b'rop chain': 'ROP Chain',
b'nop sled': 'NOP Sled',
b'buffer overflow': 'Buffer Overflow',
b'heap spray': 'Heap Spray',
b'use-after-free': 'Use-After-Free',
b'skeleton key': 'Skeleton Key',
b'dcsync': 'DCSync',
b'kerberoast': 'Kerberoasting',
b'as-rep roast': 'AS-REP Roasting',
b'pass the hash': 'Pass-the-Hash',
b'pass the ticket': 'Pass-the-Ticket',
b'golden ticket': 'Golden Ticket',
b'silver ticket': 'Silver Ticket',
b'unconstrained delegation': 'Unconstrained Delegation',
b'rbcd': 'Resource-Based Constrained Delegation',
b'exploit-db': 'Exploit-DB',
b'proof of concept': 'Proof of Concept',
b'poc ': 'Proof of Concept',
b'n-day': 'N-Day Exploit',
b'0-day': 'Zero-Day',
}
def exploit_score(file_path, sample=8192):
"""Return a risk score if the file contains exploit/PoC references."""
if not os.path.exists(file_path):
return 0.0
try:
with open(file_path, 'rb') as f:
data = f.read(sample)
lowered = data.lower()
score = 0.0
for marker, label in EXPLOIT_MARKERS.items():
if marker in lowered:
if b'cve-' in marker or b'ms' in marker[:3]:
score += 3.0
else:
score += 8.0
return min(30.0, score)
except Exception:
return 0.0
DEFAULT_IOCS = {
'ips': [],
'domains': [],
'urls': [],
'sha256': []
}
def _load_iocs():
runtime_dir = os.environ.get('ANTIVIRUS_RUNTIME_DIR', os.path.dirname(os.path.abspath(__file__)))
ioc_path = os.path.join(runtime_dir, 'iocs.json')
if not os.path.exists(ioc_path):
return DEFAULT_IOCS
try:
with open(ioc_path, 'r', encoding='utf-8') as f:
return json.load(f)
except Exception:
return DEFAULT_IOCS
def network_ioc_score(file_path, iocs=None, sample=128 * 1024):
"""Return a risk score if the file contains known bad IPs, domains or URLs."""
if not os.path.exists(file_path):
return 0.0
if iocs is None:
iocs = _load_iocs()
try:
with open(file_path, 'rb') as f:
data = f.read(sample)
lowered = data.lower()
score = 0.0
for ip in iocs.get('ips', []):
if ip.lower().encode() in lowered:
score += 15.0
for domain in iocs.get('domains', []):
if domain.lower().encode() in lowered:
score += 10.0
for url in iocs.get('urls', []):
if url.lower().encode() in lowered:
score += 12.0
return min(40.0, score)
except Exception:
return 0.0
CVE_KB_MAP = {
'eternalblue': ['KB4012598', 'KB4012606', 'KB4013198', 'KB4013429', 'KB4018466',
'KB4012212', 'KB4012213', 'KB4012214', 'KB4012215', 'KB4012216', 'KB4012217'],
'ms17-010': ['KB4012598', 'KB4012606', 'KB4013198', 'KB4013429', 'KB4018466',
'KB4012212', 'KB4012213', 'KB4012214', 'KB4012215', 'KB4012216', 'KB4012217'],
'printnightmare': ['KB5004945', 'KB5004950', 'KB5004951', 'KB5004953', 'KB5004954',
'KB5004955', 'KB5004956', 'KB5004958', 'KB5004959', 'KB5004960', 'KB5004961'],
'log4j': [], # Java library; no single Windows patch
'proxylogon': ['KB5000871', 'KB5000953', 'KB5000960', 'KB5000978'],
'proxyshell': ['KB5001779', 'KB5004780', 'KB5004791'],
'sigred': ['KB4558998', 'KB4565503', 'KB4565511', 'KB4565513', 'KB4565529'],
'zerologon': ['KB4577668', 'KB4577670', 'KB4577671', 'KB4577683', 'KB4577669'],
'petitpotam': ['KB5005413', 'KB5005399', 'KB5005405', 'KB5005394', 'KB5005393',
'KB5005404', 'KB5005403', 'KB5005408', 'KB5005407', 'KB5005406'],
'sambacry': [], # Linux/Samba
'shellshock': [], # Bash
'heartbleed': [], # OpenSSL
'bluekeep': ['KB4499175', 'KB4499164', 'KB4499149', 'KB4499180', 'KB4499172',
'KB4499179', 'KB4499167'],
'ms14-058': ['KB3000061', 'KB3000869', 'KB3001554'],
'ms15-051': ['KB3051761', 'KB3055642'],
'ms16-032': ['KB3143141', 'KB3143145'],
'ms17-010': ['KB4012598', 'KB4012606', 'KB4013198', 'KB4013429', 'KB4018466'],
}
def get_installed_kb_patches():
"""Return a set of installed Windows KB numbers from wmic qfe."""
try:
output = subprocess.check_output(
['wmic', 'qfe', 'get', 'HotFixID', '/format:csv'],
shell=False,
timeout=30,
stderr=subprocess.STDOUT,
creationflags=0x08000000
)
text = output.decode('utf-8', errors='replace')
installed = set()
for line in text.splitlines():
parts = line.split(',')
if len(parts) >= 2:
kb = parts[-1].strip().strip('"')
if kb.upper().startswith('KB'):
installed.add(kb.upper())
return installed
except Exception as e:
logging = __import__('logging')
logging.getLogger('data_analysis').warning(f'Failed to query installed KB patches: {e}')
return set()
def missing_critical_patches():
"""Return a list of (exploit_name, required_kbs) for unpatched critical CVEs."""
installed = get_installed_kb_patches()
missing = []
for exploit, kbs in CVE_KB_MAP.items():
if not kbs:
continue
if not any(kb.upper() in installed for kb in kbs):
missing.append((exploit, kbs))
return missing
def _hash_sha256(file_path):
"""Return the SHA-256 hash of a file."""
import hashlib
h = hashlib.sha256()
try:
with open(file_path, 'rb') as f:
while True:
chunk = f.read(1024 * 1024)
if not chunk:
break
h.update(chunk)
return h.hexdigest()
except Exception:
return None
def load_trusted_hashes():
"""Load a set of trusted SHA-256 hashes from trusted_hashes.json."""
runtime_dir = os.environ.get('ANTIVIRUS_RUNTIME_DIR', os.path.dirname(os.path.abspath(__file__)))
path = os.path.join(runtime_dir, 'trusted_hashes.json')
if not os.path.exists(path):
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'trusted_hashes.json')
if not os.path.exists(path):
return set()
try:
with open(path, 'r', encoding='utf-8') as f:
data = json.load(f)
if isinstance(data, list):
return set(h.lower() for h in data if isinstance(h, str))
if isinstance(data, dict):
sha_list = data.get('sha256', [])
if isinstance(sha_list, list):
return set(h.lower() for h in sha_list if isinstance(h, str))
return set(v.lower() for v in data.values() if isinstance(v, str))
except Exception:
return set()
def is_trusted_file(file_path, trusted_hashes=None):
"""Return True if the file's SHA-256 is in the trusted hashes set."""
if trusted_hashes is None:
trusted_hashes = load_trusted_hashes()
sha256 = _hash_sha256(file_path)
if not sha256:
return False
return sha256.lower() in trusted_hashes
def compute_file_entropy(file_path, sample_bytes=1024 * 1024):
"""Read up to sample_bytes from a file and return its entropy."""
if not os.path.exists(file_path):
return 0.0
try:
with open(file_path, 'rb') as f:
data = f.read(sample_bytes)
return compute_entropy(data)
except Exception:
return 0.0
FILE_SIGNATURES = {
b'\x89PNG': 'PNG Image',
b'GIF8': 'GIF Image',
b'\xFF\xD8': 'JPEG Image',
b'%PDF': 'PDF Document',
b'PK\x03\x04': 'ZIP Archive',
b'PK': 'ZIP/MSI Archive',
b'RIFF': 'WAV/AVI File',
b'\x7FELF': 'ELF Executable',
b'\x42\x5A': 'BZ2 Compressed',
b'\xFF\xFB': 'MP3 Audio',
b'\x00\x00\x00\x20ftyp': 'MP4 Video',
b'<!DOCTYPE html>': 'HTML Document',
b'<?xml': 'XML Document',
b'\x52\x61\x72\x21': 'RAR Archive',
b'\x1F\x8B': 'GZIP Compressed',
b'\x4D\x5A': 'EXE/PE Executable',
b'\x30\x26\xB2\x75': 'WMV Video',
b'\x66\x74\x79\x70': 'FLV Video',
b'\x7B\x5C': 'JSON Document',
b'\x25\x50\x44\x46': 'PDF Document',
b'MZ': 'MS-DOS/PE Executable',
b'\xFE\xEF': 'SQL Server DB',
b'\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1': 'Microsoft Compound',
b'\x50\x4B\x05\x06': 'ZIP (empty)',
b'\x37\x7A\xBC\xAF\x27\x1C': '7-Zip Archive',
b'\xFD\x37\x7A\x58\x5A\x00': 'XZ Compressed',
b'BZh': 'BZIP2 Compressed',
b'\x1F\x9D': 'LZW/Z Compressed',
b'\x1F\xA0': 'LZH/Z Huf',
b'IC': 'ICQ Archive',
b'\.\xAF\xBC\xC0': 'GPG',
b'-----BEGIN PGP': 'PGP ASCII',
b'# Microsoft': 'PEF/CAB',
b'<?php': 'PHP Script',
b'<html': 'HTML Page',
b'<script': 'HTML/JS',
b'{"': 'JSON Data',
b'#!': 'Shell Script',
b'@echo': 'Batch Script',
b'registry': 'Windows Registry',
b'\xCA\xFE\xBA\xBE': 'Java Class',
b'PK\x07\x08': 'ZIP Archive',
b'\x4C\x01': 'OBJ/COFF',
b'\x5A\x4D': 'MS-DOS Executable',
# Additional media / archive / document signatures
b'ftypisom': 'MP4/ISO Media',
b'ftypmp42': 'MP4 Video',
b'ftypqt ': 'QuickTime',
b'\x00\x00\x01\xBA': 'MPEG/VOB',
b'\x00\x00\x01\xB3': 'MPEG Video',
b'OggS': 'Ogg Media',
b'fLaC': 'FLAC Audio',
b'ID3': 'MP3 Audio',
b'\xFF\xF1': 'AAC Audio',
b'\xFF\xF9': 'AAC Audio',
b'\x49\x44\x33': 'MP3 Audio',
b'\x4F\x67\x67\x53': 'Ogg Audio',
b'\x42\x4D': 'BMP Image',
b'\x47\x49\x46\x38': 'GIF Image',
b'\xFF\xD8\xFF\xE0': 'JPEG Image',
b'\xFF\xD8\xFF\xE1': 'JPEG Image',
b'\xFF\xD8\xFF\xEE': 'JPEG Image',
b'\xFF\xD8\xFF\xDB': 'JPEG Image',
b'\x75\x73\x74\x61\x72': 'TAR Archive',
b'\x1F\x8B\x08': 'GZIP Compressed',
b'\x28\xB5\x2F\xFD': 'Zstandard',
b'Rar!': 'RAR Archive',
b'xar!': 'XAR Archive',
b'\xD4\xC3\xB2\xA1': 'PCAP Capture',
b'\xA1\xB2\xC3\xD4': 'PCAP Capture',
b'\x0A\x0D\x0D\x0A': 'PCAPNG Capture',
b'\x7B\x0D\x0A\x20\x22': 'JSON Data',
b'\x2D\x2D\x2D\x2D\x2D\x42\x45\x47\x49\x4E': 'PEM/Key Data',
b'-----BEGIN RSA PRIVATE KEY-----': 'RSA Private Key',
b'-----BEGIN OPENSSH PRIVATE KEY-----': 'SSH Private Key',
b'-----BEGIN CERTIFICATE-----': 'X509 Certificate',
# Microsoft Office and common Windows/Adobe formats
b'\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1': 'Microsoft Compound (DOC/XLS/PPT)',
b'\x50\x4B\x05\x06': 'ZIP (empty)',
b'\x50\x4B\x07\x08': 'ZIP (spanned)',
b'MSWordDoc': 'Word Document',
b'Word.Document.': 'Word Document',
b'Excel.Sheet': 'Excel Spreadsheet',
b'PowerPoint.Show': 'PowerPoint Presentation',
b'%PDF-1.0': 'PDF Document',
b'%PDF-1.1': 'PDF Document',
b'%PDF-1.2': 'PDF Document',
b'%PDF-1.3': 'PDF Document',
b'%PDF-1.4': 'PDF Document',
b'%PDF-1.5': 'PDF Document',
b'%PDF-1.6': 'PDF Document',
b'%PDF-1.7': 'PDF Document',
b'%PDF-2.0': 'PDF Document',
b'%!PS-Adobe': 'PostScript Document',
b'%!PS': 'PostScript Document',
# Images
b'II*\x00': 'TIFF Image',
b'MM\x00*': 'TIFF Image',
b'\x00\x00\x00\x0C\x6A\x50\x20\x20\x0D\x0A\x87\x0A': 'JPEG 2000',
b'RIFF\x00\x00\x00\x00WEBP': 'WebP Image',
b'\x52\x49\x46\x46': 'RIFF Container',
b'\xFF\x0A': 'JPEG XL',
b'\x00\x00\x01\x00': 'ICO Icon',
b'<?xml version="1.0"?><svg': 'SVG Image',
b'<svg ': 'SVG Image',
b'\x89\x48\x44\x46\x0D\x0A\x1A\x0A': 'HDF5 Data',
# Disk / archive / container images
b'\x43\x44\x30\x30\x31': 'ISO Image',
b'\x45\x46\x49\x20\x50\x41\x52\x54': 'EFI Partition',
b'\x55\x44\x46\x62\xA4': 'UDF Image',
b'Concordance': 'DMG Disk Image',
b'KDMV': 'VMDK Disk',
b'VHDXFILE': 'VHDX Disk',
b'\x63\x6F\x6E\x6E\x65\x63\x74\x69\x78': 'VHD Disk',
b'\x78\x61\x72\x21': 'XAR Archive',
b'\x4D\x53\x57\x49\x4D': 'WIM Image',
b'\x78\x01\x73\x0D\x62\x62\x60': 'DMG/Zlib',
# Flash and legacy web
b'CWS': 'Flash SWF (compressed)',
b'FWS': 'Flash SWF',
b'ZWS': 'Flash SWF (LZMA)',
# Scripts / source files
b'using System;': 'C# Source',
b'using namespace': 'C++/C# Source',
b'#include <': 'C/C++ Source',
b'import ': 'Python/Java Source',
b'def ': 'Python Source',
b'package ': 'Java Source',
b'<?xml version=': 'XML Document',
b'<!--': 'XML/HTML Comment',
# Obscure / legacy / game / mobile / database
b'\xFE\xED\xFA\xCE': 'Mach-O 32-bit',
b'\xFE\xED\xFA\xCF': 'Mach-O 64-bit',
b'\xCA\xFE\xBA\xBE': 'Mach-O Universal',
b'\xBE\xBA\xFE\xCA': 'Mach-O Universal (reversed)',
b'\xCF\xFA\xED\xFE': 'Mach-O 64-bit (reversed)',
b'\xCE\xFA\xED\xFE': 'Mach-O 32-bit (reversed)',
b'\x64\x65\x78\x0A\x30\x33\x35\x00': 'Android DEX',
b'\x7F\x45\x4C\x46': 'ELF 32/64',
b'\x01\x4C': 'COFF i386',
b'\x4C\x01': 'COFF i386 (reversed)',
b'\x01\x64': 'COFF x64',
b'\x64\x01': 'COFF x64 (reversed)',
b'\x66\x01': 'COFF 64+ (reversed)',
b'000003F3': 'Amiga Hunk',
b'NEO': 'Atari NEO',
b'NES\x1A': 'NES ROM',
b'SEGA GENESIS': 'Mega Drive ROM',
b'PS-X EXE': 'PlayStation 1 EXE',
b'XBEH': 'Xbox XBE',
b'XEX1': 'Xbox 360 XEX',
b'XEX2': 'Xbox 360 XEX',
b'NTR': 'Nintendo DS ROM',
b'AGB\x0E': 'Game Boy Advance ROM',
b'MThd': 'MIDI Audio',
b'Rar!\x1A\x07\x01\x00': 'RAR5 Archive',
b'Rar!\x1A\x07\x00\x00': 'RAR4 Archive',
b'BOOKMOBI': 'MOBI/AZW eBook',
b'TEXtREAd': 'Palm PDB eBook',
b'MSCF': 'CAB Archive',
b'ISc(': 'CAB Archive (InstallShield)',
b'ITSF': 'Compiled HTML (CHM)',
b'ITOLITLS': 'Microsoft Reader LIT',
b'Standard Jet DB': 'Access MDB',
b'\x00\x01\x00\x00Standard Ace DB': 'Access ACCDB',
b'!BDN': 'Outlook PST/OST',
b'\x4C\x00\x00\x00\x01\x14\x02\x00': 'Windows LNK',
b'[InternetShortcut]': 'URL Shortcut',
b'SQLite format 3\x00': 'SQLite Database',
b'hsqs': 'SquashFS Image',
b'-rom1fs-': 'RomFS Image',
b'CRAM': 'CRAM File',
b'BAM\x01': 'BAM Sequence',
b'BCF\x02': 'BCF Sequence',
b'##fileformat=VCFv4': 'VCF Variant',
b'>': 'FASTA Sequence',
b'@': 'FASTQ Sequence',
b'LOCUS ': 'GenBank Record',
b'dirc': 'Git Index',
b'0x\x0A\x0D': 'Gopher Bookmark',
b'\x04"M\x18': 'LZ4 Frame',
b'\x28\xB5\x2F\xFD': 'Zstandard',
b'\xFD\x37\x7A\x58\x5A\x00': 'XZ Archive',
b'<parallels_disk_image>~': 'Parallels HDD',
b'\x54\x41\x50\x45\x00\x00': 'Microsoft Tape Format',
b'\x50\x41\x52\x31': 'PAR Archive',
b'\x4D\x53\x54\x41\x44\x44\x49\x4E': 'MS Theater',
b'\x00\x01\x00\x00\x00': 'Palm OS PRC',
b'\x00\x01\x00\x08\x00': 'Palm OS PQA',
b'\x00\x00\x00\x0C\x4A\x58\x4C\x20\x0D\x0A\x87\x0A': 'JPEG XL',
b'\x52\x49\x46\x46\x00\x00\x00\x00\x41\x43\x4F\x4E': 'Animated Cursor (ANI)',
b'\x42\x4C\x45\x4E\x44\x45\x52': 'Blender File',
b'Kaydara FBX Binary \x20': 'Autodesk FBX',
b'4D4D': '3D Studio Mesh',
b'\x73\x6C\x66\x34': 'SoundFont 2',
b'\x56\x47\x4D\x20': 'Video Game Music (VGM)',
b'\x50\x53\x49\x44': 'SID Music',
b'\x52\x53\x49\x44': 'SID Music (RSID)',
}
SUSPICIOUS_MARKERS = {
# Living-off-the-land interpreters / launchers
b'powershell.exe': 'PowerShell EXE',
b'powershell -': 'PowerShell Command',
b'cmd /c ': 'CMD Command',
b'wscript.exe': 'WScript',
b'cscript.exe': 'CScript',
b'mshta.exe': 'MSHTA',
b'certutil -': 'CertUtil',
b'regsvr32 ': 'Regsvr32',
b'rundll32 ': 'RunDLL32',
# Macro and script indicators
b'autoopen()': 'Macro AutoOpen',
b'auto_open()': 'Macro Auto_Open',
b'workbook_open()': 'Macro Workbook_Open',
b'wscript.shell': 'WScript.Shell',
b'shell.application': 'Shell.Application',
b'createobject(': 'CreateObject',
b'vbscript:': 'VBScript',