Skip to content

Instantly share code, notes, and snippets.

@HelloZeroNet
HelloZeroNet / UpnpPunch.py
Last active August 29, 2015 14:16
UpnpPunch bind patch
import gevent
from gevent import socket
from gevent import monkey
monkey.patch_socket()
import re, urllib2, httplib, logging
from urlparse import urlparse
from xml.dom.minidom import parseString
@HelloZeroNet
HelloZeroNet / gist:b25b144506a3f8afbbda
Created March 19, 2015 15:02
Simple plugin benchmark
import time
# No plugin (without getattr 0.056s, with getattr 0.110s)
class Request(object):
def __init__(self):
pass
def route(self, req):
@HelloZeroNet
HelloZeroNet / bitcoinbar.html
Created March 19, 2015 16:34
Bitcoin donate bar
<html>
<body>
<style>
.bitcoinbar {
width: 150px; margin-top: 5px; display: inline-block; height: 20px; border-radius: 5px; position: relative;
font-family: Consolas, Monospace; background-color: #eee; color: black; vertical-align: bottom; text-decoration: none
}
.bitcoinbar .progress {
text-align: center; display: block; position: relative;
font-size: 11px; vertical-align: middle; line-height: 22px;
plugined_cache = {}
plugins = {}
def plugined(base_class):
class_name = base_class.__name__
if class_name in plugined_cache:
PluginedClass = plugined_cache[class_name]
else:
classes = plugins[class_name]+[base_class]
classes.reverse()
PluginedClass = type(class_name, tuple(classes), dict())
#
# key.py - OpenSSL wrapper
# Source: git://github.com/joric/brutus.git
# which was forked from git://github.com/samrushing/caesure.git
#
import ctypes
import ctypes.util
ssl = ctypes.cdll.LoadLibrary (ctypes.util.find_library ('ssl') or 'libeay32')
@HelloZeroNet
HelloZeroNet / openssl_verify.py
Last active August 29, 2015 14:20
Bitcoin sign recover address
from pybitcointools import bitcoin as btctools
import time, hashlib
priv = "5JsunC55XGVqFQj5kPGK4MWgTL26jKbnPhjnmchSNPo75XXCwtk"
address = "1N2XWu5soeppX2qUjvrf81rpdbShKJrjTr"
sign = btctools.ecdsa_sign("hello", priv)
import base64
def VerifyMessage(address, hash, sig):
sig = base64.b64decode(sig)
@HelloZeroNet
HelloZeroNet / opensslVerify2.py
Last active June 19, 2017 23:36
Alternative openssl verify
#!/usr/bin/env python
##
## @file contrib/verifymessage/python/terracoin_verifymessage.py
## @brief terracoin signed message verification sample script.
## @author unknown author ; found on pastebin
##
import ctypes
import ctypes.util
import hashlib
# via http://pastebin.com/H1XikJFd
# -*- Mode: Python -*-
# This is a combination of http://pastebin.com/bQtdDzHx and
# https://github.com/Bitmessage/PyBitmessage/blob/master/src/pyelliptic/openssl.py
# that doesn't crash on OSX.
import ctypes
import ctypes.util
import hashlib
@HelloZeroNet
HelloZeroNet / gdb-backtrace.log
Created May 22, 2015 10:08
python-bitcoinlib random SIGSEGV
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff62452eb in BN_bin2bn () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#0 0x00007ffff62452eb in BN_bin2bn () from /usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0
#1 0x00007ffff484e834 in ffi_call_unix64 () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#2 0x00007ffff484e2af in ffi_call () from /usr/lib/python2.7/lib-dynload/_ctypes.so
#3 0x00007ffff483bfd1 in _call_function_pointer (argcount=3, resmem=0x7fffffffa8e0, restype=<optimized out>, atypes=<optimized out>, avalues=0x7fffffffa8b0,
pProc=0x7ffff62452a0 <BN_bin2bn>, flags=4353) at /home/jmm/py/python2.7-2.7.3/Modules/_ctypes/callproc.c:827
#4 _ctypes_callproc (pProc=pProc@entry=0x7ffff62452a0 <BN_bin2bn>, argtuple=argtuple@entry=
("TC\xdb\xc6_(8\x0ct\xdf\xc3i\xb5\xb9e\x03\x9f\x1c'\x07\xc2kg\xb5\x89\x99\xc8\xee\x10\xdc\x15\x1e", 32, -334573824), flags=4353, argtypes=< at remote 0x8d30a0>,
import msgpack
import cStringIO as StringIO
print "Msgpack Version", msgpack.version
print "Testing simple data"
data = "A"*10
for i in range(1,20):
print "- %skb..." % len(data),
print "Packing",