You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#print( f"avgs: {' '.join( f'{m:{stride*2}.1f}' for m in mags_avgs )}: {sum(mags_avgs):7.2f}" )
450
474
returnstrongest
475
+
signal_entropy.signal_limits= {
476
+
128: {
477
+
False: {
478
+
3: 3.6290539642295268,
479
+
4: 3.507324239128957,
480
+
5: 4.0,
481
+
6: 4.0,
482
+
7: 4.0,
483
+
8: 4.0,
484
+
},
485
+
True: {
486
+
3: 3.980779955578968,
487
+
4: 3.757892208378965,
488
+
5: 4.0,
489
+
6: 4.0,
490
+
7: 4.0,
491
+
8: 4.0,
492
+
}
493
+
},
494
+
256: {
495
+
False: {
496
+
3: 4.110541587940857,
497
+
4: 3.552135847422123,
498
+
5: 4.0,
499
+
6: 4.0,
500
+
7: 4.0,
501
+
8: 4.0,
502
+
},
503
+
True: {
504
+
3: 4.432511412288454,
505
+
4: 4.096532008409936,
506
+
5: 4.0,
507
+
6: 4.0,
508
+
7: 4.0,
509
+
8: 4.0,
510
+
}
511
+
}
512
+
}
451
513
452
514
453
515
defshannon_entropy(
@@ -485,7 +547,7 @@ def shannon_entropy(
485
547
exceptException:
486
548
pass
487
549
assertthresholdand0<threshold<1, \
488
-
f"A small +'ve ratio threshold of Shannon entropy deficit > 0 is required for {length}-bit entropy w/ {stride}-bit symbols eg. 10%, not {threshold=!r}"
550
+
f"A small +'ve ratio threshold of Shannon entropy deficit (0, 1] is required for {length}-bit entropy w/ {stride}-bit symbols eg. 10%, not {threshold=!r}"
489
551
490
552
# Find all the unique n-bit symbols in the entropy at the desired offset(s)
491
553
strongest=None
@@ -615,11 +677,28 @@ def shannon_entropy(
615
677
defanalyze_entropy(
616
678
entropy: bytes,
617
679
strides: Optional[Union[int,Tuple[int,int]]] =None, # If only a specific stride/s makes sense, eg. for ASCII symbols
618
-
symbols: int=16,
619
680
overlap: bool=True,
620
681
ignore_dc: bool=False,
621
682
) ->Optional[str]:
622
-
"""Analyzes the provided entropy. If patterns are found, reports the findings."""
683
+
"""Analyzes the provided entropy. If patterns are found, reports the findings; the peak Signal
684
+
and the aggregate report: (Signal, "...").
685
+
686
+
Seek strong Signals or weak Shannon Entropy, across a number of different interpretations (bit
687
+
strides and overlaps) of the entropy data. We do not know where poor entropy may hide...
688
+
689
+
Since the probability of a signal being found is:
690
+
691
+
P( A or B or ... or Z ) = P(A) + P(B) + ... + P(Z) - P(A and B and ... Z )
692
+
= P( A or B or ... or Z ) = P(A) + P(B) + ... + P(Z) - ( P(A) * P(B) * ... P(Z) )
693
+
694
+
since we set the {signal,shannon}_entropy threshold values at ~ <1%, we know the P(A and B...)
695
+
term is very small; the probability we'll find an entropy failure it basically is the sum of the
696
+
individual probabilities of each test failing.
697
+
698
+
So, if we try 6 of each analysis, that's 12 * 1% =~= 12%. We want a total failure of about 1%,
699
+
so we must target a 0.1% failure on good entropy for each test.
700
+
701
+
"""
623
702
ifstridesisNone:
624
703
strides= (3, 9)
625
704
else:
@@ -628,11 +707,11 @@ def analyze_entropy(
628
707
exceptTypeError:
629
708
strides= (int(strides), int(strides)+1)
630
709
631
-
# For signal analysis, we limit ourself to symbols-sized groups of stride-bit symbols
710
+
# For signal analysis, we use the default <= ~128-bit groups of stride-bit symbols
0 commit comments