Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
from twisted.conch import error, manhole, manhole_ssh, ssh
from twisted.conch.ssh import keys, factory, common
from twisted.cred import checkers, portal, credentials
from twisted.python import failure, log
from zope.interface import implements
from twisted.cred.error import UnauthorizedLogin, UnhandledCredentials
import os.path
@e000
e000 / wa.py
Created January 31, 2011 00:23
from Core.ZalgoBase.BaseModule import BaseModule
from twisted.web.client import getPage
from twisted.internet.defer import inlineCallbacks
from Core.ZalgoUtil.CmdWraps import command, timeout, needsArg, stripColors
from Core.ZalgoUtil.ModUtil import utf8
from urllib import urlencode
from xml.etree.cElementTree import fromstring
from Core import version
from Core.ZalgoUtil.DeferredCache import deferred_lfu_cache
from urllib import urlencode, urlopen
from xml.etree.cElementTree import fromstring
appId = 'appid'
def search(query, format=('plaintext', )):
return parseWolframAlphaResponse(urllib.urlopen('http://api.wolframalpha.com/v2/query?%s' % (
urlencode(
{
'appid': appId,
@e000
e000 / basehttp-ab.txt
Created January 31, 2011 22:35
basehttpserver vs gevent
e@e-desktop:~/proxybot/bench$ ab -c 50 -n 5000 http://localhost:8000/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
proxies = []
from collections import deque
class rotate(deque):
def get(self):
item = self.pop()
self.appendleft(item)
return item
def parseWolframAlphaResponse(self, response, redirected = False, results = None):
results = results if results is not None else []
xmlTree = fromstring(response)
recalculate = xmlTree.get('recalculate')
success = xmlTree.get('success')
if success == 'true':
for pod in xmlTree.findall('pod'):
title = pod.get('title')
plaintext = pod.find('subpod/plaintext')
if plaintext is not None and plaintext.text:
@e000
e000 / bot.py
Created February 12, 2011 21:58
import sys
import socket
import string
import os
VERBOSE = True
class AstonixIRCBot(object):
socket = None
connected = False
"""
Omegle twisted client
"""
DISCONNECTED = 0
CONNECTING = 1
WAITING = 2
CONNECTED = 3
from random import choice
@e000
e000 / lib-omegle.py
Created February 16, 2011 23:03
an omegle wrapper for a connection using twisted, not really following their protocol spec, maybe I should o.O
"""
Omegle Twisted Client version 1.0
"""
__author__ = "e"
__version___ = "1.0"
DISCONNECTED = 0
CONNECTING = 1
WAITING = 2
2011-02-18 01:17:00+0000 [-] .5 secs passed
2011-02-18 01:17:00+0000 [Core.ZalgoUtil.SSHManhole.ZalgoSSHFactory] disabling diffie-hellman-group-exchange because we cannot find moduli file
2011-02-18 01:17:00+0000 [-] .5 secs passed
2011-02-18 01:17:01+0000 [SSHServerTransport,0,127.0.0.1] kex alg, key alg: diffie-hellman-group1-sha1 ssh-rsa
2011-02-18 01:17:01+0000 [SSHServerTransport,0,127.0.0.1] outgoing: aes128-ctr hmac-md5 none
2011-02-18 01:17:01+0000 [SSHServerTransport,0,127.0.0.1] incoming: aes128-ctr hmac-md5 none
2011-02-18 01:17:03+0000 [-] .5 secs passed
2011-02-18 01:17:03+0000 [SSHServerTransport,0,127.0.0.1] NEW KEYS
2011-02-18 01:17:03+0000 [-] .5 secs passed