Skip to content

Instantly share code, notes, and snippets.

View korc's full-sized avatar

Lauri Korts-Pärn korc

View GitHub Profile
@korc
korc / build-esteid-lxc.sh
Last active June 1, 2019 00:56
Building Estonian ID card capable Ubuntu/Bionic LXC container on Debian (stretch)
#!/bin/sh
set -e
test "$(id -u)" = "0" || exec sudo "$0" "$@"
: "${SUDO_UID:=1000}" "${SUDO_GID:=1000}"
: "${dist:=bionic}"
: "${lxc_name:=esteid-$dist}"
: "${rootfs:=/var/lib/lxc/$lxc_name/rootfs}"
@korc
korc / enc_http_payload.go
Last active November 26, 2019 21:37
Encrypt HTTP (ex PUT/POST) payload
package main
import (
"bytes"
"flag"
"io"
"log"
"net/http"
"net/http/httputil"
"net/url"
#!/bin/sh
find_scanner() {
echo -n "Scanning for scanners.." >&2
scanimage -f %d
echo "OK." >&2
}
test ! "x$1" = "x-h" || {
echo "Usage: ${0##*/} [<scanner>]" >&2
<!DOCTYPE html>
<html>
<head>
<title>Encrypt and Share</title>
<script src="https://unpkg.com/ace-builds@1.3.3/src-noconflict/ace.js" charset="utf-8"></script>
<script src="https://unpkg.com/ace-builds@1.3.3/src-noconflict/mode-markdown.js" charset="utf-8"></script>
<script src="https://unpkg.com/qrcode@1.2.0/build/qrcode.js" charset="utf-8"></script>
<script>
"use strict";
@korc
korc / csv2pg.go
Last active August 11, 2020 07:03
package main
import (
"database/sql"
"encoding/csv"
"fmt"
"github.com/lib/pq"
"io"
"log"
"os"
@korc
korc / audit2pg.go
Last active February 25, 2018 22:47
package main
import (
"bufio"
"database/sql"
"flag"
"fmt"
"log"
"math/big"
"net"
#!/bin/sh
red="$(tput setaf 1)" green="$(tput setaf 2)" blue="$(tput setaf 4)"
sg0="$(tput sgr0)" ul="$(tput smul)" b="$(tput bold)"
dq='"'
sed -ur \
-e '/^==>/d' \
-e '/^[[:space:]]*$/d' \
-e 's/^.*\[ *[.0-9]*\] //' \
@korc
korc / run1.sh
Last active May 11, 2018 18:54
Usage: go run websrv.go -listen :8080 # -help for more options.
#!/bin/bash
wget https://gist.githubusercontent.com/korc/a4e77451825737ef1fd2c491bd74246e/raw/websrv.go
go get -u golang.org/x/{crypto/acme/autocert,net/{webdav,websocket}}
go build websrv.go
sudo setcap cap_net_bind_service,cap_sys_chroot=ep websrv
mkdir -p data/uploads
./websrv -map /=file:/var/www/html -map /data/=webdav:$PWD/data/uploads -auth Basic:dGVzdDp0ZXN0
#!/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)