This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BLOCK = 48 | |
class LFSR: | |
def __init__(self, init, mask, length=BLOCK): | |
self.init = init | |
self.length = length | |
self.lengthmask = 2 ** length - 1 | |
self.mask = mask & self.lengthmask |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lsb_oracle_attack(n, e, c, lsb_oracle): | |
''' | |
RSA LSB Oracle Attack | |
:param lsb_oracle: lsb_oracle(x) == pow(x, d, n) % 2 | |
:return: m or None if not found | |
''' | |
l, r, k2 = 0, 1, 1 | |
while n * l // k2 + 1 < n * r // k2: | |
m = l + r | |
l <<= 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from hashlib import sha256 | |
from random import choices, getrandbits, randint | |
import signal | |
import string | |
from flag import FLAG | |
def proof_of_work() -> bool: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from os import urandom | |
import signal | |
def getrandbits(bit): | |
return int.from_bytes(urandom(bit >> 3), "big") | |
def main(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from elasticsearch_dsl import DocType, Index, Integer, Text, Q | |
from elasticsearch_dsl.connections import connections | |
import time | |
post_index = Index('test_post') | |
class PostDoc(DocType): | |
author_id = Integer() # List[Integer] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
class MT19937Recover: | |
"""Reverses the Mersenne Twister based on 624 observed outputs. | |
The internal state of a Mersenne Twister can be recovered by observing | |
624 generated outputs of it. However, if those are not directly | |
observed following a twist, another output is required to restore the | |
internal index. | |
See also https://en.wikipedia.org/wiki/Mersenne_Twister#Pseudocode . |