Skip to content

Instantly share code, notes, and snippets.

View joachifm's full-sized avatar
🌴
On vacation

Joachim F. joachifm

🌴
On vacation
  • Oslo, Norway
  • 09:25 (UTC +02:00)
View GitHub Profile
@joachifm
joachifm / aws-ssm-iter.sh
Created August 31, 2023 17:52
Export ssm path to shell variables
#! /usr/bin/env bash
awslocal() {
env \
AWS_ACCESS_KEY_ID=test \
AWS_SECRET_ACCESS_KEY=test \
aws --region=us-east-1 --endpoint-url=http://127.0.0.1:4566 ${*}
}
set -u

Keybase proof

I hereby claim:

  • I am joachifm on github.
  • I am joachifm (https://keybase.io/joachifm) on keybase.
  • I have a public key whose fingerprint is 8861 86AB 67A8 1027 B645 7717 66EA B6B1 4F6B 6E0D

To claim this, I am signing this object:

@joachifm
joachifm / ServiceGuide.org
Last active September 13, 2021 18:11
services

Service hardening basics

The ideal service runs with the minimum set of privileges necessary to perform the task it is configured to do.

When writing new services, consider the following:

  • Can the service run as an unprivileged user?
    • In most cases, the daemon can run as an unprivileged user or with a limited set of super-user capabilities
  • Can the service run without network access?
#pragma once
#include <stdbool.h>
/** A data table, with fast membership testing.
*
* Data tables are static arrays of data, with keys ranging from 0 to N-1. To
* distinguish unset elements from 0 values, tables also contain an array
* indicating whether a value has been set.
*
#pragma once
/** Define an "optional" value, where the first bit indicates
* whether the value has been set and the remaining bits are used
* for the actual value.
*
* The up-side of this definition is that it is equally space efficient
* as simply storing an array of the underlying type.
*
* The down-side of this definition is that you lose a whole bit of possible
{ pkgs ? import <nixpkgs>{}
, lib ? pkgs.lib
, configuration ? import ./configuration.nix
, nixos ? import <nixpkgs/nixos>{ inherit configuration; }
}:
let
inherit (lib) filterAttrs mapAttrs;
inherit (builtins) hasAttr getAttr;
@joachifm
joachifm / HashCat.hs
Created February 28, 2015 15:48
HashCat
{-|
Hashing the concatenation of two strings leaves a "gap" between the
inputs, so that the hash may be recreated using any two substrings
of the original input:
@
H("banana" <> "split") = H("banan" <> "asplit") = H("b" <> "ananasplit")
@
Hashing the inputs before concatenation removes this gap:
sbcl --load /usr/share/cl-quicklisp/quicklisp.lisp \
--eval '(quicklisp-quickstart:install)' \
--eval '(ql:add-to-init-file)' \
--eval '(quit)'
@joachifm
joachifm / commitment.hs
Created November 29, 2014 22:02
Commit to a message without leaking information (?)
{-# LANGUAGE OverloadedStrings #-}
module Commitment ( Message, Commitment, Opening, commit, reveal ) where
import Crypto.Cipher.AES (initAES, encryptCTR, decryptCTR)
import qualified Data.ByteString.Lazy as LB
import qualified Data.ByteString as SB
--
@joachifm
joachifm / Fizzzzz.hs
Created September 10, 2014 05:26
Fizz
import Control.Monad (guard)
import Control.Applicative ((<|>), (*>), pure)
import Data.Maybe (mapMaybe)
import Data.Monoid ((<>))
fizzBuzz :: [Integer] -> [String]
fizzBuzz = mapMaybe (\x -> g 3 "Fizz" x <> g 5 "Buzz" x <|> pure (show x))
where g d s x = guard ((x `rem` d) == 0) *> pure s