Skip to content

Commit

Permalink
finish article
Browse files Browse the repository at this point in the history
  • Loading branch information
gogo2464 committed Oct 19, 2024
1 parent e74e920 commit 0e64c33
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: "Episode 2: Reversing cryptography algorithm made to be unreversables (checksum). Method by mathematical proof: disproof"
title: "Episode 2: Reversing cryptography algorithm made to be unreversable (checksum). Method by mathematical proof: disproof"
date: 2024-10-13T1:25:30+02:00
weight: 2
draft: false
Expand All @@ -11,27 +11,35 @@ According to the documentation and as it is mentionned that type 7 is an hashing

A secure hash algorithm is an hash algorithm so that for any function hash that transform the original (plaintext) value $ hased = H(plain) $ there does not exist a function $ rev(hashed) $ so that $ rev(hashed) = plain $.

## 1 - Analysis under mathematical thinking
## II - Notes:

I really definitely insist on this point: `It is crucial for a cryptologist to PROOVE his statement. Not just calculating.` If you only calculate, you could reach some proprietary algorithms such as this one but you will never ever be able to code CVE exploits on modern algorithms. I insist in the point you have to read [book fo proof](https://www.people.vcu.edu/~rhammack/BookOfProof/Main.pdf) if you did not do it yet. It is to do theorem proving.

## III - Analysis under mathematical thinking

The reverse engineering of the hash of vigenere cisco has permitted to deduct the method taken by this algorithm.

We could then guess that the researchers thanks then that:

![image](/gogo-s-blog-cpe/from-0-to-crypto-by-projects/episode-2-proof-demonstration/theory-behind-type7-hash.png)

The question is to proove that there exists a function $ rev(hashed) $ so that $ \forall plain [rev(H(plain)) = plain] $ then $ \forall x [x = H(plain)]$

The question is to proove that there exists a function $ rev(hashed) $ so that $ \forall plain [rev(H(plain)) = plain] $ then $ \forall x [x = H(plain)] $

We intuitevely see points to split the issue into easier pieces:

The algorith treat bigrams (blocks of two opcodes) as following:
- the two opcodes are both xored to the hardcoded password.
-
## IV/ 1- solving the theorem finding a way to proove the case.

There are a lot of different method to proove a theorem. You could pick the one you prefer or the one you find easier.

The big picture is to split the proof into several cases.

There a serveral various operations including:
- splitting number between 0 and 256 to two differnt more little number (the shift: $ \ggg $ and the logical and: $ \land 0xf0 $ ). Reversable by mergingtwo numbers in a single one with same algortihm.
- adding. You could simply substract to reverse.
- doing an boolean exclusive logical or to a known password.
- as each number exclusively logically set to logical or (xored) with itself has the final value of 0 and as 0 set to logical or with another number will return this number, ![image](/gogo-s-blog-cpe/from-0-to-crypto-by-projects/episode-2-proof-demonstration/reversing-exclusive-or.png) it follows that logically set to logical or to the hardcoded password one time will change the values but logically set to logical or a second time to the same hardcoded value will change it to the original value. See [boolean algebra](https://en.wikipedia.org/wiki/Exclusive_or#Definition), and see this schems provided with the tool name `cryptool-2`.

All of these are reversables.

Then I decide to choose a proof in the form: as $ A \implies B \implies C $, then $ A \implies C $.

We now have the mathematical proof (demonstration) that the algorithm is vulnerable [in this paper]( /gogo-s-blog-cpe/from-0-to-crypto-by-projects/episode-2-proof-demonstration/latex-reverse-type7.pdf ).
Let's check it out that [in this paper]( /gogo-s-blog-cpe/from-0-to-crypto-by-projects/episode-2-proof-demonstration/latex-reverse-type7.pdf )!
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@
h_{1} = 8, \\
h = \Sigma_{i=2}^{lp}
\begin{cases}
((p_i \oplus hp_{8 + i}) \ggg 4) + 0x30, & \text{if } (p_{i} \oplus hp_{i+8} \land 0xfffffff0 < 0xa0) \text{ and if } i \equiv 0 \pmod 2 \\
((p_i \oplus hp_{8 + i}) \ggg 4) + 0x37, & \text{if } (p_{i} \oplus hp_{i+8} \land 0xfffffff0 \geq 0xa0) \text{ and if } i \equiv 0 \pmod 2 \\
((p_i \oplus hp_{8 + i}) \land 0xf) + 0x30, & \text{if } (p_{i} \oplus hp_{i+8} \land 0xf < 0x0a) \text{ and if } i \equiv 1 \pmod 2 \\
((p_i \oplus hp_{8 + i}) \land 0xf) + 0x37, & \text{if } (p_{i} \oplus hp_{i+8} \land 0xf \geq 0x0a) \text{ and if } i \equiv 1 \pmod 2
((p_i \oplus hp_{8 + i}) \ggg 4) + 0x30, & \text{if } (h_{i} \oplus hp_{i+8} \land 0xfffffff0 < 0xa0) \text{ and if } i \equiv 0 \pmod 2 \\
((p_i \oplus hp_{8 + i}) \ggg 4) + 0x37, & \text{if } (h_{i} \oplus hp_{i+8} \land 0xfffffff0 \geq 0xa0) \text{ and if } i \equiv 0 \pmod 2 \\
((p_i \oplus hp_{8 + i}) \land 0xf) + 0x30, & \text{if } (h_{i} \oplus hp_{i+8} \land 0xf < 0x0a) \text{ and if } i \equiv 1 \pmod 2 \\
((p_i \oplus hp_{8 + i}) \land 0xf) + 0x37, & \text{if } (h_{i} \oplus hp_{i+8} \land 0xf \geq 0x0a) \text{ and if } i \equiv 1 \pmod 2
\end{cases} \\
) \implies \nexists p[p = \mathbf{rev}(h)] \\
Expand Down Expand Up @@ -165,8 +165,8 @@

It follows:

$ \forall y = H(x), y \in { y | 0 < y \leq 0xa + 0x30 } \implies x = y - 0x30 $ then $ 0 < x < 0xa $ $\\$
$ \forall y = H(x), y \in { y | 0 < y \leq 0xa + 0x37 } \implies x = y - 0x30 $ then $ 0xa < x < 0x13 $ $\\$
$ \forall y = H(x), y \in { y | 0 < y \leq 0x0a + 0x30 } \implies x = y - 0x30 $ then $ 0 < x < 0x0a $ $\\$
$ \forall y = H(x), y \in { y | 0 < y \leq 0x0a + 0x37 } \implies x = y - 0x30 $ then $ 0xa < x < 0x13 $ $\\$

# V /communtativity:

Expand Down Expand Up @@ -198,15 +198,15 @@
h_{1} = 8, \\
h = \Sigma_{i=2}^{lp}
\begin{cases}
(((p_{i} \oplus hp_{i+8}) \lll 4) - 0x30), & \text{if } p_i < 0xa0 \text{ and if } i \equiv 0 \pmod 2 \\
(((p_{i} \oplus hp_{i+8}) \lll 4) - 0x37), & \text{if } p_i \geq 0x0a0 \text{ and if } i \equiv 0 \pmod 2 \\
(((p_{i} \oplus hp_{i+8}) \land 0xffffffff0) - 0x30), & \text{if } p_i < 0x0a \text{ and if } i \equiv 1 \pmod 2 \\
(((p_{i} \oplus hp_{i+8}) \land 0xffffffff0) - 0x37), & \text{if } p_i \geq 0x0a \text{ and if } i \equiv 1 \pmod 2
(((p_{i} \oplus hp_{i+8}) \lll 4) - 0x30), & \text{if } h_i < 0xa0 \text{ and if } i \equiv 0 \pmod 2 \\
(((p_{i} \oplus hp_{i+8}) \lll 4) - 0x37), & \text{if } h_i \geq 0xa0 \text{ and if } i \equiv 0 \pmod 2 \\
(((p_{i} \oplus hp_{i+8}) \land 0xffffffff0) - 0x30), & \text{if } h_i < 0x0a \text{ and if } i \equiv 1 \pmod 2 \\
(((p_{i} \oplus hp_{i+8}) \land 0xffffffff0) - 0x37), & \text{if } h_i \geq 0x0a \text{ and if } i \equiv 1 \pmod 2
\end{cases} \\
) \implies \forall p[p = \mathbf{rev}(h)] \\
\]
\end{flushleft}
\end{multline}\\
\end{multline}
\end{flushleft}\\
$$
\end{document}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0e64c33

Please sign in to comment.