Skip to main content

Assignment Format

The output of this module should be a write-up or report in PDF format, named using the following convention: NRP_Name, and it should consist of the following sections:
  • Analysis – for example, identifying weaknesses in the given code or cryptographic scheme.
  • Approach / Methodology – explanation of your thought process and solution steps, supported with relevant code snippets or screenshots.
  • Complete Solver – the full source code used to solve the challenge.
  • Results – the output or flag produced by your solver. For all challenges except the final one, the flag format is cry{}.

chall

xorxor

Remember XOR property? The flag is XORed again with a secret 4-byte key (KEY5) for extra security.
k1=KEY1 
k21=KEY2 ^ KEY1 
k23=KEY2 ^ KEY3 
k1234=KEY4 ^ KEY1 ^ KEY3 ^ KEY2 
f45=FLAG ^KEY4^KEY5
k1=3c3f0193af37d2ebbc50cc6b91d27cf61197
k21=ff76edcad455b6881b92f726987cbf30c68c
k23=611568312c102d4d921f26199d39fe973118
k1234=91ec5a6fa8a12f908f161850c591459c3887
f45=0269dd12fe3435ea63f63aef17f8362cdba8

diffie-rsa

chall.py
from Crypto.Util.number import getPrime, bytes_to_long, long_to_bytes
import gmpy2

p = getPrime(1024)
q = getPrime(1024)
p_dh = getPrime(2048)
g = getPrime(512)
a = getPrime(512)
b = getPrime(512)

def generate_public_int(g, a, p):
    return g ^ a % p

def generate_shared_secret(A, b, p):
    return A ^ b % p

n = p * q
e = 3
flag = SECRET
flag_int = bytes_to_long(flag)
A = generate_public_int(g,a,p_dh)
B = generate_public_int(g,b,p_dh)
shared_int = generate_shared_secret(A, b, p_dh)
flag2 = flag_int ^ shared_int
c = pow(flag2, e, n)

print(f"e = {e}")
print(f"n = {n}")
print(f"c = {c}")
print(f"p_dh = {p_dh}")
print(f"g = {g}")
print(f"A = {A}")
print(f"B = {B}")
output
e = 3
n = 15759615042180649041596658287668414489189077112235860100211911115250431302849683276285731106548115937638289979087969524234208611870710633515079991373663766423874055118662541824187955220440397928304236310603796796313625606897016057576744677359943486392344503145709579678674348318782229297647714174217516018694539007160608944430937034544250573079612716803553232903441662736871400867227470549648830376257722171953827226464889796516771624865677860133545288603942196828709012321175773472875667188338169400264134585468501056099033472619127264375071663751561759303474430334279790862834581749708954285104699644046613927076737
c = 2344291097829188983579466594189698282383664262684774986896537805572522683128055047748300247696394242490422027188454859807664457337978658793000777936459309009372856166671075431096156773955444505970263472075618053238322211277550632944972952128574619481153303321045511668987706883106816408769713058690096813388100618801583589770113565361941160389675526436558849335309158887629222188384623313561824109056628841144631219564014897602033727802336373408793274102135597864
p_dh = 27418193655772318021836560801851416050692903432601761932322590631270856398846653223338769831601648160706338272455764128686694641329287363057124701884832655950429213044756229849133583778169948663310001940172285290324913736206656993532304071874389264706939842819610194020225775853088482880701572674061964002978113499344301009342814017383033244358886218297201525801832550215845980216778276302227039948212464281320312461226020648259134986770846870958550047603251642455520856609564172643782801942407985734762749720889604382796256436877614065358000405891185557651690273462831344090087006816576227532248090921032709043449811
g = 12050955267775767537568470242064572761840816042113877738976273507498444199871887767403180170097289251517250563450741923892010644458668065104572122677069707
A = 4454616487663596538806517973478271079131182042349146941797659062793031468845492590250220972656964845848862358234779851686655635425033976780511424646136324
B = 4124156168261670138441671835404469967345593457632202994459118983978680881665901731998435347814290648119083726613759685795578080384055344519189024908147976

hash cracker

Imagine you’ve just come across some confidential data that has been hashed as shown below:
  • 28cc09d8d8959871a97b24a07d87bcb05b9f3e7ac6d9f20ff82196ca5f908b2c
  • 6c569aabbf7775ef8fc570e228c16b98
Find the original plaintexts for the hashes above. You are allowed to use any tools.