Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/python
from itertools import izip, cycle
import string, sys
def ascii_analysis(data):
total_len = len(data)
total_ascii = 0
for char in data:
if char in string.ascii_letters or char in ['\r', '\n'] or char in string.digits or char in string.whitespace:
@errzey
errzey / Know Thy BPF: 01
Created July 28, 2011 13:10
Know Thy BPF
bpf filter: "ip"
(000) ldh [12]
(001) jeq #0x800 jt 2 jf 3
(002) ret #96
(003) ret #0
(000) ldh [12]
Load half word at packet offset 12
Offset 12 is the eth type.
@errzey
errzey / example_usage.c
Last active February 2, 2022 10:22
trx-1 / trx-2 api in one header
/*
Output is something like:
ellzey@bluedream ~/Code/libtrx/src ./example
line1:
line2: ALM EBRCS
line3: TGRP psDr
line4: A2D
line5: ALCO Northwest S
line6: RadioID: 2DF98B
@errzey
errzey / llist_db_move.py
Created September 23, 2011 17:20
An interesting technique for creating a linked list like structure using SQL with minimal overhead.

I wrote this a long time ago as a proof-of-concept for a vaporware project. Recently I have had the need to something which seems easy at a high-level standpoint, but is actually quite hard to implement.

The original purpose for this concept was to easily maintain a strict order of data held within the rows, while still having the option to reorder the rows in an efficient manner (one table, no joins, no special embedded scripts etc).

A little insight into what I was doing: I once worked on a network security team for a tier-1 ISP. A coworker and myself had already written some really nice code to deal with the thousands (yes, thousands) of firewalls we dealt with on a daily basis. We created an API which generated abstracted structures of firewall configurations; by abstracting I mean creating a singular data-structure which represented rules, and rule-sets (a nice side-effect of this method was we could morph one firewall syntax structure to another. E.g., juniper filters -> netscreen rules. Needless to s

@errzey
errzey / ssbug.md
Last active October 24, 2020 07:30

Lets take a look at the vulnerable code:

if (s->servername_done == 0) {
    switch (servname_type) {
        case TLSEXT_NAMETYPE_host_name:
            if (s->session->tlsext_hostname == NULL) {
                if (len > TLSEXT_MAXLEN_host_name ||
                    ((s->session->tlsext_hostname = OPENSSL_malloc(len + 1)) == NULL)) {
 *al = TLS1_AD_UNRECOGNIZED_NAME;
@errzey
errzey / davehull.sh
Created April 20, 2011 20:10
Example script to show how to do an intelligent merge-sort in parallel
#!/bin/bash
# determines number of proccessors, splits a large file into sizes that
# can be consumed by n-1 sort processes (where n is the number of processors)
#
# After the file has been split up properly, it will run a sort on each split
# file in parallel. Once all processes have completed, a merge sort is executed.
#
# mthomas@n2o:~/words [100%] $ du -h big
# 1.7G big
@errzey
errzey / sym.sh
Last active August 30, 2017 18:15
stupid shell script that tries to find a specific symbol in libs.
#!/usr/bin/env bash
# runs through your ld paths and looks for a symbol
# passed as the first argument
#
# example:
#
# $ ./lz.findsymbol.sh xcb_big_requests_id
# /usr/lib/x86_64-linux-gnu/libcairo.a
# /usr/lib/x86_64-linux-gnu/libxcb.a
@errzey
errzey / sidebar-brew.md
Created October 27, 2015 23:07
fixing brew for sidebar patch

The sidebar patch is no longer included in the brew recipe, which sucks.

You can grab the newest patches here: http://www.lunar-linux.org/mutt-sidebar/

Here is how to edit brew to apply the patch without errors:

  • brew edit mutt
  • add option "with-sidebar-patch", "Apply sidebar patch
  • add:
@errzey
errzey / gist:6526383
Created September 11, 2013 16:43
Never miss a deleted message in Skype
In OSX: cd ~/Library/Application\ Support/Skype/<yourusername>
sqlite3 main.db
CREATE TABLE ILOGURDELETEDMESSAGES (AUTHOR TEXT, MESSAGE TEXT);
CREATE TRIGGER LOLILOGB4UREMOVE AFTER UPDATE On Messages
FOR EACH ROW
WHEN (NEW.body_xml ="")
BEGIN
INSERT INTO ILOGURDELETEDMESSAGES (AUTHOR, MESSAGE) VALUES (NEW.author, OLD.body_xml);
@errzey
errzey / simple_elf_crawler.c
Created September 19, 2016 03:39
ELF section / symbol crawler in 20 lines of code using liblz_elf
#include <liblz.h>
#include <liblz/lzapi.h>
#include <liblz/lz_elf.h>
static int __print_symbol(lz_elf_symbol * symbol, void * args) {
printf(" Symbol name: %s\n", lz_elf_symbol_get_name(symbol));
return 0;
}
static int __print_section(lz_elf_section * section, void * arg) {
printf("Section name : %s\nSections count: %zu\n", lz_elf_section_get_name(section), lz_elf_section_get_nsyms(section));