Skip to content

Instantly share code, notes, and snippets.

View thepacketgeek's full-sized avatar

Mat Wood thepacketgeek

View GitHub Profile
#!/usr/bin/env python
"""
Very simple HTTP server in python.
Usage::
./dummy-web-server.py [<port>]
Send a GET request::
curl http://localhost
from extensions import db
from celery import Celery
from flask import Flask
from config import config, SELECTED_CONFIG
def create_celery_app(app=None):
app = app or create_app()
celery = Celery(__name__, broker=app.config['CELERY_BROKER_URL'])
celery.conf.update(app.config)
TaskBase = celery.Task
#!/bin/bash
# This script will migrate schema and data from a SQLite3 database to PostgreSQL.
# Schema translation based on http://stackoverflow.com/a/4581921/1303625.
# Some column types are not handled (e.g blobs).
#
# See also:
# - http://stackoverflow.com/questions/4581727/convert-sqlite-sql-dump-file-to-postgresql
# - https://gist.github.com/bittner/7368128
#!/usr/bin/env bash
# change to proper directory
cd /Applications/Google\ Drive.app/Contents/Resources/
# back up the files
sudo mkdir icon-backups
sudo cp mac-animate*.png icon-backups/
sudo cp mac-error*.png icon-backups/
sudo cp mac-inactive*.png icon-backups/
# ---------------------------------------------------------------------------
#
# Description: This file holds all my BASH configurations and aliases
#
# Sections:
# 1. Environment Configuration
# 2. Make Terminal Better (remapping defaults and adding functionality)
# 3. File and Folder Management
# 4. Searching
# 5. Process Management
@thepacketgeek
thepacketgeek / valid_ip.py
Created December 4, 2013 22:01
Check for a valid IP address
def valid_ip(address):
try:
host_bytes = address.split('.')
valid = [int(b) for b in host_bytes]
valid = [b for b in valid if b >= 0 and b<=255]
return len(host_bytes) == 4 and len(valid) == 4
except:
return False
#! /usr/bin/env python3
import random
from ipaddress import IPv4Network
from typing import List
from scapy.all import ICMP, IP, sr1, TCP
# Define IP range to scan
network = "192.168.40.0/30"
from scapy.all import *
import netaddr
import random
# Define IP range to scan
network = "172.16.20.0/29"
# Define TCP port range
portRange = [22,23,80,443,449]
# make list of addresses out of network, set live host counter
@thepacketgeek
thepacketgeek / rand-packet-fields.py
Created October 23, 2013 00:01
Random packet field generators
## Returns a string of a random int between 1 and 254(default)
def randOct(end = 254):
return str(random.randint(1, end))
## Used for random size or TTL
def randTS(max = 256):
return str(random.randint(1, max/8) * 8)
## Returns a string of a hex number 4 digits long, with the preceding '0x' sliced off
def randHex(max = 65535):
@thepacketgeek
thepacketgeek / 10-ping-sweep.py
Created October 22, 2013 23:14
Ping sweep using Python's netaddr
from scapy.all import *
import netaddr
# Define IP range to ping
network = "172.16.20.0/24"
# make list of addresses out of network, set live host counter
addresses = netaddr.IPNetwork(network)
liveCounter = 0