Skip to content

Instantly share code, notes, and snippets.

View kousu's full-sized avatar

Nick Guenther kousu

View GitHub Profile
@kousu
kousu / README.md
Last active February 26, 2017 01:50
Extract SMTP credentials by running a fake server

I forgot my email password.

This is a hacked version of smtpd.py which extracts AUTH PLAIN passwords. You can use to it extract passwords from your email clients if you've forgotten them and would rather not try to figure out where they are stored locally: instead, run this and change the host and port your client uses for an SMTP server.

Example run:

[kousu@host ~/src]$ ./smtpd.py -n -d 0.0.0.0:8025
PureProxy started at Sat Feb 25 20:27:17 2017
	Local addr: ('0.0.0.0', 8025)
@kousu
kousu / bsd_thread_syscall_hang.py
Created February 12, 2017 15:15
Unkillable read()s when threads are involved
#!/usr/bin/env python
"""
Unkillable read()s when threads are involved bug:
Set up:
1) run `nc -l 7654 -k` in another terminal
2) run this
3) press control-c
Results:
@kousu
kousu / diproxy.py
Last active February 15, 2017 22:32
#!/usr/bin/env python
# DI's new licensing restriction setup is basically completely forgeable
# the only thing they actually enforce is referer checking
#
# This program sits and does the necessary referer hacking, so that you can still listen to DI.fm on standard internet radio players
#
# TODO:
# - [x] get a full list of DI channels (maybe dynamically even, at boot?)
# - [ ] pretty-up the menu; jinja2?
# - [ ] print bandwidth reports as listeners join and leave
#!/bin/sh
# this wraps an arbitrary program in dmenu
# usage: dmenu_do "<dmenu arguments>" -- "<command>"
# dmenu will run with no options, and if the user gives input, <command> will be run with input as trailing arguments
# #
# Example: dmenu_do "-p \"Web Search:\"" -- "sr duckduckgo -j"
# becomes sr duckduckgo -j `dmenu -p "Web Search:"`, except it only runs if dmenu succeeds
#
# This is not a perfect wrapper:
# ideally the API would be: dmenu_do [dmenu args] -- command [args]
@kousu
kousu / mkcert
Created February 21, 2016 06:52
openssl sucks
#!/bin/sh
#
# generates a self-signed CA and certificates signed by that CA.
# If you install the CA into your certificate stores (in Firefox: Prefs->Advanced->Certs->Import, in Gnome: open the .crt in and whose .crt,.key pair can be used
# worked out with http://www.akadia.com/services/ssh_test_certificate.html and trial and error
# (as usual, with OpenSSL)
# Usage:
# ./mkcert # and follow the prompts, to make a CA
# ./mkcert my.domain.name
@kousu
kousu / ircd
Created February 21, 2016 02:22
# #!/bin/sh
# unrealircd is designed to be VERY GOOD at staying alive
# which means it's very hard to kill
# ctrl-c'ing it doesn't kill it, but sometimes it restarts it
# instead, we background it and translate ctrl-c to a stronger signal, which it will listen to
#
CONF=$(mktemp ircd.conf.XXXXX)
LOG=$(mktemp ircd.log.XXXXXX)
@kousu
kousu / mpd.conf
Last active June 20, 2016 22:50
Local MPD.conf
# mpd config file
### XXX this has been manually hacked up to
# mpd (undocumentedly) checks $XDG_CONFIG_DIR/mpd/mpd.conf before ~/.mpdconf, before /etc/mpd.conf
# since it does that... why not the rest of the system eh?
# but this script doesn't understand environment vars of course, though it *will* expand ~/ to $HOME
# for some reason linux has decided that $XDG_RUNTIME_DIR should be on /run (/run/user/1000) which is annoying
# Files and directories #######################################################
@kousu
kousu / rdpvpn.sh
Created May 27, 2015 22:30
automagic VPNing into Windows machines, via ssh
#!/bin/sh
# automagic VPNing into Windows machines, via ssh
# this assumes the machine you're VPNing into also runs an ssh server, which admittedly is an unusual configuration (it could be stretched to not do this)
# we knock on the RDP port; if it doesn't respond, assume we're outside of the firewall, and construct a tunnel
#XXX -g workarea *does not work* with i3. Much sadness.
HOST=${HOST:=XXXXXXXXXXXXXXXXXXX}
PORT=${PORT:=3389}
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http:#www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
@kousu
kousu / README
Last active August 29, 2015 14:14
partition plain text files by section marker for literate programming the way it should be done
...possibly python wins this one.