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
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
@e000
e000 / rc4.py
Created March 3, 2011 01:53
nice rc4
class RC4:
def __init__(self, key):
self._key, x, box, kl = key, 0, range(256), len(key)
for i in xrange(256):
x = (x + box[i] + ord(key[i % kl])) & 0xff
box[i], box[x] = box[x], box[i]
self._box = box
def crypt(self, data):
from twisted.conch.ssh import transport, userauth, connection, common, keys, channel, forwarding
from twisted.internet import defer, protocol, reactor, interfaces, base, address, error
import socket
import types
from twisted.python import failure
from twisted.internet.protocol import connectionDone
__all__ = ['SSHTransport', 'SSHTransportFactory', 'SSHConnection', 'SSHForwardConnector', 'SSHForwardTransport']
class SSHTransport(transport.SSHClientTransport):