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 / s4pf.sh
Created February 16, 2017 13:49
Convert $SSH_CONNECTION to pcap filter
#!/bin/sh
test -n "$SSH_CONNECTION" || {
echo "No SSH_CONNECTION defined." >&2
echo "Example usage: ssh host dumpcap -P -i eth0 -f '\"not \$(${0##*/})\"' -w - | wireshark -k -i -" >&2
exit 1
}
read h1 p1 h2 p2 <<EOF
$SSH_CONNECTION
@korc
korc / pkcs11-tls-proxy.go
Last active December 21, 2023 02:46
PKCS11-authenticated TLS socket proxy
package main
import (
"crypto/tls"
"flag"
"fmt"
"io"
"log"
"net"
"net/textproto"
@korc
korc / ssh-askpass-pinentry.py
Created August 9, 2023 10:28
ssh-agent wrapper for pinentry
#!/usr/bin/env python3
import subprocess, sys, re
from urllib.parse import quote, unquote
proc = subprocess.Popen(
["pinentry"], stdout=subprocess.PIPE, stdin=subprocess.PIPE, text=True, bufsize=1
)
@korc
korc / udp2tcp_dns.py
Last active January 25, 2023 05:24
Convert DNS UDP to TCP
#!/usr/bin/python
import socket, os, select, struct
import errno
import logging
from logging import info, warn, error
logging.root.setLevel(logging.INFO)
@korc
korc / bf_known_hosts.py
Created December 7, 2016 22:36
~/.ssh/known_hosts bruteforcer
#!/usr/bin/python
import Crypto.Hash.SHA, Crypto.Hash.HMAC
import sys, re, os
import getopt
import time
kh_re=re.compile(r'^\|1\|(?P<salt>[a-zA-Z0-9/+]+=*)\|(?P<hash>[a-zA-Z0-9/+]+=*) (?P<keytype>\S+) (?P<hostkey>[a-zA-Z0-9/+]+=*)$')
def read_kh(fname):
ret=[]
@korc
korc / pre-install-extension.py
Last active October 22, 2022 08:05
Set up Chrome master_preferences file for Pre-installed Extensions. Cf. https://www.chromium.org/administrators/pre-installed-extensions/
#!/usr/bin/env python3
import sys
import os
import json
args = sys.argv[1:]
if not args:
print(
@korc
korc / i3status-more.sh
Created December 19, 2020 12:16
i3 status bar (cpu) temperature display enhancement
#!/bin/sh
# colorize hardware temperatures for i3status (more red as temp gets closer to crit)
# (shell internal commands only)
## this script expects i3status to give output in the format of "i3bar",
## and having a placeholder with string "TEMPERATURE"
## .config/i3status/config should contain something like this:
# general {
# output_format = "i3bar"
#!/bin/sh
remote="$1"
test -d "$2" || {
echo "Usage: ${0##*/} <host:port> <cert_dirs..>" >&2
exit 1
}
shift
@korc
korc / led-badge-write.go
Created August 31, 2019 22:36
Programmable 44x11 LED badge (USB HID 0416:5020) programmer/driver
package main
import (
"bytes"
"encoding/binary"
"encoding/hex"
"errors"
"flag"
"fmt"
"image"
@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"