Skip to content

Instantly share code, notes, and snippets.

@briantissue
briantissue / gist:d0243549e58f6cd01660128f1f955dc4
Created May 27, 2021 20:07
NMAP Scans For Firewalls Check
#!/bin/bash
# Written by Brian Tissue May 2021
> nmapresults.txt
for HOST in `cat hosts_scan|grep -v ^#`; do echo ${HOST}; nmap -v ${HOST} | grep -i ${HOST} | grep -i open ; done >> /home/scanner/nmapresults.txt
/usr/sbin/sendmail [email protected] < /home/scanner/nmapresults.txt
/usr/sbin/sendmail [email protected] < /home/scanner/nmapresults.txt
@briantissue
briantissue / monitor-server-icmp.sh
Created January 3, 2019 14:15
Monitor Server Availability that doesn't run a webserver; ICMP Checks.
#!/bin/bash
[email protected]
[email protected]
SERVER=fqdnoripaddress
PAUSE=300
FAILED=0
DEBUG=0
while true
do
@briantissue
briantissue / monitor-website-systemdaemon.sh
Last active January 3, 2019 14:11
Monitor a web server as a system daemon; Send notification on Down and when the site comes up
#!/bin/bash
[email protected]
[email protected]
SERVER=https://servertomonitor.domain.com
PAUSE=300 # Checks this server every 5 minutes
FAILED=0
DEBUG=0
while true
do
#!/bin/bash
# Program name: monitor-website.sh
# Written by Brian Tissue August 30th 2018
if [ "$(whoami)" != "root" ]; then
echo "Not running as root. Exiting..."
echo "Please use sudo -s then run this script again as root."
exit 0
else
echo "Running as root. Good"
@briantissue
briantissue / Favorite PS1 Prompt
Created September 20, 2018 18:54
favorite PS1 Prompt
PS1="\n\[\e[1;30m\][$$:$PPID - \j:\!\[\e[1;30m\]]\[\e[0;36m\] \T \[\e[1;30m\][\[\e[1;34m\]\u@\H\[\e[1;30m\]:\[\e[0;37m\]${SSH_TTY:-o} \[\e[0;32m\]+${SHLVL}\[\e[1;30m\]] \[\e[1;37m\]\w\[\e[0;37m\] \n\$ "
@briantissue
briantissue / getdebs.sh
Last active May 17, 2017 14:28
Ubuntu Air-Gapped Servers Package Retrieval
#!/bin/bash
# Used for Airgapped Ubuntu Servers; downloads package and required dependencies
# Just SCP them over to the server that needs them. Ensure OS/Kernel is the same on both.
# Feel free to comment if you have a suggestion to improve the script
read -p "Please enter the package name you would like to look for: " packagesearch
apt-cache search "$packagesearch"
read -p "Please enter the verified package name you would like to download: " package
@briantissue
briantissue / lxc-static-ip.sh
Created May 12, 2017 14:43
Linux Container Static IP address Assignment
#!/bin/bash
# Script by Brian Tissue
# Used to assign static IP addresses to LXC containers
LXCPATH='/var/lib/lxc'
if [ "$(whoami)" != "root" ]; then
echo "Not running as root. I told you that you needed to be root, come on man..."
echo "Please use su -s then run this script again as root."
exit 0
@briantissue
briantissue / Block Source IP Addresses (UFW)
Created December 22, 2016 17:55
This script allows you to quickly block source IP addresses, say during an attempted attack with Ubuntu's UFW
#!/bin/bash
# Check if root
if [ "$(whoami)" != "root" ]; then
echo "Not running as root. Exiting..."
exit 0
else
echo "Editing and Reviewing UFW Firewall Entries"
fi
sudo ufw status numbered
@briantissue
briantissue / gist:55151baf5adad45fd6d2
Created March 26, 2015 13:16
Find Users W/User Input
#!/bin/bash
read -p "Enter UserID: " userid
touch find-$userid.txt
for HOST in `cat ../server_list|grep -v ^#`; do echo ${HOST}; ssh ${HOST} "hostname;cat /etc/passwd | grep -i $userid"; echo ""; done >> find-$
for HOST in `cat ../server_list2|grep -v ^#`; do echo ${HOST}; ssh ${HOST} "hostname;cat /etc/passwd |grep -i $userid"; echo ""; done >$
read -p "Press [Enter] key to view the number of servers $userid resides..."
cat find-$userid.txt | grep -i $userid | wc -l
read -p "End of script..."
@briantissue
briantissue / gist:c944e00f4e0888438c87
Last active August 29, 2015 14:14
Use Audit Log To Find Public IP Addresses Hitting RHEL v7.0 Box w/SELINUX
#!/bin/bash
# Daily report of IP addresses that have hit the server
# This script will filter out the private IP addresses
# You could use this script to generate a report for white-lists; or auditing purposes
# Check if root
if [ "$(whoami)" != "root" ]; then
echo "Not running as root. Exiting..."
exit 0
else