Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
set -eufo pipefail
if [ "$EUID" -ne 0 ]; then
if ! [ -x "$(command -v $SUDO)" ]; then
echo "Error: Running script as non-root and $SUDO is not installed. Exiting." >&2
exit 1
leonklingele / openssl.cnf
Last active Feb 9, 2018
Useful openssl commands
View openssl.cnf
[ req ]
default_bits = 4096
default_md = sha256
default_keyfile = private.key
distinguished_name = req_distinguished_name
attributes = req_attributes
x509_extensions = v3_user_req
req_extensions = v3_user_req
[ req_distinguished_name ]
leonklingele / libsodium-php_issue.php
Last active Mar 11, 2017
crypto_aead_chacha20poly1305_decrypt triggers E_ERROR when decryption / authentication fails
View libsodium-php_issue.php
$crypto = new Crypt('cbe92e0557602e1bf9c05fffe8e54a809c1bdc5b3c3e2011b9153ce0ce672917', 'ok');
$enc = $crypto->encrypt('secretmessage');
// Here we prepend an 'a' -> Decryption should fail, i.e. return false
// It should NOT trigger an E_ERROR, as we can't handle that.
$dec = $crypto->decrypt('a' . $enc);
leonklingele /
Last active Apr 25, 2020
netcat – encrypt transfer with openssl
SHARED_SECRET="shared secret"
OPENSSL_CMD="$OPENSSL enc -a -A -aes-256-gcm"
while IFS= read -r MSG; do
leonklingele /
Created Sep 23, 2016 — forked from mimoo/
Common x509 creation and verification pitfalls

Certificate validation/creation pitfalls

A x509 certificate, and in particular the latest version 3, is the standard for authentication in Public Key Infrastructures (PKIs). Think about Google proving that he's Google before you can communicate with him.

So. Heh. This x509 thing is a tad complicated. Trying to parse such a thing usually end up in the creation of a lot of different vulnerabilities. I won't talk about that here. I will talk about the other complicated thing about them: using them correctly!

So here's a list of pitfalls in the creation of such certificates, but also in the validation and use of them when encountering them in the wild wild web (or in your favorite infrastructure).

  1. KeyUsage
  2. Validity Dates
View gist:6470baad564b754f025628d69727de7d

Encrypting data (Was: AES-CTR with HMAC): Use, in order of preference: (1) The Nacl/libsodium default, (2) Chacha20-Poly1305, or (3) AES-GCM.

You care about this if: you're hiding information from users or the network.

All three options get you "AEAD", which is the only way you want to encrypt in 2015. Options (2) and (3) are morally the same thing: a stream cipher with a polynomial ("thermonuclear CRC") MAC. Option (2) gets there with a native stream cipher and a MAC optimized for general purpose CPUs; Poly1305 is also easier than GCM for library designers to implement safely. Option (3)'s AES-GCM is the industry standard; it's fast and usually hardware accelerated on modern processors, but has implementation safety pitfalls on platforms that aren't accelerated.

Avoid: AES-CBC, AES-CTR by itself, block ciphers with 64-bit blocks --- most especially Blowfish, which is inexplicably popular, OFB mode. Don't ever use RC4, which is comically broken.

Symmetric key length (Was: Use 256 bit keys

leonklingele / nginx__dynamic_tls_records.patch
Created Oct 11, 2016
A refreshed 'nginx__dynamic_tls_records.patch' patch for nginx 1.11.5
View nginx__dynamic_tls_records.patch
What we do now:
We use a static record size of 4K. This gives a good balance of latency and
Optimize latency:
By initialy sending small (1 TCP segment) sized records, we are able to avoid
HoL blocking of the first byte. This means TTFB is sometime lower by a whole
Optimizing throughput:
leonklingele / key-bindings.bash
Last active Aug 10, 2018
fzf key-bindings.bash: ignore duplicates
View key-bindings.bash
# ..
# Requires
# SHA256: 046d69b8b1ed74aaff38565f08acc9781e7404fa240b2d091601043a5838f9f0
# gsed -i 's?#!perl?#!/usr/bin/env perl?' nauniq
# patch -p1 nauniq < nauniq-ignore-pattern.patch
__fzf_history__() (
local line
shopt -u nocaseglob nocasematch
View 0001-apple-keychain-integration-other-changes.patch
From 32a85e260f85fc820fd026637ad38e2230d2887f Mon Sep 17 00:00:00 2001
From: Leon Klingele <>
Date: Tue, 21 Mar 2017 22:37:56 +0100
Subject: [PATCH 1/3] 0001-apple-keychain-integration-other-changes.patch
--- | 18 +-
audit-bsm.c | 7 +-
auth-pam.c | 5 +-
auth.c | 2 +-
View netcup-easter-offers-2017.txt
- .de-Domain 14 Cent Eine .de-Domain für nur 14 Cent/Monat bei 2 Euro Einrichtungsgebühr
- .at-Domain 9,90 € pro Jahr! Zu Ostern bekommen Sie eine .at-Domain um 17,5% reduziert - Normalpreis 12€/Jahr!
- VPS A Ostern 2017 + Intel Dual-Core + 1 GB DDR3 RAM + 200 GB SATA + Fernwartungskonsole + und vieles mehr Nur 1,44€ / Monat
- Root-Server Ostern 2017 + 2 dedizierte Kerne + Intel Xeon E5-2660V3 + 2 GB DDR4 RAM + 4 x 100 GB SAS + RAID10 + und vieles mehr Nur 4,66€ / Monat
- RS 4000 SSD 3 Monate kostenlos + 8 dedizierte Kerne + Intel Xeon E5-2680V4 + 24 GB DDR4 RAM + 120 GB SSD + RAID10 + und vieles mehr die ers
You can’t perform that action at this time.