Skip to content

Instantly share code, notes, and snippets.

View sowbug's full-sized avatar

Mike Tsao sowbug

View GitHub Profile
#!/usr/bin/python
import subprocess
SOURCES = [
('npth', 'npth-1.5'),
('ntbtls', 'ntbtls-0.1.2'),
('libgpg-error', 'libgpg-error-1.27'),
('libassuan', 'libassuan-2.5.1'),
('libgcrypt', 'libgcrypt-1.8.2'),
@sowbug
sowbug / openpgp-bitlength-mismatch.go
Created January 17, 2018 06:29
Demo code showing problem with GnuPG keys generated in golang.org/x/crypto/openpgp
// some of this was adapted from https://gist.github.com/eliquious/9e96017f47d9bd43cdf9
func (sg SecretGenerator) GetPGPKey(passphrase string) string {
var config packet.Config
config.Time = func() time.Time {
return time.Date(2017, 1, 1, 0, 0, 0, 0, time.UTC)
}
uid := packet.NewUserId(sg.GetFriendlyName("main"), "", "")
if uid == nil {
# Thanks https://lists.gnupg.org/pipermail/gnupg-users/2016-May/055985.html
#
# To specify the passphrase on the command line:
#
# gpg --pinentry-mode loopback --passphrase "secret" --batch --generate-key x25519-gen.gpgbatch
%echo Generating ed25519 primary and cv25519 subkey
Key-Type: eddsa
Key-Curve: Ed25519
Key-Usage: sign
@sowbug
sowbug / gnuk-on-stlinkv2.sh
Last active August 14, 2023 18:15
Gnuk on ST-Link v2
# https://github.com/cabo/stlink
# https://blog.danman.eu/2-usb-crypto-token-for-use-with-gpg-and-ssh/
sudo ./upgrade_by_passwd.py -f ../regnual/regnual.bin ../src/build/gnuk-vidpid.bin
sudo st-flash erase && st-flash --reset write ~/src/gnuk/src/build/gnuk-vidpid.bin 0x08000000
-- or --
~/src/stlink/build/Debug/st-flash reset && \
~/src/stlink/build/Debug/st-flash erase && \
#include <ESP8266WiFi.h>
#include <WEMOS_SHT3X.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
/************************* WiFi Access Point *********************************/
#define WLAN_SSID "my-ssid"
#define WLAN_PASS "my-wifi-password"
# First, go get the stock firmware from the [TP-Link site](https://static.tp-link.com/2018/201803/20180316/Archer%20C9(US)_V3_171215.zip).
# Then unzip it and cd into the resulting directory.
$ ls -l
total 14956
-rw-r--r-- 1 miket miket 14820016 Dec 15 2017 c9v4_eu-us-ca_up_1-3-1-20171215rel35219.bin
-rw-r--r-- 1 miket miket 112046 Sep 14 2015 'GPL License Terms.pdf'
-rw-r--r-- 1 miket miket 373590 Oct 14 2016 'How to upgrade TP-LINK Wireless AC Router.pdf'
$ binwalk c9v4_eu-us-ca_up_1-3-1-20171215rel35219.bin
import binascii
from bluepy import btle
from bluepy.btle import DefaultDelegate
class MyDelegate(btle.DefaultDelegate):
def __init__(self, params):
btle.DefaultDelegate.__init__(self)
def handleNotification(self, cHandle, data):
print "SOMETHING HAPPENED %s" % (binascii.hexlify(data))
#include <BLEAddress.h>
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
#include <U8x8lib.h>
int scanTime = 15;
// https://thejeshgn.com/2017/06/20/reverse-engineering-itag-bluetooth-low-energy-button/
@sowbug
sowbug / pir_room_light.ino
Created December 25, 2018 06:46
An Arduino sketch to turn an ESP8266 with a PIR sensor into a thing that pings IFTTT when it's time to turn a room light on and off.
// Mostly copied from http://randomnerdtutorials.com
// New stuff is the on/off logic
#include <ESP8266WiFi.h>
const char* ssid = "...";
const char* password = "...";
const char* resource_on = "/trigger/[IFTTT_APPLET_ID_TO_TURN_ON]/with/key/xxxxxxx";
const char* resource_off = "/trigger/[IFTTT_APPLET_ID_TO_TURN_OFF]/with/key/xxxxxxx";
const char* server = "maker.ifttt.com";
@sowbug
sowbug / Planck.kbd.json
Last active March 9, 2020 04:11
Planck
[
{
"name": "Planck",
"author": "http://www.keyboard-layout-editor.com/#/gists/0ab43ed5647a133cc5b0415ba9e02665"
},
[
{
"a": 7
},
"Tab",