<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>天空软件工作室的博客 — 逆向经验与算法</title><description>逆向经验与算法（仅公开文章全文）</description><link>https://tkrjw.cn/</link><language>zh-cn</language><item><title>逆向工程的方法论是什么？从入口定位到算法还原的通用路径</title><link>https://tkrjw.cn/posts/reverse/reverse-methodology/</link><guid isPermaLink="true">https://tkrjw.cn/posts/reverse/reverse-methodology/</guid><description>把逆向分析沉淀为可复用的五步方法论：明确目标、找入口、跟数据流、还原文法、验证闭环。适用于协议分析、客户端分析与算法识别，附工具链建议。</description><pubDate>Sat, 05 Sep 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;逆向分析的通用方法论只有五步：&lt;strong&gt;明确目标 → 定位入口 → 追踪数据流 → 还原逻辑 → 闭环验证&lt;/strong&gt;。所有具体技巧都挂在这条链上。这篇文章把这五步展开，让你在拿到任何陌生目标时有一张确定性的地图。&lt;/p&gt;
&lt;h2 id=&quot;为什么逆向需要方法论而不是技巧&quot;&gt;为什么逆向需要方法论而不是技巧？&lt;/h2&gt;
&lt;p&gt;技巧（某个 Hook 点位、某条 IDA 快捷键）会随目标与工具版本过期，但&amp;quot;从现象反推实现&amp;quot;的路径是稳定的。方法论的另一个作用是&lt;strong&gt;控制范围&lt;/strong&gt;：明确这次分析只回答什么问题，防止在百万行的反编译代码里漫无目的地漂移。&lt;/p&gt;
&lt;h2 id=&quot;第一步明确目标与边界&quot;&gt;第一步：明确目标与边界&lt;/h2&gt;
&lt;p&gt;动手前写下三行字：要还原什么（例：请求头里 X-Sign 的生成算法）、验收标准是什么（例：本地能对任意输入复现出一致的签名）、合法边界在哪（例：自建靶场/授权项目）。这一步看似形式主义，实际决定了后面每一步的取舍。&lt;/p&gt;
&lt;h2 id=&quot;第二步怎么找入口&quot;&gt;第二步：怎么找入口？&lt;/h2&gt;
&lt;p&gt;按性价比从高到低试这些锚点：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;字符串与字段名&lt;/strong&gt;：参数名、URL 片段、错误文案在反编译产物里全局搜索，命中率最高；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;网络层回溯&lt;/strong&gt;：Hook 收发函数（如 &lt;code&gt;XMLHttpRequest&lt;/code&gt;、&lt;code&gt;OkHttp&lt;/code&gt; 拦截点），对请求体下断点，沿调用栈向上找；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;算法指纹&lt;/strong&gt;：魔数（0x67452301 等）、S-box、固定表名——直接暴露标准算法的存在。&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;shiki shiki-themes one-light one-dark-pro&quot; style=&quot;--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic&quot;&gt;// 示例：用 Frida 快速确认某函数是否是目标入口&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;Interceptor&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;attach&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;Module&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;getBaseAddress&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&apos;libtarget.so&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#D19A66&quot;&gt;0x1A2B3C&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;), {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;  onEnter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-light-font-style:inherit;--shiki-dark:#E06C75;--shiki-dark-font-style:italic&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;    console&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&apos;arg0:&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E06C75&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#D19A66&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;readUtf8String&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;());  &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic&quot;&gt;// 观察输入&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;  onLeave&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-light-font-style:inherit;--shiki-dark:#E06C75;--shiki-dark-font-style:italic&quot;&gt;ret&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;    console&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&apos;ret :&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;ret&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;readUtf8String&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;());      &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic&quot;&gt;// 观察输出&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;第三步追踪数据流&quot;&gt;第三步：追踪数据流&lt;/h2&gt;
&lt;p&gt;拿到入口后，问三个问题：&lt;strong&gt;输入从哪来、经过哪些变换、输出去了哪&lt;/strong&gt;。把中间变量按顺序 dump 出来，对相邻两次调用做差分——值变了但逻辑没变的字段是盐/时间戳，值不变的往往是密钥或设备指纹。&lt;/p&gt;
&lt;h2 id=&quot;第四步还原逻辑&quot;&gt;第四步：还原逻辑&lt;/h2&gt;
&lt;p&gt;先判断是标准算法还是自研变体：&lt;/p&gt;
&lt;pre class=&quot;shiki shiki-themes one-light one-dark-pro&quot; style=&quot;--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;特征: MD5 常量 0x67452301 / AES S-box / SHA-256 K 表 → 标准算法，直接套库验证&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;异常: 常量被替换、轮数改变、多一轮异或 → 魔改，逐段 diff 定位改动点&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;用 python 快速验证假设，输入输出对不上就回到第三步补 dump。常见的 &lt;a href=&quot;/posts/reverse/hash-encoding-identify&quot;&gt;哈希与编码特征对照&lt;/a&gt; 可以把识别时间从小时级压到分钟级。&lt;/p&gt;
&lt;h2 id=&quot;第五步闭环验证&quot;&gt;第五步：闭环验证&lt;/h2&gt;
&lt;p&gt;把还原的算法封装成独立函数，用&lt;strong&gt;目标在真实运行中产生的多组输入输出对&lt;/strong&gt;做回归验证：10 组全对才算还原成功。只对一组样例&amp;quot;碰巧一致&amp;quot;是最常见的假阳性。&lt;/p&gt;
&lt;h2 id=&quot;工具链建议&quot;&gt;工具链建议&lt;/h2&gt;
&lt;p&gt;静态：IDA / Ghidra / jadx（Android）/ 浏览器 DevTools（JS）。动态：Frida 通用性最好，入门见 &lt;a href=&quot;/posts/reverse/frida-hook-layers&quot;&gt;Frida Hook 的三个层次&lt;/a&gt;。所有分析在授权范围内进行——本文与后续实战篇只覆盖方法论与自建靶场演示，不涉及任何具体商业产品的绕过。&lt;/p&gt;
</content:encoded><category>逆向</category><category>方法论</category><category>协议分析</category></item><item><title>Frida 入门：Hook 函数的三个层次与调试技巧</title><link>https://tkrjw.cn/posts/reverse/frida-hook-layers/</link><guid isPermaLink="true">https://tkrjw.cn/posts/reverse/frida-hook-layers/</guid><description>Frida Hook 从易到难的三个层次：Java 层 Hook、Native 函数 Hook、运行中代码的内存级操作，附完整可运行脚本与环境搭建步骤。</description><pubDate>Wed, 12 Aug 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;Frida 的 Hook 能力分三个层次：&lt;strong&gt;Java 层方法拦截 → Native 函数拦截 → 内存级读写&lt;/strong&gt;。从上往下难度递增、能力递增。本文按层次给出可运行的最小脚本与排错思路，帮你把&amp;quot;注入成功&amp;quot;到&amp;quot;拿到数据&amp;quot;的距离缩到最短。&lt;/p&gt;
&lt;h2 id=&quot;环境怎么搭&quot;&gt;环境怎么搭？&lt;/h2&gt;
&lt;pre class=&quot;shiki shiki-themes one-light one-dark-pro&quot; style=&quot;--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic&quot;&gt;# PC 端（以 Python 环境为例）&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;pip&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt; install&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt; frida-tools&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;frida&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#D19A66&quot;&gt; --version&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic&quot;&gt;# Android 设备端：下载对应架构的 frida-server 推送并运行&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;adb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt; push&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt; frida-server-android-arm64&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt; /data/local/tmp/fs&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;adb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt; shell&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt; &quot;chmod +x /data/local/tmp/fs &amp;#x26;&amp;#x26; /data/local/tmp/fs &amp;#x26;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic&quot;&gt;# 验证连接&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;frida-ps&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#D19A66&quot;&gt; -U&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;测试目标建议使用 OWASP UnCrackable 或自写的 demo app——&lt;strong&gt;不要拿线上商业产品练手&lt;/strong&gt;。&lt;/p&gt;
&lt;h2 id=&quot;层次一java-层-hook&quot;&gt;层次一：Java 层 Hook&lt;/h2&gt;
&lt;p&gt;目标在 jadx 里能看到的方法，用 &lt;code&gt;Java.perform&lt;/code&gt; 拦截：&lt;/p&gt;
&lt;pre class=&quot;shiki shiki-themes one-light one-dark-pro&quot; style=&quot;--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic&quot;&gt;// hook_java.js — 拦截某类的静态方法并打印参数与返回值&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;Java&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;perform&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(() &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;=&gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;  const&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#E5C07B&quot;&gt; Cls&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0184BC;--shiki-dark:#56B6C2&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt; Java&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;use&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&apos;com.demo.app.CryptoUtil&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;  Cls&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E45649;--shiki-dark:#E5C07B&quot;&gt;sign&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;overload&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&apos;java.lang.String&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;implementation&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0184BC;--shiki-dark:#56B6C2&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-light-font-style:inherit;--shiki-dark:#E06C75;--shiki-dark-font-style:italic&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;    const&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#E5C07B&quot;&gt; ret&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0184BC;--shiki-dark:#56B6C2&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E45649;--shiki-dark:#E5C07B&quot;&gt; this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;sign&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E06C75&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;    console&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&apos;[sign] in :&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E06C75&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;    console&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&apos;[sign] out:&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E06C75&quot;&gt;ret&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E06C75&quot;&gt; ret&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;  };&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;shiki shiki-themes one-light one-dark-pro&quot; style=&quot;--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-bash&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;frida&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#D19A66&quot;&gt; -U&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#D19A66&quot;&gt; -l&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt; hook_java.js&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#D19A66&quot;&gt; -f&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt; com.demo.app&lt;/span&gt;&lt;span style=&quot;--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic&quot;&gt;   # spawn 模式，覆盖 attach 抓不到早期调用的场景&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;常见坑：方法重载时必须用 &lt;code&gt;overload()&lt;/code&gt; 指定签名；类名被混淆就用脚本枚举当前内存里的类。&lt;/p&gt;
&lt;h2 id=&quot;层次二native-层-hook&quot;&gt;层次二：Native 层 Hook&lt;/h2&gt;
&lt;p&gt;目标在 so 库里，先用偏移量定位，再 &lt;code&gt;Interceptor.attach&lt;/code&gt;：&lt;/p&gt;
&lt;pre class=&quot;shiki shiki-themes one-light one-dark-pro&quot; style=&quot;--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-js&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic&quot;&gt;// hook_native.js — 拦截 so 中的未导出函数（偏移 0x1A2B3C）&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#E5C07B&quot;&gt; base&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0184BC;--shiki-dark:#56B6C2&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt; Module&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;getBaseAddress&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&apos;libnative.so&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;Interceptor&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;attach&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;base&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#D19A66&quot;&gt;0x1A2B3C&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;), {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;  onEnter&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-light-font-style:inherit;--shiki-dark:#E06C75;--shiki-dark-font-style:italic&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A0A1A7;--shiki-light-font-style:italic;--shiki-dark:#7F848E;--shiki-dark-font-style:italic&quot;&gt;    // 按函数约定读参数：指针按字节读，整型按位读&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;    console&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&apos;[n] arg0 ptr:&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E06C75&quot;&gt;args&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#D19A66&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;].&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;readCString&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;  },&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;  onLeave&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-light-font-style:inherit;--shiki-dark:#E06C75;--shiki-dark-font-style:italic&quot;&gt;ret&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;    console&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;log&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&apos;[n] ret:&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#E5C07B&quot;&gt;ret&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt;toInt32&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;());&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;定位偏移的方法：IDA 打开 so → 找到目标函数 → 记录函数起始地址减去模块基址。导出函数可以直接 &lt;code&gt;Module.getExportByName(null, &apos;symbol&apos;)&lt;/code&gt;。&lt;/p&gt;
&lt;h2 id=&quot;层次三内存级操作&quot;&gt;层次三：内存级操作&lt;/h2&gt;
&lt;p&gt;前两层都不奏效时（函数被内联、逻辑写在宏里），退到内存层：&lt;code&gt;Memory.scan&lt;/code&gt; 搜特征字节、&lt;code&gt;Memory.readByteArray&lt;/code&gt; 直接读数据区、&lt;code&gt;Memory.protect&lt;/code&gt; 改页属性。这是&amp;quot;最后手段&amp;quot;，脚本可移植性差，每次版本更新都要重新定位。&lt;/p&gt;
&lt;h2 id=&quot;调试心法&quot;&gt;调试心法&lt;/h2&gt;
&lt;p&gt;三个技巧贯穿三层次：&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;差分观察&lt;/strong&gt;：同一操作重复两次，对比 dump 结果，找&amp;quot;变的&amp;quot;和&amp;quot;不变的&amp;quot;字段；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;从调用栈反推&lt;/strong&gt;：&lt;code&gt;console.log(Java.use(&apos;android.util.Log&apos;).getStackTraceString(Java.use(&apos;java.lang.Exception&apos;).$new()))&lt;/code&gt; 打印 Java 调用栈，定位是谁在调目标函数；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;最小化注入&lt;/strong&gt;：一次只 Hook 一个函数，确认生效再加下一个——批量 Hook 出错时几乎无法定位。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Frida 在完整分析流程中的位置，见 &lt;a href=&quot;/posts/reverse/reverse-methodology&quot;&gt;逆向方法论五步&lt;/a&gt;；拿到关键数据后如何还原算法，将在会员篇 &lt;a href=&quot;/posts/reverse/sign-algorithm-analysis&quot;&gt;签名算法分析实战&lt;/a&gt; 中以自建靶场为例完整演示。&lt;/p&gt;
</content:encoded><category>frida</category><category>hook</category><category>逆向</category><category>android</category></item><item><title>如何快速识别一个哈希或编码算法？特征长度对照表</title><link>https://tkrjw.cn/posts/reverse/hash-encoding-identify/</link><guid isPermaLink="true">https://tkrjw.cn/posts/reverse/hash-encoding-identify/</guid><description>通过长度、字符集与已知特征串快速识别 MD5/SHA 家族、Base64/Base58/Hex、AES/RC4 等常见算法，附速查表与验证代码，逆向分析的第一块拼图。</description><pubDate>Wed, 01 Jul 2026 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;逆向分析中，识别&amp;quot;这段数据是什么算法的产物&amp;quot;是第一块拼图。方法就三招：&lt;strong&gt;看长度、看字符集、用已知输入验证&lt;/strong&gt;。本文给一张速查表加一段验证代码，把识别时间压到分钟级。&lt;/p&gt;
&lt;h2 id=&quot;第一步看长度与字符集&quot;&gt;第一步：看长度与字符集&lt;/h2&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;输出特征&lt;/th&gt;
&lt;th&gt;候选算法&lt;/th&gt;
&lt;th&gt;备注&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;32 hex&lt;/td&gt;
&lt;td&gt;MD5&lt;/td&gt;
&lt;td&gt;空串结果 &lt;code&gt;d41d8cd9...8427e&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;40 hex&lt;/td&gt;
&lt;td&gt;SHA-1&lt;/td&gt;
&lt;td&gt;空串 &lt;code&gt;da39a3ee5e6b4b0d3255bfef95601890afd80709&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;64 hex&lt;/td&gt;
&lt;td&gt;SHA-256&lt;/td&gt;
&lt;td&gt;空串 &lt;code&gt;e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;128 hex&lt;/td&gt;
&lt;td&gt;SHA-512&lt;/td&gt;
&lt;td&gt;空串 &lt;code&gt;cf83e135...&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;A-Za-z0-9+/=&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Base64&lt;/td&gt;
&lt;td&gt;末尾 &lt;code&gt;=&lt;/code&gt; 是填充标志&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;A-Za-z0-9&lt;/code&gt;（无 &lt;code&gt;+/=&lt;/code&gt;，无 &lt;code&gt;0OlI&lt;/code&gt;）&lt;/td&gt;
&lt;td&gt;Base58&lt;/td&gt;
&lt;td&gt;比特币地址常用&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;纯数字&lt;/td&gt;
&lt;td&gt;纯数字编码/自研&lt;/td&gt;
&lt;td&gt;常见于业务混淆 ID&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;高熵二进制&lt;/td&gt;
&lt;td&gt;加密/压缩&lt;/td&gt;
&lt;td&gt;需结合代码特征判断&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;第二步用已知输入验证&quot;&gt;第二步：用已知输入验证&lt;/h2&gt;
&lt;p&gt;记住四个&amp;quot;指纹值&amp;quot;，验证标准哈希只需一行：&lt;/p&gt;
&lt;pre class=&quot;shiki shiki-themes one-light one-dark-pro&quot; style=&quot;--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-python&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt; hashlib&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;known &lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#56B6C2&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;    &quot;md5&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;:    &lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&quot;d41d8cd98f00b204e9800998ecf8427e&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;    &quot;sha1&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;:   &lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&quot;da39a3ee5e6b4b0d3255bfef95601890afd80709&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;    &quot;sha256&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&quot;e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;def&lt;/span&gt;&lt;span style=&quot;--shiki-light:#4078F2;--shiki-dark:#61AFEF&quot;&gt; identify&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-light-font-style:inherit;--shiki-dark:#D19A66;--shiki-dark-font-style:italic&quot;&gt;digest&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0184BC;--shiki-dark:#56B6C2&quot;&gt; str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;) -&gt; &lt;/span&gt;&lt;span style=&quot;--shiki-light:#0184BC;--shiki-dark:#56B6C2&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#56B6C2&quot;&gt; |&lt;/span&gt;&lt;span style=&quot;--shiki-light:#986801;--shiki-dark:#D19A66&quot;&gt; None&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;    d &lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#56B6C2&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt; digest.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#61AFEF&quot;&gt;lower&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;    for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt; name, empty &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt; known.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#61AFEF&quot;&gt;items&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;():&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;        if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt; hashlib.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#61AFEF&quot;&gt;new&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(name, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;b&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt;&quot;&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#61AFEF&quot;&gt;hexdigest&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;() &lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#56B6C2&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt; empty &lt;/span&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;and&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0184BC;--shiki-dark:#56B6C2&quot;&gt; len&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(d) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#56B6C2&quot;&gt;==&lt;/span&gt;&lt;span style=&quot;--shiki-light:#0184BC;--shiki-dark:#56B6C2&quot;&gt; len&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt;(empty):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;            return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#383A42;--shiki-dark:#ABB2BF&quot;&gt; name&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#A626A4;--shiki-dark:#C678DD&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#50A14F;--shiki-dark:#98C379&quot;&gt; &quot;unknown（可能加盐/魔改/截断）&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;对不上指纹值不一定是&amp;quot;不是这个算法&amp;quot;——&lt;strong&gt;加盐或魔改&lt;/strong&gt;会让空串指纹失效，这时转入第三步。&lt;/p&gt;
&lt;h2 id=&quot;第三步进代码找结构特征&quot;&gt;第三步：进代码找结构特征&lt;/h2&gt;
&lt;p&gt;数据层面区分不了加密算法，要进代码看常量：&lt;/p&gt;
&lt;pre class=&quot;shiki shiki-themes one-light one-dark-pro&quot; style=&quot;--shiki-light:#383A42;--shiki-dark:#abb2bf;--shiki-light-bg:#FAFAFA;--shiki-dark-bg:#282c34&quot; tabindex=&quot;0&quot;&gt;&lt;code class=&quot;language-text&quot;&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;AES   : S-box 以 0x63, 0x7c, 0x77, 0x7b... 开头；轮常量 0x01, 0x02, 0x04...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;DES   : 初始置换表 IP[58, 50, 42, ...]；16 轮迭代&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;RC4   : 256 长度状态盒 + KSA/PRGA 双循环，无魔数常量&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;RSA   : 大数运算 + e 常见取值 0x10001 (65537)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;CRC32 : 查表法 0xEDB88320（反射）或 0x04C11DB7（正向）&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;IDA/Ghidra 里全局搜索这些字节序列，命中即有答案。Standard Hash 的魔数（MD5 的 &lt;code&gt;0x67452301&lt;/code&gt;、SHA-1 的 &lt;code&gt;0x5A827999&lt;/code&gt;）也适用于定位哈希函数位置。&lt;/p&gt;
&lt;h2 id=&quot;常见陷阱&quot;&gt;常见陷阱&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;长度对上就下结论&lt;/strong&gt;——32 hex 也可能是两次 MD5 套接或加盐 MD5，必须动态验证；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;忽略编码嵌套&lt;/strong&gt;——&lt;code&gt;Base64(Hex(MD5(x)))&lt;/code&gt; 三层嵌套很常见，逐层解到指纹值为止；&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;把压缩当加密&lt;/strong&gt;——zlib/gzip 头分别是 &lt;code&gt;78 9C&lt;/code&gt; 和 &lt;code&gt;1F 8B&lt;/code&gt;，先解压再分析。&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;识别只是起点，数据流追踪与算法还原的完整路径见&lt;a href=&quot;/posts/reverse/reverse-methodology&quot;&gt;逆向方法论&lt;/a&gt;；Frida 动态验证手段见 &lt;a href=&quot;/posts/reverse/frida-hook-layers&quot;&gt;Frida Hook 三个层次&lt;/a&gt;。&lt;/p&gt;
</content:encoded><category>逆向</category><category>算法</category><category>哈希</category><category>编码</category></item></channel></rss>