Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View ei-grad's full-sized avatar

Andrew Grigorev ei-grad

View GitHub Profile
@ei-grad
ei-grad / charon.py
Created November 27, 2011 02:05
Small and ugly but working HTTP proxy based on Tornado.
#!/usr/bin/env python
# coding: utf-8
import logging
from functools import partial
import http.client
from tornado.httputil import HTTPHeaders
HTTPHeaders._normalize_name = lambda x: x
@ei-grad
ei-grad / example.py
Created November 30, 2011 01:46
threaded decorator for tornado
from time import sleep
from tornado import gen
import tornado.ioloop
import tornado.web
from tornado_threaded import threaded, inline_threaded
@threaded
def slow_func(callback):
@ei-grad
ei-grad / dntree.py
Created February 2, 2012 20:30
DNTree class. Represents a set of distinguished names as tree. Can be used to build a hierarchy of Internet Domain names or LDAP DN.
#!/usr/bin/env python
# coding: utf-8
#
# Copyright (c) 2009 Andrew Grigorev <andrew@ei-grad.ru>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
import imp
import os
import stat
import string
import sys
from default_settings import *
def get_arg(key):
return sys.argv[sys.argv.index(key) + 1]
@ei-grad
ei-grad / rc4brute.py
Created May 21, 2012 05:24
RC4 bruteforce using entropy and file type signatures
#!/usr/bin/env python
# coding: utf-8
import sys
from Crypto.Cipher import ARC4
import numpy
import magic
import string
fname = sys.argv[1] if len(sys.argv) > 1 else 'videostream'
@ei-grad
ei-grad / get_bound_objects.py
Created July 5, 2012 18:44
get_bound_objects
#!/usr/bin/env python
# coding: utf-8
def get_bound_objects(queryset, classes):
"""
Helper function to map a list of objects to corresponding classes in Django ORM.
It is a simple and stupid alternative to django_polymorphic.
Good to use with custom Paginator class. Example usage:
@ei-grad
ei-grad / .Xdefaults
Created August 14, 2012 01:47
My urxvt config.
!! Appearance
urxvt.termName: rxvt-unicode
urxvt.scrollBar: false
urxvt.background: black
urxvt.foreground: gray
!! Font prefferenes
urxvt.font: xft:DejaVu Sans Mono:pixelsize=13
urxvt.boldFont: xft:DejaVu Sans Mono:pixelsize=13:weight=bold
urxvt.letterSpace: -1
!! Larger history limit
@ei-grad
ei-grad / rw500.py
Created December 17, 2012 09:39
PHDays Quals 2012 - Real World 500
#!/usr/bin/env python2
#
# see: https://github.com/fx5/not_random and related article
import sys
import os
import gzip
import random
from itertools import imap
import hashlib
@ei-grad
ei-grad / misc400.py
Created December 17, 2012 10:22
PHDays Quals 2012 - Misc 400
#!/usr/bin/env python2
# coding: utf-8
from collections import deque
import socket
import logging
import re
logging.basicConfig(level=logging.DEBUG)
@ei-grad
ei-grad / ghe-lxc-image
Created March 11, 2013 17:18
Script to convert Github Enterprise OVA image to tar.gz for LXC.
#!/bin/bash
[ "`whoami`" != "root" ] && echo "Should be run by root!" && exit 1
[ -e *.vmdk ] || ( echo Extracting VMDK image from *.ova ... ; tar xf *.ova )
[ -e github.img ] || ( echo Converting *.vmdk to raw image ... ; qemu-img convert *.vmdk github.img )
echo Preparing mounts ...
losetup -f github.img -P
vgchange -ay enterprise-11