Skip to content

Instantly share code, notes, and snippets.

View Spencer-Doak's full-sized avatar

Spencer Spencer-Doak

  • United States of America
View GitHub Profile
@Spencer-Doak
Spencer-Doak / show_proc_and_mem_info.sh
Created August 31, 2021 18:52
Retrieve and display information about CPU utilization, memory consumption, and network listeners.
#!/usr/bin/env bash
# Record process and memory information
function log_output() {
local lines_to_print="$1"
while IFS= read -r line_to_print; do
echo "[$(date -Ins --utc)] ${line_to_print}"
done <<< "${lines_to_print}"
}
@Spencer-Doak
Spencer-Doak / SearchInTheShadows.js
Created May 8, 2021 21:25
Recursively find all shadow roots in a page.
/**
* Recursive depth-first search to find all shadow roots within a webpage.
*
* Example usage: let's imagine you come across a page that has a bunch of
* expandable information sections, and you would like to expand all of those
* info sections for the sake of printing to a PDF or for the ease of
* performing a simple `CTRL+F` search across the information. Let's assume
* those expanding buttons are buried within Shadow DOM. (Perhaps the site is
* using Angular or something of the sort & the buttons are separate
* components, thus by default they end up in a Shadow DOM whenever included.)
@Spencer-Doak
Spencer-Doak / record_unexpected_network_connections.sh
Created November 8, 2020 23:11
Script for recording unexpected outbound connections. TCPDump has a lot of options. This script includes the options which I have found to be the most useful.
#!/usr/bin/env bash
# This is a script I use when checking for unexpected outbound connections.
# Script requires root-level permissions, so this should be executed with sudo.
# Before running, export INTERFACE='eth0' (or whatever interface) and
# export EXPECTED_IP='1.1.1.1' (or whatever IP Address you are expecting
# communication with).
# Summary of variables used in TCP Dump command:
# -A: This option causes tcpdump to display ASCII versions of packets, where it
# makes sense to do so. E.g., an unencrypted HTTP call might be displayed in