Skip to content

Instantly share code, notes, and snippets.

import base64
import zlib
compressed = base64.b64encode(zlib.compress(decompressed))
@4poc
4poc / wifibot.py
Last active December 1, 2016 10:45
#!/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
@4poc
4poc / gist:6b41291bb1eef8f9720fa5344c4d8600
Last active November 4, 2016 12:36
Local SSL/TLS Sniffing
# 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
// 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 / gist:7716437
Last active December 29, 2015 19:19
Simple Example IRC Bot, my first clojure program!
(ns cljbot
(:use [clojure.string :only (split join)]
[clojure.pprint :only (pprint)])
(:import (javax.net.ssl SSLSocketFactory X509TrustManager SSLContext TrustManager)
(java.io BufferedReader PrintWriter InputStreamReader)
(java.security SecureRandom)
(java.util.regex Pattern)))
(def HOST "irc.teranetworks.de")
(def PORT 6697)
@4poc
4poc / gist:6840150
Created October 5, 2013 12:13
SQLAlchemy Session Error: Timezone/Datetime related
> TypeError: can't compare offset-naive and offset-aware datetimes
channel.published_at = dateutil.parser.parse(snippet['publishedAt'], ignoretz=True)
^^^^^^^^^^^^^
@4poc
4poc / gist:6598991
Last active December 23, 2015 07:09
Implements a fiber extension for rbot plugins, adds a wait_for() functionality.

Fiber Extension for rbot plugins

This extension can be included in Plugin classes, works only with ruby >= 1.9.3/2.0.0. Does currently not work with threads unfortunately :(

It does extend it with the following:

  • adds a :fiber => true option to map/map! command mappings, this envelops each call to the command action/method in a new Fiber block

  • adds a new wait_for method that can be called from commands (that are mapped with :fiber => true)

@4poc
4poc / gist:6575746
Created September 16, 2013 01:18
Implements a rbot plugin that waits for user input using fibers, just a simple example to show the concept.
class FiberPlugin < Plugin
def fiber(m, params)
# imagine this beeing a long (possible infinite) list of something, that is loaded on request
data = ('a'...'z').to_a
@fiber = Fiber.new do
data.each_slice(3) do |partial|
m.reply partial.join(', ') + " #{Underline}Type &more for more data."
Fiber.yield
end
@4poc
4poc / gist:6565551
Created September 14, 2013 20:54
mechanize moneypatch: extend cookie_jar to allow to import/export cookies as strings
class Mechanize::CookieJar
public
def save_str
s = StringIO.new
save(s, :cookiestxt, :session => true)
s.string
end
def load_str(str)
s = StringIO.new str
foo = {
'nested': {
'dict': 42
}
}
query = 'nested.dict'
# reduce:
from functools import reduce