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
| #!/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 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 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 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 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 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
| # 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 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 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 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
| #!/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 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
| :: 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 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 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 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
| #!/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 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 merge_dicts(*dicts): | |
| all_items = [] | |
| for dictionary in dicts: | |
| all_items += dictionary.items() | |
| return dict(all_items) |