Rating:

# IceCTF 2016 – Matrix

## Problem

>I like to approach problems with a fresh perspective and try to visualize the problem at hand.

## Solution

Import the challenge file as a list of strings.

mathematica
matrix = Import[
"List"]



{"0x00000000", "0xff71fefe", "0x83480082", "0xbb4140ba",
"0xbb6848ba", "0xbb4a80ba", "0x83213082", "0xff5556fe", "0xff5556fe",
"0x00582e00", "0x576fb9be", "0x707ef09e", "0xe74b41d6", "0xa82c0f16",
"0x27a15690", "0x8c643628", "0xbfcbf976", "0x4cd959aa", "0x2f43d73a",
"0x5462300a", "0x57290106", "0xb02ace5a", "0xef53f7fc", "0xef53f7fc",
"0x00402e36", "0xff01b6a8", "0x83657e3a", "0xbb3b27fa", "0xbb5eaeac",
"0xbb1017a0", "0x8362672c", "0xff02a650", "0x00000000"}


Convert each hex number to a list of binary digits.

mathematica
binary = IntegerDigits[FromDigits[StringTrim[#, "0x"], 16], 2, 32] & /@ matrix



{{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0},
{1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0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1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0},
{1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0},
{1, 0, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0},
{1, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0},
{1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}


Attempt to create a QR code from the data. There is some corruption that looks like duplicated rows or columns.

mathematica
ColorNegate@Image@binary


![corrupted qr code image](qrcode-corrupt.png)

Delete duplicate rows, then transpose the matrix to delete duplicate columns.

mathematica
cleaned = DeleteDuplicates@Transpose@DeleteDuplicates@binary;


Create an image from the cleaned up data.

mathematica
image = ColorNegate@Image[cleaned]


![qr code image](qrcode.png)

mathematica