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 / 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"
#!/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 / 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"]
@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 / 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 / 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 / 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 / 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 / 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=[]
#!/usr/bin/python
import sys
import re
generics=set(['the', 'and', 'to', 'of', 'a', 'in', 'i', 'we', 'this', 'that', 'for', 'it', 'on', 'will',
'be', 'are', 'can', 'with', 'by', 'from', 'or', 'how', 'an', 's', 'these', 'have', 'not',
'our', 'used', 'at', 'their', 'has', 'such', 'also', 'which', 'using', 'they', 'but',
'all', 'what', 'about', 'based', 'you', 'more', 'been', 'some', 'use', 'other', 'one',
'when', 'them', 'many', 'well', 'o', 'll', 'up'])