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 traceback | |
import logging | |
def get_exception_info(skip=2): | |
"""Note, this relies on being called from the exception handler. This is very brittle to the depth of the call.""" | |
frames_output = [] | |
for frame in traceback.extract_stack()[:-skip]: | |
fname, lineno, parent, function = frame | |
frame_output = """ File "%s", line %d, in %s\n %s""" % (fname, lineno, parent, function) | |
frames_output.append(frame_output) |
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 python | |
""" | |
Given the result of a multiplication and one of the factors, calculate the | |
other factor | |
Arguments: | |
known_factor = the factor we're given | |
result = the result of the multiplication modulo some number | |
size_of_modulo_result = The number of bits in the result |
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 merge_dicts(*dicts): | |
all_items = [] | |
for dictionary in dicts: | |
all_items += dictionary.items() | |
return dict(all_items) |
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 python | |
""" | |
Includes a function for retrieving a public IP in a simple, programmatic fashion. | |
NOTE: Does not use HTTPS! | |
""" | |
import urllib2 | |
def get_public_ip(): | |
"""Retrieve the external IP address. |
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
#include <iostream> | |
using namespace std; | |
int preincrement(int & x){ | |
// Add one to x, and return the new value for x. | |
x = x+1; | |
return x; | |
} | |
int postincrement(int & x){ |
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 exp(x,n): | |
"""Returns x^n, for integers x,n and n>=0 | |
This is done more intelligently, as we can use the definition | |
that x^(a/2)^2 == x^a to make many less multiplications""" | |
# count is the amount of multiplications. | |
count = 0 | |
result = 1 | |
x_raised = x | |
# On each iteration, multiply our result by x^a if x^a is needed to compute x^n. |
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 python | |
# Uploads every file in the directory to the specified FTP server | |
import os | |
import os.path | |
from ftplib import FTP | |
HOST = "127.0.0.1" | |
PORT = 21 |
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
""" | |
Steps: | |
1) Save the game before anything happens | |
2) Solve the game to get the list of mines, as y,x coordinates | |
3) Reconstruct the savegame | |
4) XOR the decoded savegame and the reconstructed save game to get the key | |
5) Build an exploit to steal the entire key. | |
6) Build an exploit to grab the flag | |
""" |
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 cv2 | |
from cv2 import cv | |
method = cv.CV_TM_SQDIFF_NORMED | |
template_name = "mozicon128.png" | |
image_name = "test2.jpeg" | |
# Load | |
needle = cv2.imread(template_name) |
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 hashlib | |
salt = "This is a super secret salt. Nobody should ever be able to guess this.6rAtas7swe9ach6rAtas7swe9achXrAtas7swe9ach6rAtas7swe9ach6rAtas7swe9ach6rAtas7swe9ach" | |
def get_code(number, length): | |
"""Returns the first length bytes of the generated 'code'""" | |
return hashlib.sha512(str(number) + str(salt)).hexdigest()[:length] | |
for i in range(10): | |
print get_code(i, 7) |
OlderNewer