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 / ssh-ike.sh
Last active February 16, 2017 12:11
Replacement for IKE stack using /bin/sh and ssh. Use at your own risk.
#!/bin/sh
set -e
remote_ip="$1"
: ${remote_user:=root}
: ${key_type:=aes-ctr}
: ${key_len:=$((288*2/8))}
: ${spi_cache_dir:=$HOME/.cache/spi}
test -n "$remote_ip" || {
@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 / 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 / webadb.py
Created March 10, 2017 04:24
View and click android screen via web, using adb
#!/usr/bin/python
from bottle import Bottle, response, request, HTTPResponse
import subprocess
import os
import json
import sys
ADB=os.environ.get("ADB", "adb")
@korc
korc / utils.py
Created April 11, 2017 22:08
Misc utilities
#!/usr/bin/python
# License: Public Domain
import os, sys
import re, struct, json, random, datetime, logging
import subprocess, signal
import socket, ssl, select
import cStringIO as StringIO
import warnings
@korc
korc / unzip_cp932.py
Created April 14, 2017 19:18
Extract from Japanese windows cp932-encoded zip files into utf8-encoded files
#!/usr/bin/python
from zipfile import ZipFile
import sys
import getopt
import os
import shutil
import getpass
default_enclist=["cp932", "utf8"]
#!/usr/bin/python
import psycopg2, os, sys
import json
import pprint
whois_table=os.environ.get("WHOIS_TABLE", "whois")
dsn=os.environ.get("WHOIS_DSN", "")
check_table_sql="select 1 from %s where 1=0"%(whois_table,)
@korc
korc / maildir-smtpd.go
Created May 14, 2017 14:07
SMTP daemon saving all mails to maildir
package main
import (
"os"
"os/signal"
"log"
"github.com/flashmob/go-guerrilla/mail"
"strings"
"github.com/flashmob/go-maildir"
"fmt"
package main
import (
"bufio"
"crypto/sha1"
"crypto/tls"
"crypto/x509"
"flag"
"io"
"io/ioutil"
@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()