<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Long Chengjiao</title>
    <description>The latest articles on DEV Community by Long Chengjiao (@gem3match).</description>
    <link>https://dev.to/gem3match</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4270952%2Ff7f3d82e-68c6-4b38-91f4-ea1e6f80ee59.png</url>
      <title>DEV Community: Long Chengjiao</title>
      <link>https://dev.to/gem3match</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gem3match"/>
    <language>en</language>
    <item>
      <title>Your denoiser drops the noise floor 20 dB and makes the audio worse</title>
      <dc:creator>Long Chengjiao</dc:creator>
      <pubDate>Mon, 30 Nov 2026 15:21:02 +0000</pubDate>
      <link>https://dev.to/gem3match/your-denoiser-drops-the-noise-floor-20-db-and-makes-the-audio-worse-bl3</link>
      <guid>https://dev.to/gem3match/your-denoiser-drops-the-noise-floor-20-db-and-makes-the-audio-worse-bl3</guid>
      <description>&lt;p&gt;Most noise-reduction code I see online makes the same mistake: it measures how much noise it removed, and never checks whether the speech survived.&lt;/p&gt;

&lt;p&gt;That is easy to do with a spectral subtractor. Subtract a noise estimate from every time-frequency bin and the noise floor drops 20 dB. Your log looks great. Then you listen and the consonants are gone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the usual metric lies
&lt;/h2&gt;

&lt;p&gt;The common check is band energy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# noise floor before vs after&lt;/span&gt;
&lt;span class="n"&gt;noise_db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;log10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;percentile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;S&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;axis&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 
&lt;span class="c1"&gt;# speech band before vs after  &lt;/span&gt;
&lt;span class="n"&gt;speech_db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;log10&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;S&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;300&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;3400&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both numbers can look perfect while the audio is unusable. Spectral subtraction removes energy proportionally, so quiet speech sounds — the ones carrying intelligibility — get subtracted along with the noise. The speech &lt;em&gt;band&lt;/em&gt; total barely moves because the loud vowels dominate the average. The &lt;em&gt;information&lt;/em&gt; is gone.&lt;/p&gt;

&lt;h2&gt;
  
  
  A metric that catches it
&lt;/h2&gt;

&lt;p&gt;STOI (Short-Time Objective Intelligibility) compares processed audio against a clean reference and scores how many words a listener could follow, 0 to 1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install pystoi
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;pystoi&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;stoi&lt;/span&gt;

&lt;span class="n"&gt;score_before&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;stoi&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;noisy&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;extended&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;score_after&lt;/span&gt;  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;stoi&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;clean&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;processed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;extended&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="kc"&gt;False&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;f&lt;/span&gt;&lt;span class="s2"&gt;"{score_before:.4f} -&amp;gt; {score_after:.4f}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If &lt;code&gt;score_after &amp;lt; score_before&lt;/code&gt;, your denoiser made the file harder to understand. No amount of dB reduction makes that a win.&lt;/p&gt;

&lt;h2&gt;
  
  
  What the numbers looked like
&lt;/h2&gt;

&lt;p&gt;I ran four real voice recordings through six noise conditions, 24 combinations, and swept the over-subtraction factor:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;alpha&lt;/th&gt;
&lt;th&gt;ΔSTOI (hum)&lt;/th&gt;
&lt;th&gt;noise floor&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;2.0&lt;/td&gt;
&lt;td&gt;−0.063&lt;/td&gt;
&lt;td&gt;−20.9 dB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.5&lt;/td&gt;
&lt;td&gt;−0.024&lt;/td&gt;
&lt;td&gt;−19.7 dB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;1.2&lt;/td&gt;
&lt;td&gt;−0.002&lt;/td&gt;
&lt;td&gt;−18.5 dB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;1.0&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;+0.009&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;−17.7 dB&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0.8&lt;/td&gt;
&lt;td&gt;+0.017&lt;/td&gt;
&lt;td&gt;−12.7 dB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;The aggressive setting removed 3 dB more noise and cost 0.07 STOI. That 0.07 is the difference between "clean recording" and "why do I sound like I'm underwater".&lt;/p&gt;

&lt;p&gt;The trade I picked: &lt;code&gt;alpha=1.0&lt;/code&gt;. Less noise gone, but intelligibility never drops.&lt;/p&gt;

&lt;h2&gt;
  
  
  Full results at alpha=1.0
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Noise&lt;/th&gt;
&lt;th&gt;ΔSTOI&lt;/th&gt;
&lt;th&gt;Noise floor&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Mains hum, 5 dB SNR&lt;/td&gt;
&lt;td&gt;+0.0228&lt;/td&gt;
&lt;td&gt;−22.9 dB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;White noise, 5 dB&lt;/td&gt;
&lt;td&gt;+0.0227&lt;/td&gt;
&lt;td&gt;−9.1 dB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fan / AC, 5 dB&lt;/td&gt;
&lt;td&gt;+0.0086&lt;/td&gt;
&lt;td&gt;−8.8 dB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hiss, 5 dB&lt;/td&gt;
&lt;td&gt;+0.0084&lt;/td&gt;
&lt;td&gt;−8.9 dB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Codec artefacts, 15 dB&lt;/td&gt;
&lt;td&gt;+0.0050&lt;/td&gt;
&lt;td&gt;−7.7 dB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reverb, 0.6 s&lt;/td&gt;
&lt;td&gt;+0.0004&lt;/td&gt;
&lt;td&gt;−5.5 dB&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;24 combinations: &lt;strong&gt;17 improved, 7 unchanged, 0 worse.&lt;/strong&gt; Worst case −0.0022, best +0.0432.&lt;/p&gt;

&lt;p&gt;Reverb being untouched is correct. Reflections are not noise. A tool that "removes" them is removing your room tone.&lt;/p&gt;

&lt;h2&gt;
  
  
  The point
&lt;/h2&gt;

&lt;p&gt;If you are writing a denoiser, measure STOI or PESQ, not just dB. The dB number will tell you what you want to hear.&lt;/p&gt;

&lt;p&gt;If you just want clean audio without writing any of this, I packaged the tuned version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip install speech-denoise
speech-denoise interview.wav
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It prints a verdict after each run — &lt;code&gt;GOOD&lt;/code&gt;, &lt;code&gt;MILD&lt;/code&gt;, &lt;code&gt;CAUTION&lt;/code&gt;, &lt;code&gt;ALREADY_CLEAN&lt;/code&gt; — so you know when it did not help. Free for personal use, $9 for commercial.&lt;/p&gt;

&lt;p&gt;Source and the 24-combination benchmark: &lt;a href="https://github.com/gem3match-dev/speech-denoise" rel="noopener noreferrer"&gt;github.com/gem3match-dev/speech-denoise&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;The 2.0× figure in the table above is from an earlier build of my own tool. I shipped it, measured it properly, and had to walk it back. Worth writing down so nobody repeats it.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>debugging</category>
      <category>programming</category>
      <category>python</category>
    </item>
    <item>
      <title>Why entropy can't see XOR-obfuscated code (and what to measure instead)</title>
      <dc:creator>Long Chengjiao</dc:creator>
      <pubDate>Mon, 30 Nov 2026 03:09:31 +0000</pubDate>
      <link>https://dev.to/gem3match/why-entropy-cant-see-xor-obfuscated-code-and-what-to-measure-instead-1i6n</link>
      <guid>https://dev.to/gem3match/why-entropy-cant-see-xor-obfuscated-code-and-what-to-measure-instead-1i6n</guid>
      <description>&lt;p&gt;Most packer and obfuscation detectors threshold on Shannon entropy. Above ~7.0 means "compressed or encrypted", below means "probably fine". That heuristic has a blind spot big enough to drive a truck through, and it is the most common obfuscation there is.&lt;/p&gt;

&lt;h2&gt;
  
  
  The measurement that doesn't move
&lt;/h2&gt;

&lt;p&gt;XOR is a bijection. It maps each byte value to exactly one other byte value, one-to-one. Shannon entropy is computed from the multiset of byte frequencies. A bijection permutes the labels on that multiset without changing which counts appear:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;H(XOR(data, k)) == H(data)     for every key k
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is an identity, not an approximation.&lt;/p&gt;

&lt;p&gt;I measured it on the &lt;code&gt;.text&lt;/code&gt; section of a real Windows DLL — &lt;code&gt;C:\Windows\System32\version.dll&lt;/code&gt;, 12,288 bytes:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Case&lt;/th&gt;
&lt;th&gt;Entropy&lt;/th&gt;
&lt;th&gt;Disassembly coverage&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Original&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.4067&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;100.00%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;XOR 0x5A&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.4067&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;2.54%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;XOR 0xFF&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.4067&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.69%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;XOR 0x01&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.4067&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.13%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Permuted&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;5.4067&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;0.41%&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Entropy delta on every transformed row: &lt;strong&gt;+0.0000&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Same numbers on &lt;code&gt;advapi32.dll&lt;/code&gt; (471,040-byte &lt;code&gt;.text&lt;/code&gt;): 6.2347 / 22.14% original, 6.2347 / 0.00% after XOR 0x5A.&lt;/p&gt;

&lt;p&gt;A tool that only measures entropy says "normal" for a section whose code is now entirely undecodable.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does move
&lt;/h2&gt;

&lt;p&gt;Decodable instruction coverage: start a disassembler at the section base, count what fraction of bytes valid instructions consume.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Real x64 code: typically 20–100% (not 100% — alignment padding and inline data sit between functions)&lt;/li&gt;
&lt;li&gt;XOR-obfuscated code: 0.00% — the decoder cannot form a single valid instruction&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That gap is the signal. No key needed, no unpacking, no execution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;capstone&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;pefile&lt;/span&gt;

&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;coverage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="kt"&gt;float&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;md&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;capstone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Cs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;capstone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CS_ARCH_X86&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;capstone&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;CS_MODE_64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;md&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;skipdata&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;False&lt;/span&gt;
    &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;ins&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;md&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;disasm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mh"&gt;0x1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;ins&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;size&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;code&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;code&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the whole detector. Four lines.&lt;/p&gt;

&lt;h2&gt;
  
  
  The key falls out for free
&lt;/h2&gt;

&lt;p&gt;Once you measure coverage, recovering a single-byte XOR key is a by-product: try all 255 candidates, keep the one whose output decodes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0x5A  →  100.00%   ← key
0x03  →    5.70%
0x23  →    4.36%
0x6F  →    4.24%
0xCB  →    4.13%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;94.30 percentage points between the right answer and the second-best guess. Nothing to tune, nothing to eyeball. Applied to a real DLL, the restored file is byte-identical to the original (SHA256 verified).&lt;/p&gt;

&lt;h2&gt;
  
  
  I tested the existing tools first
&lt;/h2&gt;

&lt;p&gt;Before building anything I ran the same three files through two established PE packer detectors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;entropystrip 1.3.0:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ entropystrip version_orig.dll
│  .text  │ 5.41 │ R+X │  OK  │

$ entropystrip version_xor5A.dll
│  .text  │ 5.41 │ R+X │  OK  │
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With &lt;code&gt;--deep&lt;/code&gt;, the full report is also identical — same score (50/100), same per-section statuses. The only differing fields are SHA256 and SSDEEP. The direction is even inverted: the pristine binary got &lt;code&gt;WARNING Suspicious&lt;/code&gt; (from a 7.47-entropy overlay, a real finding), and the obfuscated one did not.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;packerscope 0.4.0:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;file            is_packed   confidence
version_orig    False       0.02040816326530612
version_xor5A   False       0.02040816326530612
version_xorFF   False       0.02040816326530612
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Confidence identical to all 17 decimal places. &lt;code&gt;max_section_entropy: 5.4067&lt;/code&gt; in every report.&lt;/p&gt;

&lt;p&gt;Neither tool is wrong. Entropy, IAT, entrypoint and signature detectors all measure what they claim to measure. The gap is that none of them measure "does this code still decode", and that is the only measurement that moves under XOR.&lt;/p&gt;

&lt;h2&gt;
  
  
  Both directions of false positive are real
&lt;/h2&gt;

&lt;p&gt;A section holding data with code-like flags also scores near zero. In &lt;code&gt;advapi32.dll&lt;/code&gt;, &lt;code&gt;fothk&lt;/code&gt; is a 4,096-byte &lt;code&gt;RX&lt;/code&gt; section with entropy &lt;strong&gt;0.0159&lt;/strong&gt; — near zero because it is a jump table of identical stubs. Entropy flags nothing; coverage would flag it as suspicious. Reading it shows it is benign.&lt;/p&gt;

&lt;p&gt;So the verdict has to combine both numbers rather than threshold either one.&lt;/p&gt;

&lt;h2&gt;
  
  
  The guard that matters more than the detector
&lt;/h2&gt;

&lt;p&gt;An early version of my recovery script searched keys on a &lt;em&gt;clean&lt;/em&gt; file, found a meaningless 5.70% "best" (key 0x59) and wrote a corrupted copy over a working DLL.&lt;/p&gt;

&lt;p&gt;The fix was not a better search. It was refusing to act:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;base_coverage&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.20&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"This section already decodes. No recovery needed."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"If the file really fails to load, the cause is not single-byte XOR —"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"it may be a broken import table, a missing dependency, or a signature problem."&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;   &lt;span class="c1"&gt;# write nothing&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Any tool that can modify a file needs a condition under which it refuses to. Mine is coverage above 20%.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this does not cover
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Multi-byte XOR, block ciphers, virtualized code.&lt;/strong&gt; The 255-key search does not scale; the tool exits rather than guessing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Import tables, relocations, signatures.&lt;/strong&gt; If a file fails to load for those reasons, coverage looks normal and the tool correctly says it is not a single-byte XOR problem. It will not fix the real cause.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maliciousness.&lt;/strong&gt; Protectors obfuscate legitimately. The measurement says "this code is not decodable as-is", nothing more.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Where it came from
&lt;/h2&gt;

&lt;p&gt;I was looking at a DLL that had "suddenly stopped loading" and needed to know which of three things it was: encrypted, corrupted, or replaced with a loader stub. Three different repair strategies. An entropy reading said "clean". It was not clean.&lt;/p&gt;

&lt;p&gt;That check turned into a tool. Both the detector and the recovery script, with the full three-tool comparison and reproduction steps, are here:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/gem3match-dev/pe-obfuscation-detection" rel="noopener noreferrer"&gt;https://github.com/gem3match-dev/pe-obfuscation-detection&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;pip install peobf&lt;/code&gt; for the command-line detector, or a Windows GUI build on the releases page.&lt;/p&gt;




&lt;h2&gt;
  
  
  Trying it without installing anything
&lt;/h2&gt;

&lt;p&gt;If you just want to check whether this measurement catches something entropy misses, there is a free 10 MB build that reads the first three sections and prints the coverage number. No signup, no CLI:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://gem3matchdev.itch.io/pe-doctor-pro" rel="noopener noreferrer"&gt;PE Inspector — free build, Windows&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The full build adds single-byte key recovery across all 255 keys with the confidence margin, the report export, and the imports/exports/strings tabs. It is $9, and the free build tells you whether the approach matches how you already work before you spend it.&lt;/p&gt;

&lt;p&gt;If you find a file where the coverage number disagrees with what the binary actually does, tell me and I will look at it. That offer is the honest reason to write the post: a measurement is only worth something if someone tries to break it.&lt;/p&gt;

</description>
      <category>security</category>
      <category>python</category>
      <category>windows</category>
      <category>reverseengineering</category>
    </item>
  </channel>
</rss>
