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 / .env.example
Created March 18, 2019 14:04 — forked from DavidNgugi/.env.example
A Lumen Passport integration for a Lumen project
APP_NAME="Lumen app"
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_TIMEZONE=UTC
LOG_CHANNEL=stack
LOG_SLACK_WEBHOOK_URL=
@iDanielLaw
iDanielLaw / sendRawEth.c
Created April 20, 2019 08:17 — forked from austinmarton/sendRawEth.c
Send a raw Ethernet frame in Linux
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*/
#include <arpa/inet.h>
#include <linux/if_packet.h>
#include <stdio.h>
@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>

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 / 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,
taskkill /F /IM flow.exe /T
@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
@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 / 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 / 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