๐Ÿ‘จโ€๐Ÿ’ป
CTFs
HomePlaygroundOSCPBuy Me a Flag ๐Ÿšฉ
  • ๐ŸšฉZeyu's CTF Writeups
  • Home
  • Playground
  • OSCP
  • My Challenges
    • SEETF 2023
    • The InfoSecurity Challenge 2022
    • SEETF 2022
    • Cyber League Major 1
    • STANDCON CTF 2021
      • Space Station
      • Star Cereal
      • Star Cereal 2
      • Mission Control
      • Rocket Science
      • Space University of Interior Design
      • Rocket Ship Academy
      • Space Noise
  • 2023
    • DEF CON CTF 2023 Qualifiers
    • hxp CTF
      • true_web_assembly
    • HackTM CTF Qualifiers
      • Crocodilu
      • secrets
      • Hades
  • 2022
    • niteCTF 2022
      • Undocumented js-api
      • js-api
    • STACK the Flags 2022
      • Secret of Meow Olympurr
      • The Blacksmith
      • GutHib Actions
      • Electrogrid
      • BeautyCare
    • LakeCTF Qualifiers
      • People
      • Clob-Mate
      • So What? Revenge
    • The InfoSecurity Challenge 2022
      • Level 1 - Slay The Dragon
      • Level 2 - Leaky Matrices
      • Level 3 - PATIENT0
      • Level 4B - CloudyNekos
      • Level 5B - PALINDROME's Secret (Author Writeup)
    • BalsnCTF 2022
      • 2linenodejs
      • Health Check
    • BSidesTLV 2022 CTF
      • Smuggler
      • Wild DevTools
      • Tropical API
    • Grey Cat The Flag 2022
    • DEF CON CTF 2022 Qualifiers
    • Securinets CTF Finals 2022
      • StrUggLe
      • XwaSS ftw?
      • Strong
      • Artist
    • NahamCon CTF 2022
      • Flaskmetal Alchemist
      • Hacker TS
      • Two For One
      • Deafcon
      • OTP Vault
      • Click Me
      • Geezip
      • Ostrich
      • No Space Between Us
    • Securinets CTF Quals 2022
      • Document-Converter
      • PlanetSheet
      • NarutoKeeper
    • CTF.SG CTF
      • Asuna Waffles
      • Senpai
      • We know this all too well
      • Don't Touch My Flag
      • Wildest Dreams Part 2
      • Chopsticks
    • YaCTF 2022
      • Shiba
      • Flag Market
      • Pasteless
      • Secretive
      • MetaPDF
      • Crackme
    • DiceCTF 2022
      • knock-knock
      • blazingfast
    • TetCTF 2022
      • 2X-Service
      • Animals
      • Ezflag Level 1
  • 2021
    • hxp CTF 2021
    • HTX Investigator's Challenge 2021
    • Metasploit Community CTF
    • MetaCTF CyberGames
      • Look, if you had one shot
      • Custom Blog
      • Yummy Vegetables
      • Ransomware Patch
      • I Hate Python
      • Interception
    • CyberSecurityRumble CTF
      • Lukas App
      • Finance Calculat0r 2021
      • Personal Encryptor with Nonbreakable Inforation-theoretic Security
      • Enterprice File Sharing
      • Payback
      • Stonks Street Journal
    • The InfoSecurity Challenge (TISC) 2021
      • Level 4 - The Magician's Den
      • Level 3 - Needle in a Greystack
      • Level 2 - Dee Na Saw as a need
      • Level 1 - Scratching the Surface
    • SPbCTF's Student CTF Quals
      • 31 Line PHP
      • BLT
      • CatStep
    • Asian Cyber Security Challenge (ACSC) 2021
      • Cowsay As A Service
      • Favorite Emojis
      • Baby Developer
      • API
      • RSA Stream
      • Filtered
      • NYONG Coin
    • CSAW CTF Qualification Round 2021
      • Save the Tristate
      • securinotes
      • no pass needed
      • Gatekeeping
      • Ninja
    • YauzaCTF 2021
      • Yauzacraft Pt. 2
      • Yauzabomber
      • RISC 8bit CPU
      • ARC6969 Pt. 1
      • ARC6969 Pt. 2
      • Back in 1986 - User
      • Lorem-Ipsum
    • InCTF 2021
      • Notepad 1 - Snakehole's Secret
      • RaaS
      • MD Notes
      • Shell Boi
      • Listen
      • Ermittlung
      • Alpha Pie
    • UIUCTF 2021
      • pwnies_please
      • yana
      • ponydb
      • SUPER
      • Q-Rious Transmissions
      • capture the :flag:
      • back_to_basics
      • buy_buy_buy
    • Google CTF 2021
      • CPP
      • Filestore
    • TyphoonCon CTF 2021
      • Clubmouse
      • Impasse
    • DSTA BrainHack CDDC21
      • File It Away (Pwn)
      • Linux Rules the World! (Linux)
      • Going Active (Reconnaissance)
      • Behind the Mask (Windows)
      • Web Takedown Episode 2 (Web)
      • Break it Down (Crypto)
    • BCACTF 2.0
      • L10N Poll
      • Challenge Checker
      • Discrete Mathematics
      • Advanced Math Analysis
      • Math Analysis
      • American Literature
      • More Than Meets the Eye
      • ๔ƒ—๔Œฒ”๔‡บŸ๔Šธ‰๔ซž๔„บท๔„งป๔ƒ„๔Šธ‰
    • Zh3ro CTF V2
      • Chaos
      • Twist and Shout
      • 1n_jection
      • alice_bob_dave
      • Baby SSRF
      • bxxs
      • Sparta
    • Pwn2Win CTF 2021
      • C'mon See My Vulns
      • Illusion
    • NorzhCTF 2021
      • Leet Computer
      • Secure Auth v0
      • Triskel 3: Dead End
      • Triskel 2: Going In
      • Triskel 1: First Contact
      • Discovery
    • DawgCTF 2021
      • Bofit
      • Jellyspotters
      • No Step On Snek
      • Back to the Lab 2
      • MDL Considered Harmful
      • Really Secure Algorithm
      • The Obligatory RSA Challenge
      • Trash Chain
      • What the Flip?!
      • Back to the Lab 1
      • Back to the Lab 3
      • Dr. Hrabowski's Great Adventure
      • Just a Comment
      • Baby's First Modulation
      • Two Truths and a Fib
    • UMDCTF 2021
      • Advantageous Adventures
      • Roy's Randomness
      • Whose Base Is It Anyway
      • Cards Galore
      • Pretty Dumb File
      • Minetest
      • Donnie Docker
      • Subway
      • Jump Not Easy
      • To Be XOR Not To Be
      • Office Secrets
      • L33t M4th
      • Bomb 2 - Mix Up
      • Jay
    • Midnight Sun CTF 2021
      • Corporate MFA
      • Gurkburk
      • Backups
    • picoCTF 2021
      • It Is My Birthday (100)
      • Super Serial (130)
      • Most Cookies (150)
      • Startup Company (180)
      • X marks the spot (250)
      • Web Gauntlet (170 + 300)
      • Easy Peasy (40)
      • Mini RSA (70)
      • Dachshund Attacks (80)
      • No Padding, No Problem (90)
      • Trivial Flag Transfer Protocol (90)
      • Wireshark twoo twooo two twoo... (100)
      • Disk, Disk, Sleuth! (110 + 130)
      • Stonks (20)
    • DSO-NUS CTF 2021
      • Insecure (100)
      • Easy SQL (200)
Powered by GitBook
On this page
  • Description
  • Solution

Was this helpful?

  1. 2022
  2. The InfoSecurity Challenge 2022

Level 2 - Leaky Matrices

PreviousLevel 1 - Slay The DragonNextLevel 3 - PATIENT0

Last updated 2 years ago

Was this helpful?

Description

Looks like PALINDROME implemented their own authentication protocol and cryptosystem to provide a secure handshake between any 2 services or devices. It does not look secure to us, can you take a look at what we have got?

Try to fool their authentication service: nc chal00bq3ouweqtzva9xcobep6spl5m75fucey.ctf.sg 56765

Solution

This was a pretty straightforward crypto challenge where a weak authentication scheme allowed the leaking of the secret key through a challenge-response sequence. This relied on the following matrix multiplication in GF(2)GF(2)GF(2).

Importantly, this is equivalent to

c1[s11s21โ‹ฎsn1]+c2[s12s22โ‹ฎsn2]+โ‹ฏcn[s1ns2nโ‹ฎsnn]=[c1s11+c2s12+โ‹ฏ+cns1nc1s21+c2s22+โ‹ฏ+cns2nโ‹ฎc1sn1+c2sn2+โ‹ฏ+cnsnn]c_1 \begin{bmatrix} s_{11} \\ s_{21} \\ \vdots \\ s_{n1} \end{bmatrix} + c_2 \begin{bmatrix} s_{12} \\ s_{22} \\ \vdots \\ s_{n2} \end{bmatrix} + \cdots c_n \begin{bmatrix} s_{1n} \\ s_{2n} \\ \vdots \\ s_{nn} \end{bmatrix} = \begin{bmatrix} c_{1}s_{11} + c_{2}s_{12} + \cdots + c_{n}s_{1n} \\ c_{1}s_{21} + c_{2}s_{22} + \cdots + c_{n}s_{2n} \\ \vdots \\ c_{1}s_{n1} + c_{2}s_{n2} + \cdots + c_{n}s_{nn} \end{bmatrix}c1โ€‹โ€‹s11โ€‹s21โ€‹โ‹ฎsn1โ€‹โ€‹โ€‹+c2โ€‹โ€‹s12โ€‹s22โ€‹โ‹ฎsn2โ€‹โ€‹โ€‹+โ‹ฏcnโ€‹โ€‹s1nโ€‹s2nโ€‹โ‹ฎsnnโ€‹โ€‹โ€‹=โ€‹c1โ€‹s11โ€‹+c2โ€‹s12โ€‹+โ‹ฏ+cnโ€‹s1nโ€‹c1โ€‹s21โ€‹+c2โ€‹s22โ€‹+โ‹ฏ+cnโ€‹s2nโ€‹โ‹ฎc1โ€‹sn1โ€‹+c2โ€‹sn2โ€‹+โ‹ฏ+cnโ€‹snnโ€‹โ€‹โ€‹

โ€‹Since we control the challenge bits c, we could leak the result of each column by challenging the server. For example, setting c1=1,c2...n=0c_1=1, c_{2 ... n}=0c1โ€‹=1,c2...nโ€‹=0 gives us

[r1r2โ‹ฎrn]=[c1s11c1s21โ‹ฎc1sn1]\begin{bmatrix} r_1 \\ r_2 \\ \vdots \\ r_n \end{bmatrix} = \begin{bmatrix} c_{1}s_{11} \\ c_{1}s_{21} \\ \vdots \\ c_{1}s_{n1} \end{bmatrix}โ€‹r1โ€‹r2โ€‹โ‹ฎrnโ€‹โ€‹โ€‹=โ€‹c1โ€‹s11โ€‹c1โ€‹s21โ€‹โ‹ฎc1โ€‹sn1โ€‹โ€‹โ€‹

โ€‹and since we can do the same for all c1...nc_{1...n}c1...nโ€‹, we could reconstruct the response to any challenge by adding up the relevant column results.

The solution to this challenge is to simply probe the server with 00000001, 00000010, ... 10000000, and when challenged, take the 1-bits and add up their corresponding probed values.

Since this happens in GF(2)GF(2)GF(2), addition is the same as XOR (hence the use of XOR in the script).

from pwn import *
import re

conn = remote("chal00bq3ouweqtzva9xcobep6spl5m75fucey.ctf.sg", 56765)

def solve():
    rows = []
    for i in range(8):
        conn.recvuntil(b"<-- ")
        binstr = "0" * (8 - i - 1) + "1" + "0" * (i)
        conn.send(binstr.encode() + b"\n")
        resp = conn.recvline().decode()
        match = re.search(r"--> (.*)\n", resp)
        
        rows.append(int(match.group(1), 2))
    
    for i in range(8):
        resp = conn.recvuntil(b"<-- ").decode()
        match = re.search(r"--> (.*)\n", resp)

        challenge = match.group(1)
        result = 0
        for j in range(8):
            if challenge[j] == "1":
                result ^= rows[7 - j]

        conn.send(bin(result)[2:].zfill(8).encode() + b"\n")
    
    conn.interactive()

solve()

This gives us the flag.

========================
All challenges passed :)
========================
=================================================================
Here is your flag: TISC{d0N7_R0lL_Ur_0wN_cRyp70_7a25ee4d777cc6e9}
=================================================================
2MB
2WKV_Whitepaper.pdf
pdf