Skip to content

Instantly share code, notes, and snippets.

View samueltangz's full-sized avatar
🏳️
Capture the white flag

Samuel Tang samueltangz

🏳️
Capture the white flag
View GitHub Profile
from Crypto.Cipher import AES
from Crypto.Util.number import long_to_bytes
import hashlib
from random import randint
def sha256(my_string):
m = hashlib.sha256(my_string).digest()
v = long_to_bytes(ZZ(m.encode('hex'), 16))
return v
def gcd(a, b):
while b: a, b = b, a % b
return a
a1 = 97
b1 = 60824696933898946564451801612435320499799420685700840763560112095108031899334
a2 = 98
b2 = 55380756008140998400554730883757097743477949263876721308471329268298435052112
a3 = 99
b3 = 74193339277347514708965540905420499429551183132658118576165808841075904065168
#!/usr/env/bin python
# -*- coding: UTF-8 -*-
from gmpy2 import powmod
import random
import dlog
m = 4902227890643
chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789{}_'
@samueltangz
samueltangz / gctf2020-oracle.md
Last active February 12, 2024 19:20
Google CTF 2020: Oracle

Google CTF 2020: Oracle

I was teamed-up with Black Bauhinia on Google CTF this time. I have solved 7 challenges alone and 3 challenges with my teammates.

In particular, Oracle is a crypto challenge with 13 solves. It has got me spending 12 hours. All in all, it was a great experience in terms of learning, but my liver hurts. This piece of writeup may be very computation intensive, just because I would like to make everything clear.

Challenge Summary

There are two parts of the challenges. In the first part, we are required to recover an internal state for AEGIS-128L given the encryption oracle. For the second part, we are required to forge a ciphertext given an error oracle from decryption.