16位校验和模糊分析 – 利用“碰撞”,偏向一件事?

huangapple go评论59阅读模式
英文:

16 bit Checksum fuzzy analsysis - Leveraging "collisions", biases a thing?

问题

如果CRC RevEng的尝试没有成功,接下来该怎么办?这就是我的问题的要点。我正在努力学习如何独立思考,而不仅仅是寻找一次性问题的答案。

假设以下情况:

1.) 您对白盒算法有完全控制,并可以创建具有有效的16位/2字节校验和的任意选择样本消息。

2.) 您可以验证尽可能多的消息,以查看它们是否有效。

3.) 对白盒代码的静态或动态分析是禁止的(例如,如果MCU的制造需要电子显微镜来分析,虽然不是不可能,但对于我们的目的来说是禁止的)。

您可以使用以下方法或思路之一吗:

1.) 检查“碰撞”,即具有相同校验和的不同消息。也许对这些消息进行XOR操作并揭示一些信息?

2.) 利用对某些校验和的强烈偏好?

3.) 利用校验和“keyspace”的“滚动”,即在每65535个顺序递增的消息之后,您将看到某种顺序模式?

4.) 人工智能?

也许我遗漏了其他策略?

CRC RevEng工具未能找到答案,尽管使用了多种设置配置。

编辑:以下是一些示例消息

样本1: FFFFFFFFFFFF /

0100100A00000000000000000000FFFFFFFFFF72BE

样本2: 000000000000 /

0100100A00000000000000000000FFFFFFFFFF2A3D

样本3: 000000000001 /

0100100A00000000000000000000FFFFFFFFFF89F7

样本4: 000000000002 /

0100100A00000000000000000000FFFFFFFFFF0864

样本5: 000000000003 /

0100100A00000000000000000000FFFFFFFFFFABAE

样本6: 000000000004 /

0100100A00000000000000000000FFFFFFFFFF9396

样本7: 000000000005 /

0100100A00000000000000000000FFFFFFFFFF305C

样本8: 000000000006 /

0100100A00000000000000000000FFFFFFFFFFB1CF

英文:

If playing around with CRC RevEng fails, what next? That is the gist of my question. I am trying to learn more how to think for myself, not just looking for an answer 1 time to 1 problem.

Assuming the following:

1.) You have full control of white box algorithm and can create as many chosen sample messages as you want with valid 16 bit / 2 byte checksums

2.) You can verify as many messages as you want to see if they are valid or not

3.) Static or dynamic analysis of the white box code is off limits (say the MCU is of a lithography that would require electron microscope to analyze for example, not impossible but off limits for our purposes).

Can you use any of these methods or lines of thinking:

1.) Inspect "collisions", i.e. different messages with same checksum. Perhaps XOR these messages together and reveal something?

2.) Leverage strong biases towards certain checksums?

3.) Leverage "Rolling over" of the checksum "keyspace", i.e. every 65535 sequentially incremented messages you will see some type of sequential patterns?

4.) AI ?

Perhaps there are other strategies I am missing?

CRC RevEng tool was not able to find the answer using numerous settings configurations

EDIT: Here are some example messages

Sample 1: FFFFFFFFFFFF /

0100100A00000000000000000000FFFFFFFFFF72BE

Sample 2: 000000000000 /

0100100A00000000000000000000FFFFFFFFFF2A3D

Sample 3: 000000000001 /

0100100A00000000000000000000FFFFFFFFFF89F7

Sample 4: 000000000002 /

0100100A00000000000000000000FFFFFFFFFF0864

Sample 5: 000000000003 /

0100100A00000000000000000000FFFFFFFFFFABAE

Sample 6: 000000000004 /

0100100A00000000000000000000FFFFFFFFFF9396

Sample 7: 000000000005 /

0100100A00000000000000000000FFFFFFFFFF305C

Sample 8: 000000000006 /

0100100A00000000000000000000FFFFFFFFFFB1CF

答案1

得分: 0

Key properties and attacks:

  1. 如果你有两条相同长度的消息+ CRC,并对它们进行异或操作,结果将是一条消息和一个“纯”CRC,其中“纯”表示CRC定义的初始值和最终异或值都为零。这有助于消除这两个参数的影响,可以在以后解决。你不需要知道CRC在哪里,它有多长,或消息中的哪些位参与了CRC计算。这种线性特性成立。

  2. 利用从#1中净化的示例,如果你将任何两条相同长度的消息+纯CRC进行异或操作,你将得到另一条有效的消息+纯CRC。利用这个事实,你可以使用高斯-约旦消元法(在GF(2)上)来查看消息中的每个位是如何影响消息中生成的其他位的。借助这个方法,你可以找出a)消息中哪些位参与,b)哪些位可能是CRC(尽管其他位可能是输入的不同函数,可以通过下一个点解决),以及c)验证检查位确实是输入位在GF(2)上的线性函数。这也可以告诉你,如果没有任何位看起来是输入位的线性函数,那么你可能根本没有CRC。如果它是CRC,这可以为你提供长度的很好指示,假设你有一组连续的线性相关位。

  3. 假设你正在处理一个CRC,现在可以取输入位和多个示例的输出位,并尝试根据不同的输入位排序(反射或不反射,也许通过字节或其他单位)和CRC位移方向(反射或不反射)的不同假设来解决多项式。因为你谈论的是一个据称为16位CRC,所以最容易的方法是通过穷举法,尝试对每组位排序假设尝试所有32,768个可能的多项式。你甚至可以对32位CRC使用穷举法。对于更大的CRC,例如64位,你需要使用Berlekamp的有限域上多项式因子分解算法来在宇宙热寂之前解决这个问题。然后,你将每条消息+纯CRC分解为多项式,并查找多个示例中的共同因子。

  4. 现在,你已经有了消息位、CRC位、位排序和多项式,可以回到原始的非纯消息+ CRC,并解出初始值和最终异或值。你只需要两个不同长度的示例。然后,这就是在GF(2)上的两个方程中的两个未知数,非常简单。

享受!

英文:

Key properties and attacks:

  1. If you have two messages + CRCs of the same length and exclusive-or them together, the result is one message and one pure CRC on that message, where "pure" means a CRC definition with a zero initial value and zero final exclusive-or. This helps take those two parameters out of the equation, which can be solved for later. You do not need to know where the CRC is, how long it is, or which bits of the message are participating in the CRC calculation. This linear property holds.

  2. Working with purified examples from #1, if you take any two equal-length messages + pure CRCs and exclusive-or them together, you will get another valid message + pure CRC. Using this fact, you can use Gauss-Jordan elimination (over GF(2)) to see how each bit in the message affects other generated bits in the message. With this you can find out a) which bits in the message are particiapting, b) which bits are likely to be the CRC (though it is possible that other bits could be a different function of the input, which can be resolved by the next point), and c) verify that the check bits are each indeed a linear function of the input bits over GF(2). This can also tell you that you don't have a CRC to begin with, if there don't appear to be any bits that are linear functions of the input bits. If it is a CRC, this can give you a good indication of the length, assuming you have a contiguous set of linearly dependent bits.

  3. Assuming that you are dealing with a CRC, you can now take the input bits and the output bits for several examples and try to solve for the polynomial given different assumptions for the ordering of the input bits (reflected or not, perhaps by bytes or other units) and the direction of the CRC shifting (reflected or not). Since you're talking about an allegedly 16-bit CRC, this can be done most easily by brute force, trying all 32,768 possible polynomials for each set of bit ordering assumptions. You can even use brute force on a 32-bit CRC. For larger CRCs, e.g. 64 bits, you would need to use Berlekamp's algorithm for factoring polynomials over finite fields in order to solve the problem before the heat death of the universe. Then you would factor each message + pure CRC as a polynomial, and look for common factors over multiple examples.

  4. Now that you have the message bits, CRC bits, bit orderings, and the polynomial, you can go back to your original non-pure messages + CRCs, and solve for the initial value and final exclusive-or. All you need are two examples with different lengths. Then it's a simple two-equations-in-two-unknowns over GF(2).

Enjoy!

huangapple
  • 本文由 发表于 2023年2月10日 06:43:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75405215.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定