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
| echo 0 | sudo tee /proc/sys/kernel/randomize_va_space |
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 divide_blocks(string, block_length): | |
| return [string[i:i+block_length] for i in xrange(0, len(string), block_length)] | |
| def get_block(msg, length, index=0): | |
| return msg[length * index : length * (index + 1)] |
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 root(n, r): | |
| u, s = n, n+1 | |
| while u < s: | |
| s = u | |
| t = (r - 1) * s + n / pow(s, r-1) | |
| u = t / r | |
| return 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
| 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): | |
| g, x, y = egcd(a, m) | |
| if g != 1: |
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_hamming(st1, st2): | |
| return sum([i != j for i, j in zip(bitstring(st1), bitstring(st2))]) | |
| # BitString can be found in another gist |
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 break_single_key import break_single_key | |
| def get_block(msg, length, index=0): | |
| return msg[length * index : length * (index + 1)] | |
| def break_repeating_by_keysize(msg, keysize): | |
| blocks = [get_block(msg, keysize, i) for i in xrange(len(msg) / keysize)] | |
| transposed_blocks = zip(*blocks) | |
| full_key = '' | |
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
| { | |
| 'a': 0.0651738, | |
| 'b': 0.0124248, | |
| 'c': 0.0217339, | |
| 'd': 0.0349835, | |
| 'e': 0.1041442, | |
| 'f': 0.0197881, | |
| 'g': 0.0158610, | |
| 'h': 0.0492888, | |
| 'i': 0.0558094, |
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 bitstring(st): | |
| bs = '' | |
| for i in st: | |
| bits = bin(ord(i))[2:] | |
| bs += ('0' * (8 - len(bits))) + bits | |
| return bs |
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 repeating_key_xor(st,key): | |
| return xor_strings(st, itertools.cycle(key)) |
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 os | |
| def get_or_create(folder): | |
| if not os.path.exists(folder): | |
| os.mkdir(folder) | |
| os.popen('explorer.exe {}'.format(folder)) |