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
:: plink from here: http://the.earth.li/~sgtatham/putty/latest/x86/plink.exe | |
:: Guide available here: http://blog.buttewifi.com/2010/01/dynamic-ssh-tunneling-with-putty-to-secure-web-traffic/ | |
:: Connects to 192.168.1.2 on port 5900. Sets up a SOCKS proxy that listens on 127.0.0.1 port 9876 and forwards all connections through the connection to 192.168.1.2. | |
:: You then need to configure your system to use 127.0.0.1:9876 as a SOCKS proxy. | |
putty\PLINK.EXE 192.168.1.2 -P 5900 -D 127.0.0.1:9876 -N | |
:: Gotcha: In Windows, you need to specifically enable it as a SOCKS proxy, and disable all other proxies. |
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 | |
import sys | |
from scapy.all import * | |
MAC = "00:0c:29:bf:b0:5a" # MAC Addr of Sockstress Attacker | |
def findARP(p): | |
op = p.sprintf("%ARP.op%") | |
if op == "who-has": # Only respond to ARP Requests | |
psrc = p.sprintf("%ARP.psrc%") |
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 pyimgur | |
CLIENT_ID = "" | |
im = pyimgur.Imgur(CLIENT_ID) | |
blacklist = ['nsfw'] | |
def is_fishy_imgur(id): | |
# Takes an Imgur ID and returns True if it is fishy | |
image = im.get_image(id) |
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
# CIDR to ipv4 | |
# Written by Moshe Kaplan | |
def to_long(ip): | |
ip = ip.split('.', 4) | |
return int(ip[0])*(2**24) + int(ip[1])*(2**16) + int(ip[2])*(2**8) + int(ip[3]) | |
def to_dotted_decimal(long_form): | |
octets = [] | |
for i in range(4): | |
octets += [str(long_form % 2**8)] |
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 sys | |
from PIL import Image | |
from PIL.ExifTags import TAGS, GPSTAGS | |
def get_exif_data(image): | |
"""Returns a dictionary from the exif data of an PIL Image item. Also converts the GPS Tags""" | |
exif_data = {} | |
info = image._getexif() | |
if info: |
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) |
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 | |
''' | |
Uses SURF to match two images. | |
Based on the sample code from opencv: | |
samples/python2/find_obj.py | |
USAGE | |
find_obj.py <image1> <image2> |
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
""" | |
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 | |
""" |