Skip to content

Instantly share code, notes, and snippets.

Avatar

Nathan Marley nmarley

View GitHub Profile
@nmarley
nmarley / README.md
Last active January 29, 2023 16:49
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 / dec.py
Last active January 26, 2023 11:35
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 January 8, 2023 19:16
Rust macro testing
View README.md

Rust macro testing

rustc --test test2.rs
@nmarley
nmarley / docker_cid.sh
Created December 8, 2016 13:58
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
@nmarley
nmarley / out.txt
Created June 16, 2022 20:22
testnet debug log analysis
View out.txt
("masternode-1", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:55 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-2", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:54 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-3", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:54 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-4", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:54 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-5", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:55 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-6", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 12 22:54 /dash/.dashcore/testnet3/debug.log", build_version: "v0.17.0.3" })
("masternode-7", MNOutput { debug_log_line: "-rw------- 1 dash dash 10000000 Jun 1
@nmarley
nmarley / gencert.rb
Last active April 29, 2022 21:20
Ruby script to generate SSL certificates
View gencert.rb
#! /usr/bin/env ruby
#
# gencert.rb
# =====================================================================
# description: This script will accepts an FQDN as an argument
# and generates a Secure Sockets Layer (SSL)
# certificate request and a private key that corresponds
# to the request. It will not overwrite any existing
# files, so file <fqdn>.cnf , <fqdn>.csr , or <fqdn>.key
# exist, the program will print a message and exit.
@nmarley
nmarley / main.rs
Last active April 23, 2022 12:53
Example of sending interrupt using Rust mpsc channel
View main.rs
use std::sync::mpsc::{channel, Sender};
pub struct PPU {
// data...
cycles: u8,
nmi_channel: Sender<bool>,
}
impl PPU {
pub fn new(chan: Sender<bool>) -> Self {
@nmarley
nmarley / kapture.sh
Created July 18, 2013 01:43
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 / get-latest-alpine-ami.sh
Last active April 13, 2021 15:18
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 March 29, 2021 10:26
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