Skip to content

Instantly share code, notes, and snippets.

@hellais
hellais / benchmark-parsers.py
Created January 18, 2016 18:55
Benchmarking of YAML vs JSON parsing
#!/usr/bin/env python
#
# Running of the script against the following files (OONI reports):
# 87M 2015-12-22.json
# 97M 2015-12-22.yaml
#
# vanilla json: 1.37932395935
# ultra json: 0.421966075897
# simple json: 1.23581790924
# yaml: 193.864903927
@hellais
hellais / ooni-api-queries.sql
Created December 14, 2015 21:35
interesting queries for ooni-api
# Interesting DNS Consistency tests
SELECT input, report_id FROM reports WHERE test_name='dns_consistency' AND (test_keys->>'tampering_detected')::bool=true;
# Interesting HTTP requests tests
SELECT input, report_id FROM reports WHERE test_name='http_requests' AND (test_keys->>'body_length_match')::bool=false;
# Interesting tests that indicate a generic failure
@hellais
hellais / binario.py
Last active August 29, 2015 14:21
A minimalist parallel processing python framework
import time
import traceback
from datetime import datetime
from multiprocessing import Process, Semaphore, JoinableQueue
class BaseNode(object):
def __init__(self, concurrency=1):
self.concurrency = concurrency
@hellais
hellais / ip-to-asn.py
Last active May 27, 2016 12:27
IP to ASN
#!/usr/bin/env python
# To get GeoIPASNum.dat:
# wget https://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz && gunzip GeoIPASNum.dat.gz
import sys
import pygeoip
if len(sys.argv) < 2:
print "Usage: path/to/GeoIPASNum.dat [IPs ... ...]"
ips = sys.argv[2:]
gi = pygeoip.GeoIP(sys.argv[1])
for ip in ips:
@hellais
hellais / gist:1d6a7ce672f0130b8f63
Created March 16, 2015 15:24
blind signatures
import os
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.backends.openssl.backend import Backend
from config import priv_key_path
def generate_private_key(private_key_path):
private_key = rsa.generate_private_key(
@hellais
hellais / votes.csv
Last active August 29, 2015 14:15
votes for OONI roadmap
Goal asn sbs cda irl average phw feamster phillipa mer
Implement data analytics and visualization for OONI tests 5 4 5 5 4.75 "+1" "+1" "+1"
Reach production quality ooni rasperry-pi (beagle-board) images 4 4 4 5 4.25 "+1"
Develop OONI tests for censorship circumvention tools 4 4 3 5 4 "+1" "+1"
Develop scheme for orchestrating ooni-probes 3 3 5 5 4 "+1"
Promote and further develop OONI on mobile (Android, iOS) 3 4 4 5 4
Get daily OONI measurements from 50 countries 4 4 2 5 3.75
Publish monthly reports about the status of internet censorship in a country 4 5 2 4 3.75
Implement a GUI for ooniprobes 3 3 5 4 3.75
Do research based on OONI 3 3 5 3.666666667
@hellais
hellais / report-dns_injection-2014-12-12T101910Z.yamloo
Created December 15, 2014 18:21
first ever libight ooniprobe report
---
test_name: dns_injection
test_version: 0.0.1
probe_ip: 127.0.0.1
software_name: ight
software_version: 0.0.1
data_format_version: 0.1
...
---
input: google.com
@hellais
hellais / designer.html
Created August 23, 2014 17:02
designer
<link rel="import" href="../core-item/core-item.html">
<link rel="import" href="../google-map/google-map.html">
<link rel="import" href="../core-field/core-field.html">
<link rel="import" href="../core-icon/core-icon.html">
<link rel="import" href="../core-input/core-input.html">
<link rel="import" href="../core-icons/core-icons.html">
<polymer-element name="my-element">
<template>
@hellais
hellais / gist:a1a63df6e9f4958c9ab0
Created August 11, 2014 15:32
Enumerate HS descriptors
import json
from pprint import pprint
from base64 import b64decode
from twisted.internet import reactor, defer
from txtorcon import launch_tor, TorConfig, TorState
from twisted.internet.endpoints import TCP4ClientEndpoint
from twisted.internet.task import react
from twisted.web.client import readBody
@hellais
hellais / gist:10496214
Created April 11, 2014 19:50
random int generation.
# random int generation as gist.
randint = lambda a,b: a + int(''.join("%x" % ord(i) for i in os.urandom(b-a+1)), 16) % (b - a + 1)