Skip to content

Instantly share code, notes, and snippets.

View forestbaker's full-sized avatar

input - process - output forestbaker

View GitHub Profile
@forestbaker
forestbaker / display_interface_ip
Last active October 11, 2015 20:34 — forked from wozoopa/showips
Get ip addresses for each interface in linux with bash function.
declare -rx IFC='/sbin/ifconfig'
showips() {
NAMES=( $($IFC | egrep 'lo|eth|wlan|en' -A 1 | awk -F' ' '{print $1 }' | egrep -v 'inet|-|UP|RX|collisions' | sort -u) )
for i in "${NAMES[@]}"; do
echo "$i has ip address: $($IFC | grep $i -A 1 | grep 'addr' | awk -F' ' '{print $2}' | awk -F':' '{print $2}')"
done
start on runlevel [2345]
stop on runlevel [016]
respawn
respawn limit 10 10
kill signal INT
kill timeout 20
normal exit 0 TERM INT
@forestbaker
forestbaker / hashgen-function
Created October 11, 2015 20:36 — forked from metachris/hashgen-function
bash hash generator function
# Simple Bash Hash Generator
#
# Author: Chris Hager <chris@linuxuser.at>
#
# Put the `hashgen` method in your `.functions` file and source it from your `.bash_profile`
#
# Usage: hashgen [type] [#chars]
#
# Optional argument `type`:
#
@forestbaker
forestbaker / gist:eafb82d907aabe3369dd
Created October 11, 2015 20:36 — forked from chadfurman/gist:5298b4c3c63b36412083
poodle checking bash script
#!/bin/bash
ciphers=`nmap --script ssl-enum-ciphers -p 443 $1`
echo "$ciphers" | grep -q "SSLv3: No supported ciphers found"
if [ $? -eq 0 ];then
echo "Cipher not supported. No poodles.";
exit 1 # cipher not found
fi
echo "Cipher supported. Poodles.";
@forestbaker
forestbaker / irc
Created October 11, 2015 20:44 — forked from schmunsler/irc
Bash 1-liner IRC client
#/bin/bash
# Fully functional IRC client. Takes server as arg, raw IRC commands on stdin, outputs full transaction labelled for downstream filters
{ { tee >(sed 's/^/< /' >&4) <&3 | sed -un 's/^PING/PONG/p' & cat ;} | tee >(sed 's/^/> /' >&4) >&3 ;} 3<>/dev/tcp/$1/6667 4>&1
@forestbaker
forestbaker / bash_commands.txt
Created October 11, 2015 21:08 — forked from corbanb/bash_commands.txt
helpful bash commands
I have marked with a * those which I think are absolutely essential
Items for each section are sorted by oldest to newest. Come back soon for more!
BASH
* In bash, 'ctrl-r' searches your command history as you type
- Input from the commandline as if it were a file by replacing
'command < file.in' with 'command <<< "some input text"'
- '^' is a sed-like operator to replace chars from last command
'ls docs; ^docs^web^' is equal to 'ls web'. The second argument can be empty.
* '!!:n' selects the nth argument of the last command, and '!$' the last arg
@forestbaker
forestbaker / cmd
Created October 11, 2015 21:10 — forked from crittelmeyer/cmd
A bash script to quickly create new bash scripts. It's scriptception.
#!/bin/bash -e
filename=$1
script_root=/usr/bin
editor=vi
createScriptIfItDoesntExist() {
if [ ! -f $1 ]; then
touch $1
chmod +x $1
#!/bin/bash
# Let it Rain!
# Copyright (C) 2011, 2013 by Yu-Jie Lin
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
_
_._ _..._ .-', _.._(`))
'-. ` ' /-._.-' ',/
) \ '.
/ _ _ | \
| a a / |
\ .-. ;
'-('' ).-' ,' ;
'-; | .'
\ \ /
#!/bin/bash
# generate a number of files with random sizes in a range
min=1 # min size (MB)
max=10 # max size (MB)
nofiles=20 # number of files
for i in `eval echo {1..$nofiles}`
do
dd bs=1M count=$(($RANDOM%max + $min)) if=/dev/urandom of=./files/file$i