This file contains hidden or 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
| # Hack.lu CTF 2016 Creative Cheating (Crypto 150pt) | |
| def egcd(a, b): | |
| if (a == 0): | |
| return [b, 0, 1] | |
| else: | |
| g, y, x = egcd(b % a, a) | |
| return [g, x - (b // a) * y, y] | |
| def modInv(a, m): |
This file contains hidden or 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
| # -*- coding: utf-8 -*- | |
| import numpy as np | |
| import matplotlib.pyplot as plt | |
| import pandas as pd | |
| from pandas import Series, DataFrame | |
| from numpy.random import normal | |
| #------------# |
This file contains hidden or 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
| // Refered hash_extender: https://github.com/iagox86/hash_extender | |
| #include <stdio.h> | |
| #include <string.h> | |
| #include <openssl/md5.h> | |
| unsigned int extend(unsigned int A, unsigned int B, unsigned int C, unsigned int D, char *testhash2) { | |
| MD5_CTX ctx; | |
| unsigned char buffer[MD5_DIGEST_LENGTH]; | |
| int i; |
This file contains hidden or 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 calc_hash(key): | |
| h = 0x539 | |
| target = 0xEF2E3558 | |
| for k in key: | |
| h += (h<<5) + ord(k) | |
| h &= 0xFFFFFFFF | |
| return abs(target - h) | |
| charset = [chr(i) for i in range(0x21,0x7e)] |
This file contains hidden or 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 socket | |
| import hashlib | |
| import telnetlib | |
| import fractions | |
| # nc cry1.chal.ctf.westerns.tokyo 37992 | |
| remoteip = "cry1.chal.ctf.westerns.tokyo" | |
| remoteport = 37992 | |
| def shell(s): |
This file contains hidden or 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 collections | |
| import itertools | |
| from base64 import b64encode, b64decode | |
| def shift(char, key, rev = False): | |
| if not char in chars: | |
| return char | |
| if rev: | |
| return chars[(chars.index(char) - chars.index(key)) % len(chars)] | |
| else: |
This file contains hidden or 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 socket | |
| remoteip = "misc.chal.csaw.io" | |
| remoteport = 8000 | |
| def sock(remoteip, remoteport): | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.connect((remoteip, remoteport)) | |
| return s, s.makefile('rw', bufsize=0) |
This file contains hidden or 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 socket | |
| import rstr | |
| remoteip = "misc.chal.csaw.io" | |
| remoteport = 8001 | |
| def sock(remoteip, remoteport): | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.connect((remoteip, remoteport)) | |
| return s, s.makefile('rw', bufsize=0) |
This file contains hidden or 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 Crypto.Util.number import * | |
| import Crypto.PublicKey.RSA as RSA | |
| import os | |
| n1 = 19402643768027967294480695361037227649637514561280461352708420192197328993512710852087871986349184383442031544945263966477446685587168025154775060178782897097993949800845903218890975275725416699258462920097986424936088541112790958875211336188249107280753661467619511079649070248659536282267267928669265252935184448638997877593781930103866416949585686541509642494048554242004100863315220430074997145531929128200885758274037875349539018669336263469803277281048657198114844413236754680549874472753528866434686048799833381542018876362229842605213500869709361657000044182573308825550237999139442040422107931857506897810951 | |
| n2 = 1940264376802796729448069536103722764963751456128046135270842019219732899351271085208787198634918438344203154494526396647744668558716802515477506017878289709799394980084590321889097527572541669925846292009798642493608854111279095887521133618824910728075366146761951107964907024865953628226726792866926525293575741886 |
This file contains hidden or 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 itertools | |
| cipher = '805eed80cbbccb94c36413275780ec94a857dfec8da8ca94a8c313a8ccf9' | |
| for i, j in itertools.product(range(251), repeat=2): | |
| if (ord("T")*i+j)%251==0x80 and (ord("W")*i+j)%251==0x5e: | |
| a, b = i, j | |
| break | |
| print a, b |