Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Marley nmarley

View GitHub Profile
@nmarley
nmarley / kapture.sh
Created Jul 18, 2013
OSX can capture WiFi packets using only tcpdump (and without needing a clunky interface such as KisMAC). Used for testing security strength of home WiFi setup.
View kapture.sh
#! /bin/bash
# This is for Mac OSX only.
# =============================================
# explanation of arguments used with 'tcpdump':
# =============================================
# -y IEEE802_11_RADIO => makes it capture __WIFI__ packets, turns resultant file
# into a dump which can be read by aircrack-ng, etc.
#
# -I => puts interface into monitor mode (required to capture packets)
@nmarley
nmarley / dec.py
Last active Oct 7, 2021
AWS KMS encryption/decryption using Python/Boto3
View dec.py
import boto3
import base64
if __name__ == '__main__':
session = boto3.session.Session()
kms = session.client('kms')
encrypted_password = 'AQECAHjgTiiE7TYRGp5Irf8jQ3HzlaQaHGYgsUJDaavnHcFm0gAAAGswaQYJKoZIhvcNAQcGoFwwWgIBADBVBgkqhkiG9w0BBwEwHgYJYIZIAWUDBAEuMBEEDDwxVQuG0oVwpkU7nQIBEIAoVGk1/wpserb+GVUOzE7PiL/Nr9fTDFKZfpKpF0ip2ct4B2q0Wn6ZZw=='
binary_data = base64.b64decode(encrypted_password)
@nmarley
nmarley / README.md
Last active Aug 4, 2021
Go / C++ bindings example
View README.md

Go / C++ bindings example

This is an example of Go code calling to a C++ library with a C wrapper.

Build

go build  # this only ensures it compiles
@nmarley
nmarley / get-latest-alpine-ami.sh
Last active Apr 13, 2021
Get latest Alpine AMI
View get-latest-alpine-ami.sh
#! /bin/bash
# get latest alpine linux AMI
aws ec2 describe-images --output text --filters Name=owner-id,Values=538276064493 Name=name,Values='alpine-ami-3.13*-x86_64*' Name=architecture,Values=x86_64 Name=state,Values=available --query 'max_by(Images[], &CreationDate).ImageId'
@nmarley
nmarley / README.md
Last active Mar 29, 2021
Go fresh install Ubuntu 18.04
View README.md

Go install using gvm on fresh Ubuntu instance

Install

Using a fresh Ubuntu 18.04 (latest LTS) install:

# Install prerequisites
sudo apt update
sudo apt install -y bison binutils gcc make
@nmarley
nmarley / most-recent-ubuntu-ami.sh
Last active Feb 11, 2021
AWS EC2: Search most recent Ubuntu AMI for all regions
View most-recent-ubuntu-ami.sh
#! /bin/bash
# search based on prefix and most recent date
IMAGE_PREFIX="ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-"
# Canonical (makers of Ubuntu)
OWNER_ID="099720109477"
for REGION in $(aws ec2 describe-regions | jq -r '.Regions[].RegionName'); do
IMAGE_ID=$(aws ec2 describe-images --region "${REGION}" --filters "Name=name,Values=${IMAGE_PREFIX}*" --owners "$OWNER_ID" | jq -r '.Images | sort_by(.CreationDate)[-1].ImageId')
@nmarley
nmarley / main.rs
Last active Jan 7, 2021
Example of sending interrupt using Rust mpsc channel
View main.rs
use std::sync::mpsc::channel;
use std::sync::mpsc::Sender;
pub struct PPU {
// data...
cycles: u8,
nmi_channel: Sender<bool>,
}
impl PPU {
@nmarley
nmarley / README.md
Last active Dec 4, 2020
JSON Schema validation example in Node.JS
View README.md

test json schema validation in Node.JS

Setup Package

$ npm i jsonschema --save

Test/Play:

$ node ./v.js
@nmarley
nmarley / .gitignore
Last active Nov 27, 2020
LOD parser in Go (parse Luxembourg Online Dictionary XML files) basic PoC
View .gitignore
# ignore the ignore/ dir
ignore/
@nmarley
nmarley / docker_cid.sh
Created Dec 8, 2016
Docker — get container ID from within Docker container
View docker_cid.sh
bash-4.3# cat /proc/1/cpuset
/docker/13f8c221656e202db979d1e607c9c902282d8719ab70715978dd04ee6069d61e
bash-4.3# DOCKER_CID=$(cat /proc/1/cpuset | cut -c9-)
bash-4.3# echo $DOCKER_CID
13f8c221656e202db979d1e607c9c902282d8719ab70715978dd04ee6069d61e