Skip to content

Instantly share code, notes, and snippets.

View david415's full-sized avatar
💭
♥️Ⓐλ😼

David Stainton david415

💭
♥️Ⓐλ😼
View GitHub Profile
@david415
david415 / scapy tcp header fu
Created September 30, 2013 04:58
hiding messages in tcp header using scapy; retrieving messages from iptables LOG...
#!/usr/bin/env python
import binascii
from scapy.all import TCP, IP
ip = IP(dst="192.155.82.5")
tcp = TCP(dport = 6200,
flags = 'S',
seq = 32456,
ack = 32456,
window = 32456,
@david415
david415 / nflog twisted
Last active December 24, 2015 08:29
an attempt to create a async twisted interface to the iptables NFLOG blocking packet reads; this example happens to use an echo server because it's simple. Use this with an iptables rule to populate the NFLOG e.g. iptables -A INPUT -p tcp --dport 2600 -j NFLOG
#!/usr/bin/env python
import os
from nflog_cffi import NFLOG
from twisted.internet.protocol import Protocol, Factory
from twisted.internet import reactor
def NFLOG_get_packets(callback):
@david415
david415 / nflog_reader.py
Created October 2, 2013 05:50
Twisted Reader for Linux Netfilter Log
#!/usr/bin/env python
from nflog_cffi import NFLOG, NFWouldBlock
from twisted.internet import main
from twisted.internet import reactor
class NFLogReader(object):
def __init__(self, dropPrivCallback = None, handlePacket = None, queues = (0,1), nflog_kwargs=dict()):
@david415
david415 / nflog_proto.py
Last active December 24, 2015 11:19
twisted nflog protocol?
"""
Implementation of the Hush protocol.
"""
from nflog_cffi import NFLOG, NFWouldBlock
from twisted.internet import reactor, protocol, defer
from twisted.python import log
@david415
david415 / python
Created November 18, 2013 20:00
arp cache poison
#!/usr/bin/python
import scapy
import scapy.all
from scapy.all import ARP, send
def poison_arpcache(target_ip, spoofed_ip, spoofed_mac):
@david415
david415 / python
Created November 18, 2013 20:06
some old python i wrote as a thought experiment after a coding interview... called it shard.py
#!/usr/bin/python
def get_shard_map(shardfile):
shards = {}
shards_fh = open(shardfile)
for line in shards_fh:
shard, host1, host2 = line.split()
if shards.has_key(shard):
@david415
david415 / gist:7534597
Created November 18, 2013 20:18
python nacl secret box
#!/usr/bin/env python
import nacl.secret
import nacl.utils
key = nacl.utils.random(nacl.secret.SecretBox.KEY_SIZE)
box = nacl.secret.SecretBox(key)
message = b"secret message"
nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE)
@david415
david415 / new_laptop_setup.sh
Last active December 28, 2015 17:39
ubuntu 12.04 laptop setup notes
#!/bin/bash
apt-get update
apt-get install xorg openbox wicd sysstat wireshark macchanger openvpn xlockmore emacs23 chromium-browser nmap netcat -y
# after install grsec kernel
paxctl -m -x -e /usr/lib/chromium-browser/chrome-sandbox -c
paxctl -P -m -x -e -R /usr/lib/chromium-browser/chromium-browser -c
# edit /etc/default/grub
@david415
david415 / gist:8274448
Created January 5, 2014 21:54
bananaphone-bridge-torrc
Log notice stdout
SocksPort 0
ORPort 7001
ExitPolicy reject *:*
DataDirectory ./bridge-data
BridgeRelay 1
PublishServerDescriptor 0
@david415
david415 / gist:8274463
Created January 5, 2014 21:55
bananaphone-client-torrc
Log notice stdout
SocksPort 8040
#ORPort 8001
DataDirectory ./client-data
UseBridges 1
Bridge bananaphone 127.0.0.1:4703 modelName=markov corpus=/usr/share/dict/words encodingSpec=words,sha1,4 order=1