Skip to content

Instantly share code, notes, and snippets.

View korc's full-sized avatar

Lauri Korts-Pärn korc

View GitHub Profile
#!/bin/sh
# Changes WiFi NIC MAC address to MD5-based semi-random value
name="$1"
iface="$2"
: "${ifaces:=$(for i in /sys/class/net/*;do test ! -d $i/wireless || { echo -n "$_s${i##*/}";_s=" ";};done)}"
: "${iface:=$(echo "$ifaces" | cut -f1 -d" ")}"

Build SFS-bootable linux files from sources

Requirements for building

  • aufs support (grep -w aufs /proc/filesystems)
    • might be included in linux-image-extra-* packages
  • To build SFS files you need:
    • python and python-crypto
    • lxc-start, lxc-info and friends (lxc or lxc1 package)
  • mksquashfs (squashfs-tools package)
package main
import (
"bufio"
"bytes"
"crypto/tls"
"encoding/binary"
"flag"
"fmt"
"io"
package main
// +build windows,386
import (
"bytes"
"encoding/binary"
"errors"
"flag"
"fmt"
@korc
korc / foldertree.py
Last active September 14, 2017 02:33
terminator foldertree plugin
#!/usr/bin/python
## Put this file to $HOME/.config/terminator/plugins and enable 'FolderTree' plugin from preferences
import os, stat
import re
from terminatorlib import plugin, terminator
#!/usr/bin/python
import sys,socket,struct,time
snaplen = 65535
try: iface = sys.argv[1]
except IndexError:
sys.stderr.write("Usage: %s <interface> >output.pcap\n"%(sys.argv[0]))
raise SystemExit(1)
<!DOCTYPE html>
<html>
<head>
<title>Control Remote Web</title>
<script>
"use strict";
var targets = [];
var messageQueue = {};
// This program is intented to use with iptables REDIRECT directive
// for example if your provider is blocking outgoing port 25 connections
// 1) connect to server in datacenter which allows connections
// ssh -D 1080 user@example.com
// 2) redirect all outgoing SMTP connections through this here
// iptables -t nat -A OUTPUT -p tcp --dport 25 -j REDIRECT --to-ports 4567
// *Note* for router configuration (iptables PREROUTING chain) you have to listen on other IP than 127.0.0.1
package main
@korc
korc / debdeps.py
Created July 5, 2017 19:15
Shows dependencies of installed debian packages, recursively if asked
#!/usr/bin/python
import apt
import sys
import os
def print_deb_deps(name, recurse=1, prep="", _processed=None):
if _processed is None: _processed={}
print "%s%s:"%(prep, name),
sys.stdout.flush()
package main
import (
"bufio"
"crypto/sha1"
"crypto/tls"
"crypto/x509"
"flag"
"io"
"io/ioutil"