Skip to content

Instantly share code, notes, and snippets.

View crashGoBoom's full-sized avatar

Christopher Mundus crashGoBoom

View GitHub Profile
@crashGoBoom
crashGoBoom / block_non_root_ec2_meta.sh
Created August 4, 2021 16:25
Block non root users from accessing ec2 metadata
#!/bin/bash
# This will block users that are not root from accessing ec2 metadata
# Prevents users from grabbing the instance credentials
iptables -A OUTPUT -m owner ! --uid-owner root -d 169.254.169.254 -j DROP
@crashGoBoom
crashGoBoom / send_colorbars_tone_to_rtmp.sh
Created February 15, 2021 23:27
Send colorbars and tone to RTMP endpoint using FFMPEG
ffmpeg -re -f lavfi -i 'testsrc[out0];sine[out1]' \
-c:v libx264 -pix_fmt yuv420p -profile:v main \
-preset veryfast -x264opts "nal-hrd=cbr:no-scenecut" \
-minrate 3000 -maxrate 3000 -g 60 -c:a aac -b:a 160k \
-ac 2 -ar 44100 -f flv \
rtmps://$INGEST_ENDPOINT
@crashGoBoom
crashGoBoom / create_test_video.sh
Created February 15, 2021 23:24
Generate a 30 second test video with tone with FFMPEG
ffmpeg -f lavfi -i 'testsrc[out0];sine[out1]' -t 30 -pix_fmt yuv420p colorbars_tone.mp4
@crashGoBoom
crashGoBoom / install-codeql.sh
Last active October 27, 2023 05:32
Install codeql for MacOS (BigSur)
#!/bin/bash
# Check for latest release: https://github.com/github/codeql-cli-binaries/releases
_version='v2.4.1'
_arch='osx'
_zip_url="https://github.com/github/codeql-cli-binaries/releases/download/${_version}/codeql-${_arch}64.zip"
_dir='codeql-home'
_cores=2
pushd "${HOME}" || exit
@crashGoBoom
crashGoBoom / c-est_quoi_ça.sh
Last active December 25, 2020 21:37
Useful investigation for linux
#!/bin/bash
# Get open network connections
lsof -a -i4 -i6 -itcp
# Get listening ports
netstat -tunlp
@crashGoBoom
crashGoBoom / get_bucket_by_prefix.sh
Created September 30, 2020 16:43
aws s3 get bucket by name prefix
#!/bin/bash
# Usage: ./get_bucket_byprefix.sh "someprefix"
_prefix="${1}"
aws s3api list-buckets --query "Buckets[?starts_with(Name,'${_prefix}')].Name
@crashGoBoom
crashGoBoom / ssm_local.sh
Last active July 1, 2020 19:58
Local Port Forwarding with AWS SSM
#!/bin/bash
# Usage: ./ssm_local.sh i-xxxxxxxxxx 80
_instance_id="${1}"
_instance_port="${2}"
aws ssm start-session --target "${_instance_id}" \
--document-name AWS-StartPortForwardingSession \
--parameters "{\"portNumber\":[\"${_instance_port}\"],\"localPortNumber\":[\"9000\"]}"
@crashGoBoom
crashGoBoom / vid2gif.sh
Created August 27, 2019 18:55
Create a gif from mov file using FFMPEG
_video_file="${1}"
ffmpeg -i $_video_file -vf palettegen pal.png
ffmpeg -i $_video_file -i pal.png -lavfi paletteuse=bayer_scale=4:dither=bayer -r 18 video.gif
@crashGoBoom
crashGoBoom / jq_functions.sh
Created May 9, 2019 13:04
Simple handy jq functions.
declare -r SOME_JSON_FILE="/path/to/json/file.json"
# Read a key from a file.
# Usage: _key_value=$(_read_json_key "key")
function _read_json_key() {
local -r _key="${1}"
jq --arg key "${_key}" -r '.[$key]' "${SOME_JSON_FILE}"
}
# Writes a json key into an existing file without overwriting.
@crashGoBoom
crashGoBoom / aws-iam-simulate.sh
Last active September 16, 2022 03:46
Use AWS IAM Policy Simulator with the CLI
# The action we want to test
_action="s3:GetObject"
# The JSON you want to convert to a string
_json_to_convert='{ "Version": "2012-10-17","Statement": [{"Effect": "Allow","Action": "*","Resource": "*"}]}'
# Your resource arn goes here
_resource_arn="arn:aws:s3:::${_some_s3_bucket}/${_some_prefix}/*"
# This command will format the json policy as a string for the cli to use
# echo ${_json_to_convert} | jq '[.|tostring]'
# But we will send it to a fifo with '<()' instead of creating a json file every time