Skip to content

Instantly share code, notes, and snippets.

View tylerapplebaum's full-sized avatar
☁️
AWS + Networking

Tyler Applebaum tylerapplebaum

☁️
AWS + Networking
View GitHub Profile
@tylerapplebaum
tylerapplebaum / Find-EC2InstanceAvailabilityByRegion.ps1
Last active December 3, 2019 22:24
Find EC2 instance availability among all public regions
#Check for EC2 instance type availability among all public regions
#Prerequisites - the most current AWS CLI installation - https://aws.amazon.com/cli/
[CmdletBinding()]
param(
[Parameter(HelpMessage="Specify the API name of the EC2 instance type to search for. Example: t3a.small")]
[ValidateNotNullOrEmpty()]$InstanceType
)
$RegionsJson = aws ec2 describe-regions
@tylerapplebaum
tylerapplebaum / Sync-Documents.ps1
Created October 24, 2019 21:18
Robocopy wrapper to mirror directory to backup drive. Includes path validation.
#https://social.technet.microsoft.com/wiki/contents/articles/1073.robocopy-and-a-few-examples.aspx
#http://www.luisrocha.net/2008/12/robocopy-error-error-5-0x00000005.html
#Robocopy switches used:
#/MIR - mirror directory structure (including empty)
#/COPY:DT - excludes copying permissions
#/XA:H - excludes hidden files
#/W:5 - wait 5 seconds on a failure
#/XJD - exclude junction points
@tylerapplebaum
tylerapplebaum / Get-DirectoryInfo.ps1
Last active October 19, 2019 20:09
Identify directories with and without files
Function Get-SubdirectoryInfo {
[CmdletBinding()]
param(
[Parameter(HelpMessage="Specify the top level directory to search")]
[string]$TopLevelDir
)
#Find subdirectories with files
$Items = Get-ChildItem $TopLevelDir | Where-Object Attributes -ne Directory | Select-Object DirectoryName,Name,Length
@tylerapplebaum
tylerapplebaum / bootstrap.sh
Last active August 13, 2019 21:12
Bootstrap for Amazon Linux 2 EC2 instances
#!/bin/bash
sudo yum install httpd
usermod -a -G apache ec2-user
sudo chown -R ec2-user:apache /var/www
sudo systemctl restart httpd.service
sudo systemctl enable httpd.service
public_ipv4=$(curl -s "http://169.254.169.254/latest/meta-data/public-ipv4")
sudo echo $public_ipv4 > /var/www/html/public-ipv4.txt
cd /var/www/html
curl -O https://gist.githubusercontent.com/tylerapplebaum/98a940c312724ae6a0838d43afc2a592/raw/85523ac76edf2c68ee7431839784dff4313b723a/index.html
fsutil.exe file createNew file.txt 2645789412
.\zip2john.exe "C:\Users\derp\Downloads\Tester.zip" | Out-File C:\Users\derp\Downloads\Tester.hash -Encoding utf8
& type C:\Users\derp\Downloads\Tester.hash
.\john.exe C:\Users\derp\Downloads\Tester.hash
Using default input encoding: UTF-8
Loaded 1 password hash (PKZIP [32/64])
Will run 8 OpenMP threads
Proceeding with single, rules:Single
@tylerapplebaum
tylerapplebaum / Snippets.js
Created June 11, 2019 20:35
Chrome Dev Tools Utilities
// Paste these into the Developer Tools Console
// Calculate DNS lookup time in milliseconds
var pageNavArr = performance.getEntriesByType("navigation");
var pageResArr = performance.getEntriesByType("resource");
var pageArr = pageNavArr.concat(pageResArr);
pageArr.forEach(function(element) {
var dnsTime = element.domainLookupEnd - element.domainLookupStart;
if (dnsTime > 0) { // Don't display cached DNS entries
console.log(element.name);
@tylerapplebaum
tylerapplebaum / Resolve-EstablishedConnections.ps1
Last active March 18, 2019 20:56
Just like "netstat -f | findstr ESTABLISHED" but in PowerShell
Function Resolve-EstablishedConnections {
$EstConnections = Get-NetTCPConnection -State Established
$ConnectionArr = New-Object System.Collections.ArrayList #Initialize the ArrayList
$Counter = 1
ForEach ($Connection in $EstConnections) {
Write-Progress -Activity "Resolving PTR Record" -Status "Looking up $($Connection.RemoteAddress)" -PercentComplete ($Counter / $($EstConnections.Length)*100)
$ConnectionObj = [PSCustomObject][Ordered] @{
LocalAddress = $Connection.LocalAddress
@tylerapplebaum
tylerapplebaum / gist:0a82343a53c34b6f0d27724154fbfabe
Last active February 1, 2019 18:28
Printer Automation Idea for Dave
[CmdletBinding()]
param(
[Parameter(HelpMessage="Specify the path to the CSV file")]
[string]$CSVPath,
[Parameter(HelpMessage="Specify one of OCHIN's supported drivers")]
[ValidateSet("HP LaserJet 4100 Series PCL6", "HP Universal Printing PCL 5 (v5.7.0)", "Kyocera TASKalfa 7551ci", "Sharp MX-3500N", "Xerox Global Print Driver PCL")]$Driver
)
@tylerapplebaum
tylerapplebaum / Set-TSProfilePath.ps1
Last active October 13, 2018 03:46
Sets the Remote Desktop Services profile path for a user account in Active Directory. Also creates that folder in a share and sets NTFS permissions.
[CmdletBinding()]
param (
[Parameter(HelpMessage="Specify the username")]
[string]$Username,
[Parameter(HelpMessage="Specify the profile root directory")]
[string]$ProfileRoot,
[Parameter(HelpMessage="Specify the full path to log output to")]
[string]$LogPath = "C:\Automate\Set-TSProfilePath-log.txt",