Skip to content

Instantly share code, notes, and snippets.

View iDanielLaw's full-sized avatar

Daniel Law iDanielLaw

  • Imagine No Limit Technology
View GitHub Profile
@iDanielLaw
iDanielLaw / Lava Lamp RNG.md
Created June 23, 2019 17:42 — forked from UnquietCode/Lava Lamp RNG.md
Lava Lamp Random Number Generator

Lava Lamp Random Number Generator

(extracted from the now defunct SGI project at http://lavarand.sgi.com/cgi-bin/how.cgi via the magical Internet Archive Wayback Machine)

Lava Lamps can be used as a source of randomness, which can be used to establish a random number generator. The output of the RNG can then be consumed by various computer applications.

Step 1: Establish a chaotic system

(Set up Lava Lite® lamps in a machine room.)

#!/bin/bash
# Create and sign a JWT token with ES256 given the path to an ECDSA
# private key and a JSON payload.
# $0 path/to/keypair.der '{"JSON": "payload"}'
# Example keypair creation:
# openssl ecparam -name prime256v1 -genkey -noout -outform DER > example-keypair.der
# A few tips for generating the payload:
# - Pipe raw strings through `jq --raw-input .` to encode them as
@iDanielLaw
iDanielLaw / index.sh
Created June 15, 2019 09:13 — forked from max-mapper/index.sh
generate ES512 and RS256 elliptic curve keypairs for JWT JWK (JSON Web Token JSON Web Key) using openssl
# RS256
# private key
openssl genrsa -out rs256-4096-private.rsa 4096
# public key
openssl rsa -in rs256-4096-private.rsa -pubout > rs256-4096-public.pem
# ES512
# private key
openssl ecparam -genkey -name secp521r1 -noout -out ecdsa-p521-private.pem
# public key
@iDanielLaw
iDanielLaw / udp_client.go
Created June 6, 2019 06:53 — forked from reterVision/udp_client.go
A dummy UDP hole punching sample in Go
package main
import (
"encoding/json"
"fmt"
"log"
"net"
"os"
"time"
)
@iDanielLaw
iDanielLaw / client.go
Created May 23, 2019 11:41 — forked from spikebike/client.go
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)
@iDanielLaw
iDanielLaw / chat.go
Created May 23, 2019 11:41
simple golang chat server
package main
import (
"bufio"
"net"
)
type Client struct {
incoming chan string
outgoing chan string
taskkill /F /IM flow.exe /T
@iDanielLaw
iDanielLaw / nf.c
Created May 2, 2019 09:40 — forked from Taehun/nf.c
Linux Kernel Module Example: Netfilter
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netfilter_ipv4.h>
#include <linux/skbuff.h>
#include <linux/udp.h>
#include <linux/ip.h>
/* This function to be called by hook. */
static unsigned int
hook_func(unsigned int hooknum,

The netfilter hooks in the kernel and where they hook in the packet flow

The figure below calls out

  • The netfilter hooks
  • The order of table traversal
@iDanielLaw
iDanielLaw / ethcom.c
Created April 29, 2019 11:04 — forked from lethean/ethcom.c
Send / Receive raw Ethernet frames with custom EtherType in Linux
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
vim: set autoindent expandtab shiftwidth=2 softtabstop=2 tabstop=2: */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include <sys/types.h>
#include <sys/socket.h>