Skip to content

Instantly share code, notes, and snippets.

@tuansoibk
tuansoibk / cryptography-file-formats.md
Last active September 20, 2024 14:21
Cryptography material conversion and verification commands
  1. Introduction
  2. Standards
  3. Common combinations
  4. Conversion
  5. Verification/Inspection
  6. Tips for recognising

Introduction

It happens that there are many standards for storing cryptography materials (key, certificate, ...) and it isn't always obvious to know which standard is used by just looking at file name extension or file content. There are bunch of questions on stackoverflow asking about how to convert from PEM to PKCS#8 or PKCS#12, while many tried to answer the questions, those answers may not help because the correct answer depends on the content inside the PEM file. That is, a PEM file can contain many different things, such as an X509 certificate, a PKCS#1 or PKCS#8 private key. The worst-case scenario is that someone just store a non-PEM content in "something.pem" file.

@gene1wood
gene1wood / aws_assume_role
Last active May 17, 2022 16:40
Workaround AWS CLI lack of support for IAM assume-role
#!/bin/bash
usage () {
cat <<DOCUMENTATIONXX
Usage : . $0 ROLE_ARN [PARENT_PROFILE_NAME]
^--- Note that this script must be sourced not executed
This tool will generate temporary credentials for an assumed role, save
those ephemeral credentials in the awscli config and set the alias of
"aaws" to use this new ephemeral awscli profile
#!/bin/bash
if [ "$EUID" -ne 0 ] ; then
echo "Please run this installer as root (sudo -Hs)"
exit
fi
set +x
function step() {
echo "$@" "($((++n)) of 8)"
ALEX ARSON
ALFONSE RAPISTKILLER
ANGELO BRASSKNUCKLE
ARNOLD TWATPOUNDER
AXE BURLY
BLADE SPINERIPPER
BLAKE STONE
BOARD RAZORFIST
BRANDON BEERBONG
BROCK STEAL
@kennwhite
kennwhite / reset_osx_attributes.sh
Created September 1, 2013 03:10
Remove all extended attributes recursively on an OSX directory & files and fix "chown: ... Operation not permitted" and "chmod: ... Operation not permitted"
# This is the nuclear option. Use with extreme care
# Works up to and including Mountain Lion (10.8.x)
# Show all extended attributes
ls -lOe ~/dir-to-fix
# Remove no-change attributes
sudo chflags nouchg ~/dir-to-fix
# Recursively clear all entended attributes
@addiedx44
addiedx44 / sudofuckshitstack.sh
Last active July 27, 2016 13:26
Runs the last command with sudo if you curse at your terminal. Add this to your .bashrc.
# Runs the last command with sudo if you curse at your terminal.
#
# $ whoami
# adam
# $ how about now, motherfucker?
# root
#
debug_trap () {
re="(fuck|shit)"
if [[ $BASH_COMMAND =~ $re ]]; then
@addiedx44
addiedx44 / damnatio-memoriae.sh
Created April 3, 2013 02:32
Removes a file from a git repository by rewriting history.
# $1 below refers to whatever filename you want removed from the repository
git filter-branch --index-filter "git rm --cached --ignore-unmatch $1" --prune-empty -- --all
@addiedx44
addiedx44 / largefiles.sh
Last active January 24, 2018 15:19
List large files in order of size
sudo du -h / 2>/dev/null | grep '^\([0-9.]*G\|[0-9]\{3,\}M\)' | sort -h
@addiedx44
addiedx44 / randomkill.sh
Last active June 14, 2018 19:35
Kill a random process for funsies
kill -9 $(ps -ef | tail -n +2 | awk '{ print $2 }' | while read line; do echo "$RANDOM $line"; done | sort | awk '{ print $2 }' | head -n 1)