Skip to content

Instantly share code, notes, and snippets.

@MariaRigaki
MariaRigaki / timing_attack.py
Created July 29, 2019 08:06
Timing attack using the picoscope 2204 SDK and arduino
import ctypes
import numpy as np
from picosdk.ps2000 import ps2000 as ps
import matplotlib.pyplot as plt
from picosdk.functions import adc2mV, assert_pico2000_ok
import serial
import time
ser = serial.Serial('/dev/ttyACM0')
ser.baudrate = 9600

Cryptopals is a set of cryptographic challenges, originally published here: https://cryptopals.com

Set 8 of the challenges was never published publicly, until late March 2018. However the cryptopals website was not updated to include the challenges. This gist compiles the 8th set of the Cryptopals challenges.

title link
57. Diffie-Hellman Revisited: Small Subgroup Confinement https://toadstyle.org/cryptopals/513b590b41d19eff3a0aa028023349fd.txt
58. Pollard's Method for Catching Kangaroos https://toadstyle.org/cryptopals/3e17c7b35fcf491d08c989081ed18c9a.txt
59. Elliptic Curve Diffie-Hellman and Invalid-Curve Attacks https://toadstyle.org/cryptopals/a0833e607878a80fdc0808f889c721b1.txt

Keybase proof

I hereby claim:

  • I am mariarigaki on github.
  • I am marik0 (https://keybase.io/marik0) on keybase.
  • I have a public key ASCAErwL2Qf_wrwIEsng6536j0g-mCRXF31B7PSCYl1XTQo

To claim this, I am signing this object:

@MariaRigaki
MariaRigaki / base18_decode.py
Created April 8, 2018 19:57
The last step from Avast's reversing challenge in security session 2018
# The message I got from the previous step was the following:
# The last step: 4e 3f 4a 5f 3g 5f 3d 3b 4c 5f 2c 46 1e 43 2f 4h 34 1e 2c 6c 32 5b 32 57 31 30 32 2h
# From that and the hint that "16 is not enough" we had to figure out that it was base18 encoded
# Decoder function from https://github.com/gg/integer_encoding
def decoder(alphabet):
"""
Returns a decoder that decodes a base-`len(alphabet)` encoded sequence of
alphabet elements into a positive integer.
@MariaRigaki
MariaRigaki / png_extender.py
Last active April 8, 2018 19:58
Read extra lines from PNG file (Avast reversing challenge at Security session 2018)
import png
rdr = png.Reader('E3EA158BA24F4D9573C04A0687F47F3BA3DB096ADA14729ECF7574678733E8AF.png')
w, h, pixels, meta = rdr.read()
# read returns width, height, pixels as Map and metadata
# (600,
# 790,
# <map at 0x7ff98c07e908>,
# {'alpha': False,
@MariaRigaki
MariaRigaki / ping_pong.py
Last active December 10, 2017 20:15
Solution for the ping pong problem using Z3Py
# Solution for the following problem:
# 3 friends (A, B and C) play ping-pong all day.
# The winner always keeps playing. A plays 10 games, B 15, C 17. Who lost the 2nd game?
# Problem by @eldracote https://twitter.com/eldracote/status/939614390571200514
from z3 import *
# Keep track of the players results (2 means win, 1 means loss, 0 is DNP)
A = IntVector('a', 21)
B = IntVector('b', 21)
# A solution to the CUCTF 2017 Future task using Z3Py
# inspired by Hackeriet's solution in https://blog.hackeriet.no/solution-to-tuctf-2017-future/
from z3 import *
# This is the flag format
# flag = "TUCTF{..................}"
auth = [0x8b, 0xce, 0xb0, 0x89, 0x7b, 0xb0, 0xb0, 0xee, 0xbf, 0x92, 0x65, 0x9d, 0x9a, 0x99, 0x99, 0x94, 0xad, 0xe4, 0x00]
# Declare the variables for Z3
@MariaRigaki
MariaRigaki / pg-pong-keras.py
Last active March 14, 2017 13:12
Keras implementation based on Andrej Karpathy's RL pong implementation (http://karpathy.github.io/2016/05/31/rl/)
# The base code was taken from https://gist.github.com/karpathy/a4166c7fe253700972fcbc77e4ea32c5
import numpy as np
import gym
from keras import models
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import RMSprop
# hyperparameters