Skip to content

Instantly share code, notes, and snippets.

View colehocking's full-sized avatar

Cole Hocking colehocking

  • Colorado
View GitHub Profile
@colehocking
colehocking / nmap_smb.sh
Created October 8, 2018 17:20
Grab smb Nmap vulns with NSE
#!/bin/bash
TARGET="$1"
nmap -n -sV -Pn -pT:138,U:137 --script=smb-enum-shares,smb-enum-domains,smb-enum-domains,smb-os-discovery,smb-vuln* ${TARGET}
@colehocking
colehocking / ssh_proxy8000.sh
Created October 8, 2018 17:18
Proxy port 8000 for localhost browser access
#/bin/bash
# Make your argument: '<user>@<server>'
USR_AT_SRVR="$1"
ssh -D 8000 -C -N ${USR_AT_SRVR}
# Now just visit your server in a web browser on port 8000 and you should have localhost access via ssh!
@colehocking
colehocking / getLastLogon.ps1
Created October 8, 2018 17:12
Get last AD User logon
#Check if the account exists.
If($Results.Count -eq 0)
{
Write-Warning "The SamAccountName '$UserName' cannot find. Please make sure that it exists."
}
Else
{
Foreach($Result in $Results)
{
$DistinguishedName = $Result.Properties.Item("DistinguishedName")
@colehocking
colehocking / netbiosx.sh
Created October 4, 2018 17:10
Use OSX smbutil to NetBIOS resolve a file full of IPs
#!/bin/bash
# Use the OSX smbutil to query a file of IPs
# use 'lookup' instead of 'status' to get IPs from Netbi names
file="$1"
while read -r line; do
smbutil status "$line"
@colehocking
colehocking / diffstr.sh
Created October 4, 2018 17:05
Compare strings in 2 files; output the difference to 3rd file
#!/bin/bash
# Find a list of strings in OG_LIST in OTHER LIST; export to FINAL_LIST
OG_LIST=$1
OTHER_LIST=$2
FINAL_LIST=$3
diff -iEwBay --strip-trailing-cr $OG_LIST $OTHER_LIST | grep -v "|" | grep -v "<" | grep -v ">" | awk '{print $1 " " $2}' > $FINAL_LIST
@colehocking
colehocking / getExpDate.sh
Created October 4, 2018 16:56
Get AWS Domain Expiration Date
#!/bin/bash
declare -a domain_list=( $(aws route53domains list-domains | jq -r .Domains[].DomainName) )
for domain in "${domain_list[@]}"
do
# Returns date in unix timestamp
date_unix=$(aws route53domains get-domain-details --domain-name ${domain} | jq -r .ExpirationDate)
date -r ${date_unix}
done
@colehocking
colehocking / getDomains.sh
Created October 4, 2018 16:54
Get AWS Domains
#!/bin/bash
# Gather AWS Domain info
declare -a domain_list=( $(aws route53domains list-domains | jq -r .Domains[].DomainName) )
for domain in "${domain_list[@]}"
do
echo ${domain}
echo "Admin Contact:"
@colehocking
colehocking / dumpClean.py
Created July 11, 2018 15:51
dumpClean: the mighty nested JSON object expander!
def dumpClean(obj):
"""
Recursive function to clean the output of deeply nested dicts/lists
"""
if type(obj) == dict:
for k, v in obj.items():
# if the object has an iterable attribute; keep pulling it apart
if hasattr(v, '__iter__'):
print("%s : %s" % (k, dumpClean(v)))
else:
#######################
## Github Cheatsheet ##
#######################
# Git Global Setup #
git config --global user.name "Cole Hocking"
git config --global user.email "<my-email-addr>"
# Token Authentication #
( Settings --> <> Developer Settings --> Personal Access Tokens)
#!/bin/bash
# Installation script to load homebrew
# -- Cole Hocking
# -----------------------------------------------------------------------------
# Verify Homebrew installation for package management
# Docs: https://brew.sh/
go_brew() {
echo "Checking for Homebrew package management tool..."