Skip to content

Instantly share code, notes, and snippets.

View ducnhse130201's full-sized avatar

PeterJson ducnhse130201

View GitHub Profile
@ducnhse130201
ducnhse130201 / solve.py
Last active May 2, 2018 07:17
VizHash(Hackcon2017)
from PIL import Image
import itertools
from hashlib import *
import string
import collections
compare = lambda x, y: collections.Counter(x) == collections.Counter(y)
def sum_to_n(n):
sum = 0
@ducnhse130201
ducnhse130201 / solve.py
Created May 2, 2018 07:36
VigenereCipher(SecconQuals2016)
from hashlib import *
import random
import itertools
h = 'f528a6ab914c1ecf856a1d93103948fe'
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ{}'
cipher = 'LMIG}RPEDOEEWKJIQIWKJWMNDTSR}TFVUFWYOCBAJBQ'
format_flag = 'SECCON{'
def repeat(a,len_b):
return (a*(int(len_b/len(a))+1))[:len_b]
@ducnhse130201
ducnhse130201 / solve.py
Created May 2, 2018 08:11
Crypto100-RSA(SVATTT-Quals-2017)
from libnum import *
to_int = lambda string : int(string,16)
n = 1552518092300708935148979488462502555256886017116696611139052038026050952686376886330878408828646477971459063658923221258297866648143023058142446317581796810373905913084934869211153276980011573717416472395713363686571638755823503877
BS = 32
p = 39402006196394479212279040100143613805079739270465446667948293404245721771497210611414266254884915641338868201294899
q = 39402006196394479212279040100143613805079739270465446667948293404245721771497210611414266254884915640806628012398823
phi = (p-1)*(q-1)
e = 3
d = modular.invmod(e,phi)
f = open('cipher.txt').read()
@ducnhse130201
ducnhse130201 / solve.py
Created May 2, 2018 08:48
Crypto100-DES(SVATTT-Quals-2017)
import telnetlib
from hashlib import *
from Crypto.Cipher import DES
host = 'localhost'
port = 33334
unpad = lambda s : s[0:-ord(s[-1])]
BS = DES.block_size
@ducnhse130201
ducnhse130201 / solve.py
Created May 2, 2018 09:40
Crypto300(SVATTT-Quals-2017)
from pwn import *
import string
import time
from base64 import *
r = remote('localhost',33333)
def xor(s1,s2):
return ''.join([chr(ord(a) ^ ord(b)) for a,b in zip(s1,s2)])
def repeat(string, len_cipher):
@ducnhse130201
ducnhse130201 / ViettelStore.py
Created June 19, 2018 02:21
ViettelStore.py(MatesCTF Round5)
import time
import string
import random
from hashlib import sha256
from urlparse import parse_qsl
money = random.randint(1000000, 5000000)
signkey = ''.join([random.choice(string.letters+string.digits) for _ in xrange(random.randint(8,32))])
items = [
('Samsung Galaxy S9', 19990000),
@ducnhse130201
ducnhse130201 / solve(ViettelStore).py
Created June 19, 2018 02:58
solve(ViettelStore).py
import subprocess
from telnetlib import *
from random import randint
host,port = '13.251.110.215',10001
# len_secret 8-32
def hash_length_ex(data,len_secret,append,sign,_format):
res_sign = ''
res_string = ''
@ducnhse130201
ducnhse130201 / Web-Token.py
Created June 19, 2018 03:06
Web-Token(Mates Round 5).py
from flask import Flask, render_template, request, make_response, redirect
import random
import string
from base64 import b64decode, b64encode
from Crypto.Cipher import AES
from hashlib import md5
from Crypto.Hash import HMAC
BLOCK_SIZE = 16
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * chr(BLOCK_SIZE - len(s) % BLOCK_SIZE)
@ducnhse130201
ducnhse130201 / solve(Web-Token).py
Created June 19, 2018 04:55
solve(Web-Token).py
import requests
import string
from base64 import *
from Crypto.Hash import HMAC
alpha = string.ascii_letters + string.digits
BLOCK_SIZE = 16
pad = lambda s: s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * chr(BLOCK_SIZE - len(s) % BLOCK_SIZE)
@ducnhse130201
ducnhse130201 / solve(du ddu).py
Created June 19, 2018 13:20
solve(du ddu).py
from telnetlib import *
import string
from base64 import *
alpha = string.ascii_letters + string.digits
host,port = 'ec2-13-251-81-16.ap-southeast-1.compute.amazonaws.com',3333
c = 'OEEBNFHAIECBPEFBLCBHPFFAIBCENLHOLFBANOHLIKCPLIBNOPEKKHACNOHLOHECILCOMDGGJGDDMCGHPGFDLBBEPFFALIBNPFFALEBBMAGFJBDEMAGFIJCMNOHLKEABONEIJMDJKPAKJIDNOOELILCOOIENINCINIHN'
text = ''