Merge branch 'master' of git.juju.re:juju/juju.re

This commit is contained in:
Julien CLEMENT 2023-05-03 01:49:50 +02:00
commit 01057cae54
2 changed files with 15 additions and 14 deletions

View File

@ -10,7 +10,7 @@ toc: true
Brachiosaure is a math/puzzle challenge from `\J` for the 2023 edition of the Brachiosaure is a math/puzzle challenge from `\J` for the 2023 edition of the
FCSC. It's difficulty is not in the reversing process, which is fairly trivial FCSC. It's difficulty is not in the reversing process, which is fairly trivial
here, but in solving of underlying problem. here, but in solving the underlying problem.
{{< image src="/brachiosaure/meme.jpg" style="border-radius: 8px;" >}} {{< image src="/brachiosaure/meme.jpg" style="border-radius: 8px;" >}}
@ -170,9 +170,9 @@ Cutting drama right now, it is simply a matrix dot product:
Alright so to recap what actually happens: Alright so to recap what actually happens:
- In check serial, we perform the dot product of the user digest, interpreted a - In check serial, we perform the dot product of the user digest, interpreted
linearized 8 * 8 matrix, with itself, effectively squaring it, which gives us as a linearized 8 * 8 matrix, with itself, effectively squaring it, which
our serial (also in a linearized 8 * 8 matrix). gives us our serial (also in a linearized 8 * 8 matrix).
- In main, we perform the dot product of the user and serial IMAGES, and we can - In main, we perform the dot product of the user and serial IMAGES, and we can
see from the code that the return value indicates wether or not the resulting see from the code that the return value indicates wether or not the resulting
@ -242,11 +242,11 @@ over this bigger matrix, infinetely recursing.
OK, so after this misadventure, the next step is to understand that a single OK, so after this misadventure, the next step is to understand that a single
element of coordinates (i, j) from the dot product is impacted by all elements element of coordinates (i, j) from the dot product is impacted by all elements
of the ith line of the first matrix and all elements of the jth line. (You of the ith line of the first matrix and all elements of the jth column of the
actually already needed to understand this to implement my dumb idea but now we second. (You actually already needed to understand this to implement my dumb
will make it interesting). idea but now we will make it interesting).
Let's say that I take my first QR code and I double it's size and width like Let's say that I take my first QR code and I double it's height and width like
this where the purple ones are all 0 matrices and the green one is the identity: this where the purple ones are all 0 matrices and the green one is the identity:
{{< image src="/brachiosaure/resizing.png" style="border-radius: 8px;" >}} {{< image src="/brachiosaure/resizing.png" style="border-radius: 8px;" >}}
@ -301,9 +301,10 @@ And there is a really interesting property indeed:
{{< image src="/brachiosaure/invertible.png" style="border-radius: 8px;" >}} {{< image src="/brachiosaure/invertible.png" style="border-radius: 8px;" >}}
By adding empty matrices and an identity matrix in the bottom right corner, the By adding identity matrices and an empty matrix in the bottom right corner, the
resulting matrix is always invertible, and the inverse can be trivially computed resulting matrix is always invertible, and the inverse can be trivially
since it is simply moving matrices arround and negating the original image modulo 256 `notice the "-(QRuser)" in the inverted matrix`. computed since it is simply moving matrices arround and negating the original
image modulo 256 `notice the "-(QRuser)" in the inverted matrix`.
## Putting everything together ## Putting everything together
@ -332,7 +333,7 @@ from the remote service and the upload of the images to recover the flag.
But before leaving this writeup there is still something I want to show you at the end. But before leaving this writeup there is still something I want to show you at the end.
{{< code file="/static/brachiosaure/solve_writeup.py" language="c" >}} {{< code file="/static/brachiosaure/solve_writeup.py" language="python" >}}
```console ```console
@ -373,4 +374,4 @@ inverse matrix:
- We add identity matrices: they only have the diagonal set to 1 so only a little bit grayer than the black, no noise visible by naked eyes - We add identity matrices: they only have the diagonal set to 1 so only a little bit grayer than the black, no noise visible by naked eyes
- We add the opposite of the matrix, and this is the clean part: our original matrices only hold black and white pixels so respectively `0x0` and `0xff`, so the opposite of `0` is still `0` and the opposite of `0xff` if `1` modulo 256, so like the identity matrix, they are nearly invisible. If you look closely though :eyes: you will see that all white pixels of the QR code were indeed reflected as very faint taint of gray in its inverse matrix on the other image. - We add the opposite of the matrix, and this is the clean part: our original matrices only hold black and white pixels so respectively `0x0` and `0xff`, so the opposite of `0` is still `0` and the opposite of `0xff` if `1` modulo 256, so like the identity matrix, they are nearly invisible. If you look closely though :eyes: you will see that all white pixels of the QR code were indeed reflected as very faint taint of gray in its inverse matrix on the other image.

View File

@ -88,7 +88,7 @@ matrix_img_serial = img_to_matrix(img_serial)
def invert(usr, serial): def invert(usr, serial):
# Add empty and identity matrices to maka it invetible # Add empty and identity matrices to make it invetible
usr = make_invertible(usr) usr = make_invertible(usr)
serial = make_invertible(serial) serial = make_invertible(serial)