Skip to content

Instantly share code, notes, and snippets.

View fionn's full-sized avatar
🦜
wars are waged by technicians

Fionn Fitzmaurice fionn

🦜
wars are waged by technicians
View GitHub Profile
@fionn
fionn / san.sh
Last active July 8, 2022 13:08
Server name
#!/bin/bash
set -euo pipefail
echo | openssl s_client -servername "$1" -connect "$1":443 2>/dev/null | openssl x509 -noout -text | grep -A 1 "X509v3 Subject Alternative Name:" | grep "DNS:" | tr -d "DNS:" | tr -d " " | tr "," "\n"
@fionn
fionn / secure_object.py
Last active October 7, 2021 18:22
Dumb idea for intrinsic timing-attack-resistant Python object comparison
#!/usr/bin/env python3
import hmac
class SecureObject(bytes):
"""Bytes that can be compared safely"""
def __eq__(self, other: object) -> bool:
return hmac.compare_digest(self, other) # type: ignore
@fionn
fionn / tf-workspace-mv.sh
Last active September 7, 2021 06:17
Move or rename a Terraform workspace
#!/bin/bash
# Move the current workspace to the given name, along with all associated state.
# Deals with the special case default workspace in the least surprising way.
set -euo pipefail
export TF_INPUT=0
export TF_IN_AUTOMATION=1
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "You must be root"
exit 1
fi
service="Wi-Fi"
while true; do
@fionn
fionn / 00-cash-out-handshake.md
Last active May 27, 2021 11:08
Cashing out the Handshake Airdrop

Handshake Airdrop Withdrawal

Copied mostly from hs-airdrop/issues/2.

Warning

This assumes that the hs-airdrop code is not (necessarily) trustworthy, but also that it:

  • is not capable of escaping the docker container; and
  • does not leak your SSH private key material in its proof output.
@fionn
fionn / android_virtual_device_hardware_profile_options.txt
Created October 7, 2020 09:11
Android virtual device hardware profile options
PlayStore: Does the device supports Google Play?
PlayStore.enabled [no]:
avd home that was used during the construction of this hardware.ini: This can be used by post processing tools to migrate snapshots
android.avd.home []:
sdk root that was used during the construction of this hardware.ini: This can be used by post processing tools to migrate snapshots
android.sdk.root []:
ID of the AVD being run:
@fionn
fionn / android_mac.md
Created October 7, 2020 08:28
Android emulation on Darwin

Get the Android SDK with brew cask install android-sdk. It has a Java 8 dependency and tells you to install it with brew cask install homebrew/cask-versions/adoptopenjdk8. If you already have another newer version, you must set JAVA_HOME=/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home.

You now have emulator, sdkmanager and avdmanager.

To save yourself the missing file warnings, touch .android/repositories.cfg.

To make a test VM, run sdkmanager "system-images;android-30;google_apis;x86" to get the base image. You'll have to accept some licenses.

@fionn
fionn / brew_downgrade.md
Last active October 7, 2020 09:23
How to downgrade a Homebrew package in 2020

Make a GitHub repository that conforms to the naming scheme $username/homebrew-$tapname. It can be empty or already exist, it doesn't matter.

Get the formula at the version you want with brew extract $package $username/homebrew-$tapname --version=$version

This will automatically tap your tap, but if you want to add this to another machine, you'll have to:

  • commit and push your changes from the $(brew --prefix)/Homebrew/Library/Taps/$username/ directory,
  • brew tap $username/$tapname from the machine you want to add the tap to.

To install, brew install $package@$version.

@fionn
fionn / main.tf
Created July 12, 2020 14:17
Package Lambda
data "external" "packaged_lambda" {
program = concat(["${path.module}/files/package_lambda.sh", var.source_folder], var.exclude_files)
}
@fionn
fionn / nsl_en.md
Last active July 5, 2020 09:37
中華人民共和國香港特別行政區維護國家安全法

The Law of the People’s Republic of China on Safeguarding National Security in the Hong Kong Special Administrative Region

中華人民共和國香港特別行政區維護國家安全法

(English translation for reference)

Contents

  • Chapter I General Principles
  • Chapter II The Duties and the Government Bodies of the Hong Kong Special Administrative Region for Safeguarding National Security