Skip to content

Instantly share code, notes, and snippets.

Matthias Hecker 4poc

Block or report user

Report or block 4poc

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View lmdb_bench.py
from uuid import uuid4
from time import time
from datetime import datetime, timedelta
import lmdb
def get_random(size):
def get_bytes():
return bytearray(size)
return get_bytes
@4poc
4poc / gist:5761b0cdfd6d903d31a73c36aff22b90
Created Feb 23, 2017
python 3.4 vs. 3.5 incompatibility
View gist:5761b0cdfd6d903d31a73c36aff22b90
def fun(a=0, b=0):
print(a, b)
fun(**{'b': 2}, a=1) # <--- breaks in 3.4
fun(a=1, **{'b': 2}) # works in 3.5
@4poc
4poc / 1_encrypt.py
Last active Dec 13, 2016
Is this secure? (encrypted and signed(?))
View 1_encrypt.py
import jose
from json import dumps
from Crypto.PublicKey import RSA
key = RSA.generate(2048)
private_key = key.exportKey('PEM').decode('utf-8')
public_key = key.publickey().exportKey('PEM').decode('utf-8')
from jwcrypto import jwk, jwe
from jwcrypto.common import json_encode
View Deflate (python).py
import base64
import zlib
compressed = base64.b64encode(zlib.compress(decompressed))
View wifibot.py
#!/usr/bin/python
# Wifibot: Read station dumps from a router and shows new/dropped wifi clients in a matrix channel
# by john & matthias
import re
import sys
import time
import subprocess
import requests # pip install requests
from threading import Thread
View gist:6b41291bb1eef8f9720fa5344c4d8600
# Route local connections to the remote target to localhost port 4440:
iptables -t nat -A OUTPUT -p tcp --dport 443 -d [REMOTE_HOST] -j DNAT --to-destination 127.0.0.1:4440
# Route local connections to port 4441 to the original target:
iptables -t nat -A OUTPUT -p tcp --dport 4441 -d 127.0.0.1 -j DNAT --to-destination [REMOTE_HOST]:443
# Use sslsplit to proxy connections inbetween and save plaintext contents:
sslsplit -D -l connections.log -S logs -k ca.key -c ca.crt https 127.0.0.1 4440 127.0.0.1 4441
View gist:674598e9ac66a1df6948d03488480b17
// immutable object assignment:
const initialState = { products: {} };
export default function reducer(state = initialState, action = {}) {
switch (action.type) {
case PUT_PRODUCT:
return { ...state, products: { ...state.products, [action.product.id]: action.product } };
default:
return state;
}
}
@4poc
4poc / bintest.js
Created Oct 11, 2016
Buffer Schema Type in Mongoose: How to specify subtype
View bintest.js
'use strict';
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;
const MongooseBuffer = mongoose.Types.Buffer;
const uuid = require('node-uuid');
const db = require('../lib/database');
View gist:3e2243d3b9d57079ac2b
foo = {
'nested': {
'dict': 42
}
}
query = 'nested.dict'
# reduce:
from functools import reduce
View keybase.md

Keybase proof

I hereby claim:

  • I am 4poc on github.
  • I am apoc (https://keybase.io/apoc) on keybase.
  • I have a public key whose fingerprint is 6FCC 1EF0 3B42 A155 CE89 4962 C6E6 8A99 721F BC1E

To claim this, I am signing this object:

You can’t perform that action at this time.