From 5eaabf4716516047d26fcd7f0629b12e379bf28b Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Thu, 2 Feb 2017 22:35:24 -0800 Subject: [PATCH 01/10] Basic tool installer. --- bin/install_tool | 67 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 bin/install_tool diff --git a/bin/install_tool b/bin/install_tool new file mode 100755 index 0000000..d0fe696 --- /dev/null +++ b/bin/install_tool @@ -0,0 +1,67 @@ +#!/bin/bash + +set -ue + +REINSTALL=0 + +while getopts -- "-:" a ; do + case "${a}" in + -) + case "${OPTARG}" in + reinstall) + REINSTALL=1 + ;; + *) + echo "Unknown long option ${OPTARG}" >/dev/stderr + exit 1 + ;; + esac + esac +done + +if [ $# -ne 1 ] ; then + echo "Usage: ${0} " >/dev/stderr + exit 1 +fi +TOOL=${1} + +function install_pkgs { + if [ `id -u` -ne "0" ] ; then + echo "Unable to install packages, please ensure these are installed." >/dev/stderr + echo $* + return 0 + fi + apt-get -y install $* +} + +DESTDIR="${HOME}/tools/${TOOL}" + +if [ -d ${DESTDIR} ] ; then + if [ ${REINSTALL} -eq 1 ] ; then + rm -ri ${DESTDIR} + else + echo "${DESTDIR} exists but not reinstalling." >/dev/stderr + exit 1 + fi +fi + +mkdir -p ${DESTDIR} + +case ${TOOL} in + john) + install_pkgs libssl-dev git build-essential yasm libgmp-dev libpcap-dev \ + pkg-config libbz2-dev libopenmpi-dev openmpi-bin libnss-dev \ + libkrb5-dev libgmp-dev + jtemp=`mktemp -d` + git clone https://github.com/magnumripper/JohnTheRipper.git ${jtemp}/john + cd ${jtemp}/john/src + ./configure && make -sj2 + cp -r ${jtemp}/john/run/* ${DESTDIR} + rm -rf ${jtemp} + ;; + *) + echo "Unknown tool: ${TOOL}" >/dev/stderr + rmdir ${DESTDIR} + exit 1 + ;; +esac From 58ae338ece8009c80ea83b91dbf5f8315eaf575c Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Fri, 3 Feb 2017 09:06:18 -0800 Subject: [PATCH 02/10] Fix color for colorcolumn. --- dotfiles/vimrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotfiles/vimrc b/dotfiles/vimrc index 59a7123..7610e9d 100644 --- a/dotfiles/vimrc +++ b/dotfiles/vimrc @@ -148,4 +148,4 @@ autocmd Syntax * syn match ExtraWhitespace /\s\+$\| \+\ze\t/ containedin=ALL " Color column at end of lines set colorcolumn=+1 -highlight ColorColumn ctermbg=lightgrey guibg=lightgrey +highlight ColorColumn ctermbg=black guibg=lightgrey From e7c797e1950f9f448847e92355d1905f82e88096 Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Fri, 3 Feb 2017 09:08:32 -0800 Subject: [PATCH 03/10] Update install_tool for john configs. --- bin/install_tool | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/install_tool b/bin/install_tool index d0fe696..4fb9b46 100755 --- a/bin/install_tool +++ b/bin/install_tool @@ -58,6 +58,9 @@ case ${TOOL} in ./configure && make -sj2 cp -r ${jtemp}/john/run/* ${DESTDIR} rm -rf ${jtemp} + # Persistent files + mkdir -p ${HOME}/.john + ln -sf ${HOME}/.john/* ${DESTDIR} ;; *) echo "Unknown tool: ${TOOL}" >/dev/stderr From 4d196a0b7549bba68a00762e8cffcc16f556b5fb Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Fri, 3 Feb 2017 09:16:24 -0800 Subject: [PATCH 04/10] install_tool fixes. --- bin/install_tool | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bin/install_tool b/bin/install_tool index 4fb9b46..c2059c8 100755 --- a/bin/install_tool +++ b/bin/install_tool @@ -19,6 +19,9 @@ while getopts -- "-:" a ; do esac done +shift $(($OPTIND-1)) +echo $* + if [ $# -ne 1 ] ; then echo "Usage: ${0} " >/dev/stderr exit 1 @@ -27,8 +30,10 @@ TOOL=${1} function install_pkgs { if [ `id -u` -ne "0" ] ; then - echo "Unable to install packages, please ensure these are installed." >/dev/stderr - echo $* + sudo apt-get -y install $* || ( + echo "Unable to install packages, please ensure these are installed." >/dev/stderr + echo $* + false ) return 0 fi apt-get -y install $* @@ -45,26 +50,25 @@ if [ -d ${DESTDIR} ] ; then fi fi -mkdir -p ${DESTDIR} - case ${TOOL} in john) install_pkgs libssl-dev git build-essential yasm libgmp-dev libpcap-dev \ - pkg-config libbz2-dev libopenmpi-dev openmpi-bin libnss-dev \ + pkg-config libbz2-dev libopenmpi-dev openmpi-bin libnss3-dev \ libkrb5-dev libgmp-dev jtemp=`mktemp -d` git clone https://github.com/magnumripper/JohnTheRipper.git ${jtemp}/john cd ${jtemp}/john/src ./configure && make -sj2 + mkdir -p ${DESTDIR} cp -r ${jtemp}/john/run/* ${DESTDIR} rm -rf ${jtemp} # Persistent files mkdir -p ${HOME}/.john + touch ${HOME}/.john/john.pot ln -sf ${HOME}/.john/* ${DESTDIR} ;; *) echo "Unknown tool: ${TOOL}" >/dev/stderr - rmdir ${DESTDIR} exit 1 ;; esac From 2701a9e8f0afe8a98702aa72a7d23c91f5513a6b Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Fri, 3 Feb 2017 17:29:21 -0800 Subject: [PATCH 05/10] Wordlist script. --- bin/install_tool | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/install_tool b/bin/install_tool index c2059c8..984bfc5 100755 --- a/bin/install_tool +++ b/bin/install_tool @@ -67,6 +67,18 @@ case ${TOOL} in touch ${HOME}/.john/john.pot ln -sf ${HOME}/.john/* ${DESTDIR} ;; + wordlists) + mkdir -p ${DESTDIR} + wget -q -O ${DESTDIR}/rockyou.txt.bz2 \ + http://downloads.skullsecurity.org/passwords/rockyou.txt.bz2 + bunzip2 ${DESTDIR}/rockyou.txt.bz2 + wget -q -O ${DESTDIR}/phpbb.txt.bz2 \ + http://downloads.skullsecurity.org/passwords/phpbb.txt.bz2 + bunzip2 ${DESTDIR}/phpbb.txt.bz2 + wget -q -O ${DESTDIR}/hak5.txt.bz2 \ + http://downloads.skullsecurity.org/passwords/hak5.txt.bz2 + bunzip2 ${DESTDIR}/hak5.txt.bz2 + ;; *) echo "Unknown tool: ${TOOL}" >/dev/stderr exit 1 From e94f1caab362d2ed0edb0474b7e808b64d035ecd Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Sat, 4 Feb 2017 07:53:38 -0800 Subject: [PATCH 06/10] Update install_tool script. --- bin/install_tool | 11 +++++++++-- dotfiles/zsh_custom/analyze_new_cluster.sh | 22 ++++++++++++++++++++++ dotfiles/zsh_custom/delete_old_cluster.sh | 3 +++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100755 dotfiles/zsh_custom/analyze_new_cluster.sh create mode 100755 dotfiles/zsh_custom/delete_old_cluster.sh diff --git a/bin/install_tool b/bin/install_tool index 984bfc5..6e09593 100755 --- a/bin/install_tool +++ b/bin/install_tool @@ -3,6 +3,7 @@ set -ue REINSTALL=0 +PACKAGES=1 while getopts -- "-:" a ; do case "${a}" in @@ -11,6 +12,9 @@ while getopts -- "-:" a ; do reinstall) REINSTALL=1 ;; + no-packages) + PACKAGES=0 + ;; *) echo "Unknown long option ${OPTARG}" >/dev/stderr exit 1 @@ -20,7 +24,6 @@ while getopts -- "-:" a ; do done shift $(($OPTIND-1)) -echo $* if [ $# -ne 1 ] ; then echo "Usage: ${0} " >/dev/stderr @@ -29,9 +32,13 @@ fi TOOL=${1} function install_pkgs { + if [ ${PACKAGES} -eq 0 ] ; then + return 0 + fi if [ `id -u` -ne "0" ] ; then sudo apt-get -y install $* || ( - echo "Unable to install packages, please ensure these are installed." >/dev/stderr + echo -n "Unable to install packages, please ensure these " >/dev/stderr + echo "are installed, then run with --no-packages." >/dev/stderr echo $* false ) return 0 diff --git a/dotfiles/zsh_custom/analyze_new_cluster.sh b/dotfiles/zsh_custom/analyze_new_cluster.sh new file mode 100755 index 0000000..23a2c1a --- /dev/null +++ b/dotfiles/zsh_custom/analyze_new_cluster.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +echo 'This script will generate minimal optimizer statistics rapidly' +echo 'so your system is usable, and then gather statistics twice more' +echo 'with increasing accuracy. When it is done, your system will' +echo 'have the default level of optimizer statistics.' +echo + +echo 'If you have used ALTER TABLE to modify the statistics target for' +echo 'any tables, you might want to remove them and restore them after' +echo 'running this script because they will delay fast statistics generation.' +echo + +echo 'If you would like default statistics as quickly as possible, cancel' +echo 'this script and run:' +echo ' "/opt/metasploit-framework/embedded/bin/vacuumdb" --all --analyze-only' +echo + +"/opt/metasploit-framework/embedded/bin/vacuumdb" --all --analyze-in-stages +echo + +echo 'Done' diff --git a/dotfiles/zsh_custom/delete_old_cluster.sh b/dotfiles/zsh_custom/delete_old_cluster.sh new file mode 100755 index 0000000..fd6f0a0 --- /dev/null +++ b/dotfiles/zsh_custom/delete_old_cluster.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +rm -rf '/home/david/.msf4/db.prev' From 59b0bca33c0f5825178b1d0477513db7f6cce384 Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Sat, 4 Feb 2017 07:54:15 -0800 Subject: [PATCH 07/10] Delete unneeded scripts. --- dotfiles/zsh_custom/analyze_new_cluster.sh | 22 ---------------------- dotfiles/zsh_custom/delete_old_cluster.sh | 3 --- 2 files changed, 25 deletions(-) delete mode 100755 dotfiles/zsh_custom/analyze_new_cluster.sh delete mode 100755 dotfiles/zsh_custom/delete_old_cluster.sh diff --git a/dotfiles/zsh_custom/analyze_new_cluster.sh b/dotfiles/zsh_custom/analyze_new_cluster.sh deleted file mode 100755 index 23a2c1a..0000000 --- a/dotfiles/zsh_custom/analyze_new_cluster.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh - -echo 'This script will generate minimal optimizer statistics rapidly' -echo 'so your system is usable, and then gather statistics twice more' -echo 'with increasing accuracy. When it is done, your system will' -echo 'have the default level of optimizer statistics.' -echo - -echo 'If you have used ALTER TABLE to modify the statistics target for' -echo 'any tables, you might want to remove them and restore them after' -echo 'running this script because they will delay fast statistics generation.' -echo - -echo 'If you would like default statistics as quickly as possible, cancel' -echo 'this script and run:' -echo ' "/opt/metasploit-framework/embedded/bin/vacuumdb" --all --analyze-only' -echo - -"/opt/metasploit-framework/embedded/bin/vacuumdb" --all --analyze-in-stages -echo - -echo 'Done' diff --git a/dotfiles/zsh_custom/delete_old_cluster.sh b/dotfiles/zsh_custom/delete_old_cluster.sh deleted file mode 100755 index fd6f0a0..0000000 --- a/dotfiles/zsh_custom/delete_old_cluster.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -rm -rf '/home/david/.msf4/db.prev' From f3b6be53e03b17adabc1bd981d4e9a21dfe5d29d Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Sat, 4 Feb 2017 08:04:26 -0800 Subject: [PATCH 08/10] Add metasploit tab completion. --- dotfiles/zsh_custom/plugins/metasploit/metasploit.plugin.zsh | 0 dotfiles/zshrc | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 dotfiles/zsh_custom/plugins/metasploit/metasploit.plugin.zsh diff --git a/dotfiles/zsh_custom/plugins/metasploit/metasploit.plugin.zsh b/dotfiles/zsh_custom/plugins/metasploit/metasploit.plugin.zsh new file mode 100644 index 0000000..e69de29 diff --git a/dotfiles/zshrc b/dotfiles/zshrc index b1f4c9d..58c7d1c 100644 --- a/dotfiles/zshrc +++ b/dotfiles/zshrc @@ -29,7 +29,7 @@ if [ -d $HOME/.oh-my-zsh ] ; then ZSH=$HOME/.oh-my-zsh ZSH_THEME="matir" ZSH_CUSTOM="$HOME/.zsh_custom" - plugins=(git encode64 gpg-agent pep8 pip python tmux urltools extract sudo virsh virtualenv jekyll) + plugins=(git encode64 gpg-agent pep8 pip python tmux urltools extract sudo virsh virtualenv jekyll metasploit) test -f /usr/share/virtualenvwrapper/virtualenvwrapper.sh && plugins+=(virtualenvwrapper) source $ZSH/oh-my-zsh.sh unset ZSH_THEME From c8c954617e328ee2bf7fe907690882e546cf51dd Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Sat, 4 Feb 2017 12:29:25 -0800 Subject: [PATCH 09/10] gcloud in tools. --- bin/install_tool | 8 ++++++++ dotfiles/env | 5 +---- .../zsh_custom/plugins/gcloud/gcloud.plugin.zsh | 13 +++++++++++++ dotfiles/zshrc | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100755 dotfiles/zsh_custom/plugins/gcloud/gcloud.plugin.zsh diff --git a/bin/install_tool b/bin/install_tool index 6e09593..e9cf302 100755 --- a/bin/install_tool +++ b/bin/install_tool @@ -86,6 +86,14 @@ case ${TOOL} in http://downloads.skullsecurity.org/passwords/hak5.txt.bz2 bunzip2 ${DESTDIR}/hak5.txt.bz2 ;; + gcloud) + gtemp=`mktemp -d` + gbase="https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/" + gsdk="google-cloud-sdk-142.0.0-linux-x86_64.tar.gz" + wget -q -O /tmp/gcloud.tar.gz \ + "${gbase}${gsdk}" + tar zxf /tmp/gcloud.tar.gz --strip-components=1 -C ${DESTDIR} + ;; *) echo "Unknown tool: ${TOOL}" >/dev/stderr exit 1 diff --git a/dotfiles/env b/dotfiles/env index 0b62791..c1b83c7 100644 --- a/dotfiles/env +++ b/dotfiles/env @@ -4,18 +4,15 @@ umask 027 ulimit -c unlimited # Paths and preferences -export PATH="$HOME/bin:/sbin:/usr/sbin:$PATH" export PYTHONPATH="$HOME/.python:$PYTHONPATH" export GOPATH="$HOME/Projects/Go" +export PATH="$HOME/bin:/sbin:/usr/sbin:$PATH:$GOPATH/bin" export VISUAL=vim export EDITOR=vim export DEBEMAIL="david@systemoverlord.com" export DEBFULLNAME="David Tomaschik" export LESS="-MR" -# Unconditional because /bin/sh sucks -export PATH="$PATH:$HOME/.gce/google-cloud-sdk/bin:$HOME/bin/genymotion:$HOME/bin/genymotion/tools:$HOME/bin/google_appengine:$HOME/bin/go_appengine:$HOME/bin/google-cloud-sdk/bin:$GOPATH/bin" - # Fix gnome-terminal if [[ $TERM == "xterm" && $COLORTERM == "gnome-terminal" ]] ; then export TERM="xterm-256color" diff --git a/dotfiles/zsh_custom/plugins/gcloud/gcloud.plugin.zsh b/dotfiles/zsh_custom/plugins/gcloud/gcloud.plugin.zsh new file mode 100755 index 0000000..3cfb6a7 --- /dev/null +++ b/dotfiles/zsh_custom/plugins/gcloud/gcloud.plugin.zsh @@ -0,0 +1,13 @@ +#!/bin/zsh + +GCL=${HOME}/tools/gcloud + +if [ ! -d ${GCL} ] ; then + return +fi + +# Add bin to path +export PATH="${PATH}:${GCL}/bin" + +# Load completion +source ${GCL}/completion.zsh.inc diff --git a/dotfiles/zshrc b/dotfiles/zshrc index 58c7d1c..c25e79b 100644 --- a/dotfiles/zshrc +++ b/dotfiles/zshrc @@ -29,7 +29,7 @@ if [ -d $HOME/.oh-my-zsh ] ; then ZSH=$HOME/.oh-my-zsh ZSH_THEME="matir" ZSH_CUSTOM="$HOME/.zsh_custom" - plugins=(git encode64 gpg-agent pep8 pip python tmux urltools extract sudo virsh virtualenv jekyll metasploit) + plugins=(git encode64 gpg-agent pep8 pip python tmux urltools extract sudo virsh virtualenv jekyll metasploit gcloud) test -f /usr/share/virtualenvwrapper/virtualenvwrapper.sh && plugins+=(virtualenvwrapper) source $ZSH/oh-my-zsh.sh unset ZSH_THEME From 70cc5c5218aa0b4a76968700e576e5918db9818d Mon Sep 17 00:00:00 2001 From: David Tomaschik Date: Sat, 4 Feb 2017 16:48:40 -0800 Subject: [PATCH 10/10] kubectl completion. --- dotfiles/zsh_custom/plugins/gcloud/gcloud.plugin.zsh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dotfiles/zsh_custom/plugins/gcloud/gcloud.plugin.zsh b/dotfiles/zsh_custom/plugins/gcloud/gcloud.plugin.zsh index 3cfb6a7..8a58b12 100755 --- a/dotfiles/zsh_custom/plugins/gcloud/gcloud.plugin.zsh +++ b/dotfiles/zsh_custom/plugins/gcloud/gcloud.plugin.zsh @@ -11,3 +11,7 @@ export PATH="${PATH}:${GCL}/bin" # Load completion source ${GCL}/completion.zsh.inc + +which kubectl 2>/dev/null >&2 && \ + source <(kubectl completion zsh) || \ + true