Skip to content

Instantly share code, notes, and snippets.

View 73spica's full-sized avatar

Haruka Hoshino 73spica

View GitHub Profile
from sage.all import *
# ======== Extended Euclidean algorithm ========
def egcd(a, b):
if a == 0:
return (b, 0, 1)
else:
g, y, x = egcd(b % a, a)
return (g, x - (int(b / a)) * y, y)
from urllib.parse import urlencode, quote, quote_plus
import hashlib
import hmac
import base64
from operator import itemgetter
import time
import requests
import os # for nonce
@73spica
73spica / get_user_timeline.py
Last active July 2, 2018 08:15
Using twitter api without python library.
import requests
from base64 import b64decode, b64encode
# SECRET:)
import config
def main():
# ===== 手順 (プログラム外の手順も) =====
# 1. consumer_key, consumer_key_secretの取得
# ==== ここからプログラム ====
@73spica
73spica / common_modulus_1_solver.py
Last active November 23, 2017 03:12
CODEBLUE CTF 2017 Common Modulus 1~3
# coding:utf-8
# CODEBLUE CTF 2017 Common Modulus 1
from m1z0r3.crypro import *
def main():
ts_data = open("transcript.txt").read()
ts_data = ts_data.split("\n")
n1, e1 = eval(ts_data[0].split(":")[-1])
c1 = long(ts_data[1].split("=")[-1])
n2, e2 = eval(ts_data[3].split(":")[-1])
@73spica
73spica / paillier_oracle_solver.py
Last active November 16, 2017 02:35
CODEBLUE CTF 2017 Paillier Oracle
# coding: utf-8
from m1z0r3.crypro import sock, read_until, b2l, l2b
import string
from hashlib import sha256
from itertools import product
from fractions import Fraction
from time import sleep
@73spica
73spica / secret-server-revenge_solver.py
Last active November 15, 2017 17:10
HITCON CTF 2017 Secret Server Revenge
# coding:utf-8
from m1z0r3.crypro import sock, read_until, split_n
from itertools import product
import string
from Crypto.Hash import *
from base64 import b64encode, b64decode
remoteip = "52.192.29.52"
remoteport = 9999
#remoteip = "localhost"
@73spica
73spica / dj_solver.py
Created April 26, 2017 11:04
Damgard-Jurik暗号の復号の練習
from sage.all import *
from Crypto.Util.number import long_to_bytes as l2b
import json
params = json.load(open("param.txt","r"))
s = params["s"]
n = params["n"]
c = params["c"]
g = params["g"]
p = 531457043239
from PIL import Image
# H4CK1T CTF 2016 Online
# Mozambique – 1magePr1son ($TEGO 150 pts )
def main():
img = Image.open("./planet.png")
rgb_img = img.convert("RGB")
print img
import subprocess
import time
# H4CK1T CTF 2016 Online
# Paraguay – Hex0gator (PPC 250 pts)
def do_unzip(target_file_path,source_path):
cmd = "unzip %s -d %s"%(target_file_path,source_path)
subprocess.call(cmd.split())
from m1z0r3.crypro import *
from math import sqrt
import time
# H4CK1T CTF 2016 Online
# Mongolia – HellMath (PPC 100 pts)
def do_calc(num):
span = 2
b = 1