Skip to content

Latest commit

 

History

History
87 lines (55 loc) · 1.49 KB

ctf.md

File metadata and controls

87 lines (55 loc) · 1.49 KB

CTF resources

Crypto

AES

from Crypto.Cipher import AES

key = bytes.fromhex('2b7e1...')
iv =    bytes.fromhex('00010203...')
ciphertext = bytes.fromhex('e47bc2d...')

cipher = AES.new(key, AES.MODE_CBC, iv)
plaintext = cipher.decrypt(ciphertext)

RSA

We have e*d = 1 mod phi. This also means there is an int k, such that e*d = k*phi + 1.

from Crypto.Util.number import inverse, long_to_bytes, getPrime
from math import gcd

n = int(0x8d926...)
m = b'tototata...'

int_m = bytes_to_long(m)

# d = 1/e mod phi
d_b = inverse(e_b, phi)

# decrypt
plaintext = pow(ciphertext,d_b, n)

p = getPrime(1024)

if gcd(e, phi) == 1:
   print("blah")
   

Communication with a server

from pwn import *

def choice(number):
    p.recvuntil("Choice: ")
    p.sendline(str(number))

Pcap

  • Output as JSON
  • Process pcap with dpkt in Python.
import dpkt
with open("capture.pcap", "rb") as file:
    pcap = dpkt.pcap.Reader(file)

Stegano

Write-ups