Skip to content

Instantly share code, notes, and snippets.

View colehocking's full-sized avatar

Cole Hocking colehocking

  • Colorado
View GitHub Profile
@colehocking
colehocking / gimme_a_var.sh
Created January 3, 2019 19:23
generate a random variable of length 0-10
#!/bin/bash
# Generate a random variable of length 0-10
head -c 500 /dev/urandom | LC_ALL=C tr -dc 'a-zA-Z0-9~!@#$%^&*_-' | fold -w $((RANDOM%10)) | head -n 1
@colehocking
colehocking / text_calc.py
Created December 23, 2018 20:25
Get the summation of dollar amounts found in a text file
#!/usr/bin/env python
# Calculate dollar values of a text file with python
# -- Cole Hocking
import re
from sys import argv, exit
import os.path as opath
def validateFile(filei):
@colehocking
colehocking / ntp_drift_slack_alert.sh
Last active April 30, 2020 22:08
Send slack alert if Docker logs on Ubuntu server indicate NTP drifting has occurred.
#!/bin/bash
# Send a slack notification if docker logs indicate an NTP time drift
# -- Cole Hocking
# Should be run in a cron job that runs every 24 hours
# Grab the docker container ID dynamically; in case the ID changes
# Update: This can be statically assigned to the container NAME: 'IMAGE_NAME'
# This also assumes only one docker container is running!!
@colehocking
colehocking / remove_tr_period.sh
Created October 15, 2018 18:06
Remove a trailing period from file EOLs
#!/bin/bash
# Remove a trailing period
FILE="$1"
sed -e 's/\.$//g' ${FILE} -i
@colehocking
colehocking / your_loc.sh
Last active February 14, 2024 17:15
Open Google Maps for an IP address
#!/bin/bash
# Open Google Maps for an IP address;
# requires jq
# Replace "firefox" with "open" for OSX
# requires osescript for the "open" command.
IP=$1
COOR=$(curl -s http://ipinfo.io/${IP} | jq .loc)
MAP="https://maps.google.com/maps?q=${COOR}"
@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