Skip to content

Instantly share code, notes, and snippets.

@melpomene
melpomene / wordcollector.py
Created October 11, 2011 11:33
Wordlist generating script that parses websites for words.
#!/usr/bin/env python2.7
''' Creates wordlists from web scraping. BeautifulSoup requierd (pip install beautifulsoup) '''
import sys
import os
import robotparser
from BeautifulSoup import BeautifulSoup as bs
import urllib2
from urlparse import urlparse
@melpomene
melpomene / tc-brute.sh
Created July 30, 2012 13:11
Truecrypt brute force script
#!/bin/sh
# Before use:
# * Put line seperated wordlist in file 'wordlist'
# * Change device /dev/sdX to the drive/file you want to brute force
# Call with 'sudo tc-brute.sh < wordlist'.
while read line
do
if truecrypt -t -k "" --protect-hidden=no --non-interactive /dev/sdX -p $line
@melpomene
melpomene / lagrange.py
Created April 24, 2012 19:27
Lagrange interpolation in python
import numpy as np
import matplotlib.pyplot as plt
import sys
def main():
if len(sys.argv) == 1 or "-h" in sys.argv or "--help" in sys.argv:
print "python lagrange.py <x1.y1> .. <x_k.y_k>"
print "Example:"
print "python lagrange.py 0.1 2.4 4.5 3.2"
@melpomene
melpomene / toy_blockchain.py
Last active November 13, 2021 07:28
Toy blockchain implementation demonstrating Proof of work
# This Python file uses the following encoding: utf-8
from copy import deepcopy
from hashlib import sha256
class Blockchain:
def __init__(self, difficulty = 1):
genesis_block = GenesisBlock()
self.chain_tail = genesis_block
self.geneis_block = genesis_block
@melpomene
melpomene / download.py
Last active April 25, 2021 01:58
Script to download all your images from dailyview.com (gamla bilddagboken.se)
#!/usr/bin/env python
# encoding: utf-8
"""
Python script to download all your dailyview.com images
Run with 'python download.py'
Depends on requests and Beautiful soup
"""
@melpomene
melpomene / brute.py
Created December 12, 2011 23:18
Statistical attack on simple linear substitution ciphers.
import sys, string, re
"""
Brute.py script to statistically break simple replacement ciphers.
Named after Ceasars killer.
Called with
python brute.py -m 'some text to break'
or
python brute.py -f filewithcypher.txt
@melpomene
melpomene / check_vpn.py
Created September 22, 2013 14:31
VPN verification and reconnection script for Ubuntu with network-manager.
import os, requests, time
from datetime import datetime
import socket
URL = "https://showmemyip.example.com" # EDIT THIS. NEEDS TO BE A URL THAT RETURNS YOUR PUBLIC IP.
CORRECT_REVERSE_URL = "ipredator.se" # EDIT THIS TO BE THE REVERSE-URL OF YOUR VPN PROVIDER
VPN_CONNECTION_NAME = "Ipredator" # EDIT THIS TO THE NAME OF THE VPN CONNECTION IN NETWORK-MANAGER.
"""
Run this script in cron to verify that you are connected to your desired VPN service
which is automatically reconnected if the connection is lost
@melpomene
melpomene / compare_duck_type_speed.py
Created January 28, 2014 11:04
Compare isinstance, type and ducktyping to see which one is quickest.
import time
""""
Compare isinstance, type and ducktyping to see which one is quickest.
Typical output
=============
IsInstance 0.00567038607597
ducktyping 0.0232819545269
type 0.004327688694
all_questions = None
for database in databases:
if all_questions is None:
all_questions = load_questions(database=database,verified=True)
build_something(questions)
@melpomene
melpomene / lasttuesdaysocietypodcast.py
Created July 13, 2013 14:05
Python script to download all the Last Tuesday Society podcasts in one swoop
#!/usr/bin/env python
# encoding: utf-8
"""
Python script to download all the Last Tuesday Society podcasts in one swoop
Find them here: http://www.thelasttuesdaysociety.org/podcasts.html
Run with 'python lasttuesdaysocietypodcast.py'
Depends on requests and Beautiful soup
"""