Skip to content

Instantly share code, notes, and snippets.

View dustinbutterworth's full-sized avatar
:octocat:

Dustin Butterworth dustinbutterworth

:octocat:
View GitHub Profile
@dustinbutterworth
dustinbutterworth / dns-check.sh
Created October 11, 2021 17:50
Check for dangling DNS in a list of CNAMES and their target record
#!/usr/bin/env bash
# FILE is a csv dumped from some source, i.e. Azure. Columns formatted like: "DnsRecord","Record","RecordType"
FILE="AllAzureDnsRecords10-08-2021-16.csv"
NEWFILE="dangling_records.csv"
DEADDNS=()
for line in $(grep "CNAME" ${FILE}); do
TARGET=$(echo ${line} | cut -d, -f2 | sed s/\"//g)
CNAME=$(echo ${line} | cut -d, -f1 | sed s/\"//g)
echo "Checking ${TARGET}..."
RESPONSE=$(host ${TARGET})
@dustinbutterworth
dustinbutterworth / dockernuke.sh
Created October 11, 2021 16:36
Nuke entire docker presence on local workstation
dockernuke () {
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -a -q)
docker system prune -a
docker volume prune
}
@dustinbutterworth
dustinbutterworth / cf-azure-app-service-restriction.ps1
Last active October 4, 2021 19:49
Add Cloudflare CIDR's to Azure App Service's Network Restriction using the Cloudflare API to pull latest CIDRs.
#!/usr/bin/env pwsh
# To Run: cf-azure-app-service-restriction.ps1 <ResourceGroup> <FunctionName>
# Credit to Praveen Kumar Sreeram, got the basic script from his blog post here and modified it a bit:
# https://praveenkumarsreeram.com/2021/04/26/azure-devops-bulk-ip-address-restriction-of-azure-app-service-dynamically-using-powershell/
Param(
[Parameter(Mandatory = $true)]
[string] $ResourceGroupName,
[Parameter(Mandatory = $true)]
[string] $WebAppName
@dustinbutterworth
dustinbutterworth / Rapid7Scan.sh
Created November 20, 2020 15:35
Rapid7 Scan Hosts via API
# Rapid7 Scan Request
# Sites and their corresponding ID:
# ATL = 1
# NYC = 2
#
# Scan Engines and their corresponding ID:
# ATLSCANNER = 1
# NYCSCANNER = 2
#
# Which Scan Engines Go with Which Sites:
# Credit to @leo60228
curl <YouTube URL> | grep -Po 'y.*g = \K\{.+?}(?=;y)' | jq -r '.args.player_response | fromjson | .streamingData.formats | max_by(.bitrate) | .url'
@dustinbutterworth
dustinbutterworth / double_to_single_space.sh
Created September 17, 2020 17:41
remove double spacing from a file
# remove double spacing from a file
tr -s '\n' < ${input_file} > ${output_file}
@dustinbutterworth
dustinbutterworth / ecrTagSearch.sh
Created September 10, 2020 13:06
Search for tag starting with the word "jenkins" in an ECR Image
aws ecr describe-images \
--repository-name ${REPO_NAME} \
--image-ids imageTag=${IMAGE_TAG} \
--profile prod \
| jq '.imageDetails[].imageTags[] |select (. | test("^jenkins"))'
@dustinbutterworth
dustinbutterworth / imageloopwithjq.sh
Created September 9, 2020 20:48
Loop Through Docker Images with Docker Inspect And jq
for f in $(sudo docker images -q) ; do sudo docker image inspect $f | jq '.[0].RepoTags[]' ; done
@dustinbutterworth
dustinbutterworth / CVEPuller.py
Created August 10, 2020 14:50
Take a CSV with CVE number in a row, print out CVE using regex.
#!/usr/bin/env python3
# Take a CSV with CVE number in a row, print out CVE using regex.
import csv
import re
reg = 'CVE-\d{4}-\d{4,7}'
csvfile = '/Users/dbutterworth/test/VulnerabilityListingExport.csv'
with open(csvfile, mode='r') as infile:
csvreader = csv.reader(infile)
@dustinbutterworth
dustinbutterworth / AwsSsmSessionManagerTomfoolery.sh
Created August 6, 2020 19:15
AWS SSM Session Manager Tomfoolery
#!/usr/bin/env bash
instance_id="i-***************"
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
curl "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/linux_64bit/session-manager-plugin.rpm" -o "session-manager-plugin.rpm"
sudo yum install session-manager-plugin.rpm -y
/usr/local/bin/aws ssm start-session --target $instance_id
#Cleanup