Skip to content

Instantly share code, notes, and snippets.

View enedil's full-sized avatar

Michał Radwański enedil

View GitHub Profile
#include <vector>
#include <fstream>
#include <array>
#include <cstdint>
#include <iostream>
using u32 = uint32_t;
using u64 = uint64_t;
const auto SECRET = 14810031;
const u32 masks[] = {43, 578, 22079, 142962};
import sys
import networkx as nx
"""
Algorytm znajdowania trasy Chińskiego Listonosza opiera się na rozszerzeniu
grafu wejściowego o dodatkowe krawędzie (co robi z niego multigraf) i odszukanie
w tak spreparowanym grafie ścieżki Eulera. Metoda doboru takich krawędzi
zapewnia optymalność łącznej sumy długości ścieżek.
"""
#!/usr/bin/env python3
import random
# Jeśli dostajesz błąd "ImportError: No module named gmpy2", możesz to naprawić
# dzięki poleceniu
# python3 -m pip install gmpy2
from gmpy2 import is_prime, invert
from sekrety import wiadomosc
pt = int.from_bytes(wiadomosc.encode(), 'big')
size = 1024
#!/usr/bin/env python3
import cgi
import os
import json
from base64 import b64decode, b64encode
from Crypto.Cipher import AES
from Crypto.Util.strxor import strxor
from Crypto.Util.Padding import pad, unpad
from Crypto.Util.number import long_to_bytes
#!/usr/bin/env python3
import cgi
from secret import N, e, d
def encrypt(m):
return pow(m, e, N)
def decrypt(c):
return pow(c, d, N)
#!/usr/bin/env python3
import cgi
import os
import json
from base64 import b64decode, b64encode
from Crypto.Cipher import AES
from Crypto.Util.strxor import strxor
from Crypto.Util.Padding import pad, unpad
from Crypto.Util.number import long_to_bytes
@enedil
enedil / my-simple-cipher.md
Last active September 4, 2017 02:04
my-simple-cipher.py

I use recursive relation

enc[n+1] = (enc[n] + msg[n] + key[n])%128

Note that last bytes of message are filled with flag, so this gives another relation (after inlining key_len and pipe_offset)

msg[n%13 + 22] = key[n%13]

Using this I start with given pipe character and perform jumping through the bytes of key. Thankfully, key_len and pipe_offset are coprime, so jumping doesn't mean falling into a small cycle. Therefore all bytes will be restored.

@enedil
enedil / babydlp.py
Created September 4, 2017 01:56
WTCTF2017, BabyDLP
#!/usr/bin/env python2
import os
import pwn
from Crypto.Util.number import long_to_bytes
p = 160634950613302858781995506902938412625377360249559915379491492274326359260806831823821711441204122060415286351711411013883400510041411782176467940678464161205204391247137689678794367049197824119717278923753940984084059450704378828123780678883777306239500480793044460796256306557893061457956479624163771194201
g = 2
make: pkg-config: Command not found
make: pkg-config: Command not found
../py/nlrthumb.c:73:5: error: non-ASM statement in naked function is not supported
return 0; // needed to silence compiler warning
^
../py/nlrthumb.c:40:16: note: attribute is here
__attribute__((naked)) unsigned int nlr_push(nlr_buf_t *nlr) {
^
../py/nlrthumb.c:89:5: error: non-ASM statement in naked function is not supported
nlr_buf_t **top_ptr = &MP_STATE_THREAD(nlr_top);
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
CC ../py/nlrthumb.c