Skip to content

Instantly share code, notes, and snippets.

View forestbaker's full-sized avatar

input - process - output forestbaker

View GitHub Profile
@forestbaker
forestbaker / apache2_reminders
Last active November 20, 2015 06:30
Apache2 reminders
The /etc/apache2/httpd.conf is empty in Ubuntu, because it is there for historic reasons
Apache2 user options should go into a new *.conf-file inside /etc/apache2/conf.d/
httpd.conf or apache2.conf may get overwritten during an update
To make sure the above works, check that /etc/apache2/apache2.conf contains the following lines:
Include conf.d/
In Apache 2.4+ the user configuration directory is /etc/apache2/conf-available/
Use a2enconf FILENAME_WITHOUT_SUFFIX to enable the new configuration file, or manually create a symlink in /etc/apache2/conf-enabled/
@forestbaker
forestbaker / asteriskExtract
Last active November 20, 2015 05:16
extract all extensions, usernames and passwords from the asterisk sip.conf file
# this will extract all extensions, usernames and passwords from the asterisk sip.conf file
# Remove the -- from egrep to see the relation of username to pass
egrep -B2 'username=....' /etc/asterisk/sip.conf | egrep -v 'host|vmexten|--' | wc -l
@forestbaker
forestbaker / fgbg256
Created September 14, 2015 21:24
Displays 256 colors
for fgbg in 38 48 ; do #Foreground/Background
for color in {0..256} ; do #Colors
#Display the color
echo -en "\e[${fgbg};5;${color}m ${color}\t\e[0m"
#Display 10 colors per lines
if [ $((($color + 1) % 10)) == 0 ] ; then
echo #New line
fi
done
echo #New line
@forestbaker
forestbaker / fgbg16
Created September 14, 2015 21:26
displays 16 colors
for clbg in {40..47} {100..107} 49 ; do
#Foreground
for clfg in {30..37} {90..97} 39 ; do
#Formatting
for attr in 0 1 2 4 5 7 ; do
#Print the result
echo -en "\e[${attr};${clbg};${clfg}m ^[${attr};${clbg};${clfg}m \e[0m"
done
echo #Newline
done
@forestbaker
forestbaker / high_perfomance_while.sh
Last active December 5, 2015 02:11
performance shell scripting
# The first method opens file.txt, writes one line, then closes file.txt. Then repeats those three steps 100 times
# The second method opens file.txt, writes 100 lines and closes file.txt
#!/usr/bin/sh
# typical use of a while loop -
# while $count is less than or equal to 100.
# append the value of $count to file.txt
count=1
@forestbaker
forestbaker / mysql_password_reset
Last active November 20, 2015 06:42
reset mysql password for root user
service mysql stop
mysqld_safe --skip-grant-tables > /dev/null 2>&1 &
# wait for previous command to complete
mysql -u root -e "use mysql; update user set password=PASSWORD('NEW-PASSWORD') where user='root'; flush privileges;"
service mysql start
@forestbaker
forestbaker / bad_logins_today
Last active November 20, 2015 07:16
display IP's that unsuccessfully attempted to login 5 or more times,
# original - this is all bad logins - ever!
lastb -i | grep -Po '\b(?!255)(?:\d{1,3}\.){3}(?!255)\d{1,3}\b' | sort | uniq -c | awk '{ if ($1 >= 5) print $2; }'
# early prototype - this works - but returns words
lastb -i | awk '{ print $3 }' | sort | uniq -c | awk '{ if ($1 >= 5) print $2; }'
# ah ha! this filters out the blank line and date/time stamp that was causing the words to appear
lastb -i | egrep -v '^$|btmp' | awk '{ print $3 }' | sort | uniq -c | awk '{ if ($1 >= 5) print $2; }'
@forestbaker
forestbaker / apache2_stuff
Last active November 24, 2015 19:47
apache2 commands and information
# removes stuff I didn't want to read
apache2ctl status | grep -v '\.\.' | grep -v '^\"' | grep -v 'Scoreboard'
@forestbaker
forestbaker / sharkie
Created September 22, 2015 18:27
tshark - capture packets on bond0 interface containing "REGISTER" for 60 seconds
# captures packets on bond0 interface containing "REGISTER" for 60 seconds
timeout 60 tshark -i bond0 -R sip.CSeq.method=="REGISTER"
# more tuning
@forestbaker
forestbaker / favorite_flavorites
Last active November 20, 2015 06:34
favorite flavorites
# # Includes perfect date perfected. The uses go beyond backups, beyond space and time ... ok not time.
# # Creates a directory structure of ./YYYY/mm/dd/HH/MM/SS
mkdir -p "$(date '+%Y/%m/%d/%H/%M/%S')"
# enDIRing elegant epoch
# # -p is optional - unless co-processing!
# # the " and ' are also optional, but "'safer'"
# # for scripting, do set the epoch in a variable, reference that variable - write once read many and yer done!
mkdir -p "$(date '+%s')"