Skip to content

Instantly share code, notes, and snippets.

@fmoo
fmoo / gist:2018384
Created March 11, 2012 22:09
Tunneling arbitrary TCP connections over HTTP CONNECT requests with Twisted
from twisted.web import http
from twisted.internet import protocol, reactor
from twisted.internet.error import CannotListenError, ConnectError
from twisted.internet.interfaces import IReactorTCP
from zope.interface import implements
from twisted.python import log
class ProxyConnectError(ConnectError):
@fmoo
fmoo / server.py
Created March 18, 2012 04:04
CONNECT-enabled HTTP Proxy Server
from twisted.web.proxy import Proxy, ProxyRequest
from twisted.internet.protocol import Protocol, ClientFactory
import urlparse
from twisted.python import log
class ConnectProxyRequest(ProxyRequest):
"""HTTP ProxyRequest handler (factory) that supports CONNECT"""
connectedProtocol = None
@fmoo
fmoo / gist:4057731
Created November 12, 2012 05:54
Getting a Facebook Access Token in python via QWebView + Facebook Javascript SDK
from PySide.QtCore import Slot
from PySide.QtGui import QApplication, QMainWindow, QDialog, QVBoxLayout
from PySide.QtWebKit import QWebView, QWebPage, QWebSettings
import sys
from functools import partial
from argparse import ArgumentParser
ap = ArgumentParser()
ap.add_argument('app_id', type=int)
@fmoo
fmoo / keyring-get.py
Created November 14, 2012 15:51
Clowny CLI script to get stuff out of the keyring
#!/usr/bin/env python
from __future__ import absolute_import
from argparse import ArgumentParser
from getpass import getuser, getpass
ap = ArgumentParser()
ap.add_argument('key')
ap.add_argument('user', default=getuser(), nargs='?',
help='username [%(default)s]')
ap.add_argument('--clear', action='store_true')
@fmoo
fmoo / ftplib_simple_proxy.py
Created December 29, 2012 23:27 — forked from anonymous/ftplib_simple_proxy
An FTP client implementation that supports sending and receiving data via SOCKS proxy using PASV transfers
import ftplib
import socket
import socks # socksipy (https://github.com/mikedougherty/SocksiPy)
class FTP(ftplib.FTP):
def __init__(self, host='', user='', passwd='', acct='',
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
proxyconfig=None):
"""Like ftplib.FTP constructor, but with an added `proxyconfig` kwarg
@fmoo
fmoo / whoiswatch.py
Last active December 20, 2015 21:39
sparts service that uses twilio to send an SMS whenever a domain's WHOIS State changes
from sparts.vservice import VService
from sparts.vtask import TryLater
from sparts.tasks.poller import PollerTask
from sparts.sparts import option
import whois
import re
import twilio.rest
def parse_whois(data):
result = {}
@fmoo
fmoo / rsrc.py
Created September 7, 2013 04:12
my rsrc.py "py-haste" clownery. Features include: (1) Static css / js analyzer (syntax parsing provided by pygments) (2) Tracks @requires and @provides dependencies. (3) Makes it easier to implement javelin behaviors. (4) Makes it *super* easy to use react components.
import os
import os.path
import re
from collections import defaultdict
from pygments.lexers.web import CssLexer, JavascriptLexer
from .json import dumps
import random