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 / 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"
@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()
// 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
<!DOCTYPE html>
<html>
<head>
<title>Control Remote Web</title>
<script>
"use strict";
var targets = [];
var messageQueue = {};
#!/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)
@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