├── cmd_macros.txt ├── mac ├── mount_sshfs ├── .bash_aliases └── .bashrc ├── useful_scripts ├── mount_sshfs.sh ├── flush_routes.sh ├── cp_pub_key_to_clip.sh ├── gitit.sh ├── checkbashism_readme.txt ├── customizeBT5.sh ├── countdown.sh ├── posix_workarounds.sh ├── fast_rm.sh ├── autoreply.pl ├── init-git.sh ├── youtube.sh ├── install_pianobar.sh ├── progression.rb ├── find_block.sh ├── lock-keyboard-for-baby.pl ├── bt4-joshomise.sh └── checkbashisms.pl ├── git ├── alias_reset2unstage ├── push_to_remote_branch ├── delete_branch_local_and_remote ├── ignore_file_for_now.sh ├── unignore_file_for_now.sh ├── reset-local-git.txt ├── obliterate.sh ├── show_last2_committed_files.sh ├── make_new_git_or_push_existing.sh ├── nuke_remote_origin_restore_from_local.sh ├── .gitignore_global ├── update_branch_from_upstream ├── update_master_from_upstream_simple.sh ├── update_branch_from_upstream_and_push_remote ├── merge_a_contribs_stuff ├── .bash_aliases_git └── clone_all_branches.sh ├── msf ├── run_exe_in_mem.rc.rb ├── run_msftidy_last2commits.sh ├── find_evasions_msf.rb ├── msfconsole.rc ├── svn_install_msf_ubuntu.sh └── irc_nuggets ├── README ├── bash ├── .bash_logout ├── .gittemplate ├── aliases.d │ ├── S90_app_aliases.rc │ └── S10basic_aliases.rc ├── bashrc.d │ ├── S30load_rvm.rc │ ├── S10default_shell_prompt.rc │ ├── K90ssh_agent.rc │ └── S50git_ruby_shell_additions.rc ├── just_proxy.sh ├── functions.d │ ├── S70git_helpers.rc │ ├── S10utils.rc │ ├── S80transfer.sh.rc │ ├── S30proxystate.rc │ └── S20input_output.rc ├── load_drop_directories.rc ├── .bashrc ├── install_bashrc_framework.sh ├── .vimrc ├── .bash_profile ├── README.md └── .gitconfig ├── backgrounds ├── fire.jpg ├── kernel.png ├── matrix.jpg ├── cybersoldier.jpg ├── midnight_tree.jpg ├── hackintosh_wallpaper.png ├── hackintosh_wallpaper_black.png ├── hackintosh_wallpaper_black_upc.png ├── corelan_wallpaper_dark_1440-900.jpg ├── corelan_wallpaper_dark_1680-1050.jpg ├── corelan_wallpaper_dark_1920-1080.jpg └── corelan_wallpaper_dark_1920-1200.jpg ├── debug ├── windbg_workspace_dark.wew ├── set_symbols.bat ├── windbg_dark.cmd ├── launchLazyInWinDBG.cmd ├── launchLazyInWinDBGWin8.cmd ├── README.md ├── lazy.wds └── lazy-Win8.wds ├── .screenrc ├── ssh ├── config ├── burner_rsa.pub ├── port_forward.sh └── mount_sshfs.sh ├── apache2 └── no-gzip.conf ├── dot_config ├── pianobar │ └── config ├── deluge │ └── gtkui.conf └── gpg.pub ├── .tmux.conf ├── esxi ├── ssh_mount.sh ├── usage-my-vmware-cmd.txt ├── install_vmware_tools_ubuntu.sh ├── package_vmx.sh └── ghetto-esxi-linked-clones.sh ├── ruby └── irbrc ├── ruby_dev_env ├── ruby_instrospection.rb ├── jcran_guide.txt └── make_dope_ruby_dev_env.sh ├── zsh └── .zshrc └── osx └── setup_new_box.sh /cmd_macros.txt: -------------------------------------------------------------------------------- 1 | ls=dir 2 | ifconfig=ipconfig 3 | -------------------------------------------------------------------------------- /mac/mount_sshfs: -------------------------------------------------------------------------------- 1 | gits/env-customization/ssh/mount_sshfs.sh -------------------------------------------------------------------------------- /useful_scripts/mount_sshfs.sh: -------------------------------------------------------------------------------- 1 | gits/env-customization/ssh/mount_sshfs.sh -------------------------------------------------------------------------------- /git/alias_reset2unstage: -------------------------------------------------------------------------------- 1 | git config --global alias.unstage 'reset HEAD --' 2 | -------------------------------------------------------------------------------- /msf/run_exe_in_mem.rc.rb: -------------------------------------------------------------------------------- 1 | execute -H -i -c -m -d calc.exe -f bin.exe -a "args" -------------------------------------------------------------------------------- /useful_scripts/flush_routes.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ip addr flush dev eth0 4 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Place for environment customization scripts, rc's, bashrc's, etc etc 2 | -------------------------------------------------------------------------------- /bash/.bash_logout: -------------------------------------------------------------------------------- 1 | if [ -n "$SSH_AGENT_PID" ];then 2 | kill $SSH_AGENT_PID 3 | fi 4 | -------------------------------------------------------------------------------- /useful_scripts/cp_pub_key_to_clip.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | xclip -sel clip < ~/.ssh/id_rsa.pub 3 | -------------------------------------------------------------------------------- /useful_scripts/gitit.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | git pull 3 | git add -A 4 | git commit -m "$1" 5 | git push 6 | -------------------------------------------------------------------------------- /backgrounds/fire.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/fire.jpg -------------------------------------------------------------------------------- /useful_scripts/checkbashism_readme.txt: -------------------------------------------------------------------------------- 1 | This version is patched for "trap ERR" (provided by Sami Kerola). 2 | -------------------------------------------------------------------------------- /backgrounds/kernel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/kernel.png -------------------------------------------------------------------------------- /backgrounds/matrix.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/matrix.jpg -------------------------------------------------------------------------------- /backgrounds/cybersoldier.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/cybersoldier.jpg -------------------------------------------------------------------------------- /backgrounds/midnight_tree.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/midnight_tree.jpg -------------------------------------------------------------------------------- /debug/windbg_workspace_dark.wew: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/debug/windbg_workspace_dark.wew -------------------------------------------------------------------------------- /git/push_to_remote_branch: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | thebranch="$1" 4 | 5 | git checkout $thebranch 6 | git push origin $thebranch 7 | -------------------------------------------------------------------------------- /backgrounds/hackintosh_wallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/hackintosh_wallpaper.png -------------------------------------------------------------------------------- /.screenrc: -------------------------------------------------------------------------------- 1 | hardstatus on 2 | hardstatus alwayslastline "%{=b}%{G} Screen(s): %{b}%w" 3 | defscrollback 5000 4 | term screen-256color 5 | 6 | -------------------------------------------------------------------------------- /backgrounds/hackintosh_wallpaper_black.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/hackintosh_wallpaper_black.png -------------------------------------------------------------------------------- /backgrounds/hackintosh_wallpaper_black_upc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/hackintosh_wallpaper_black_upc.png -------------------------------------------------------------------------------- /debug/set_symbols.bat: -------------------------------------------------------------------------------- 1 | setx -m _NT_SYMBOL_PATH SRV*c:\symbols\*http://msdl.microsoft.com/download/symbols;SRV*c:\symbols\*http://symbols.mozilla.org/firefox -------------------------------------------------------------------------------- /backgrounds/corelan_wallpaper_dark_1440-900.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/corelan_wallpaper_dark_1440-900.jpg -------------------------------------------------------------------------------- /backgrounds/corelan_wallpaper_dark_1680-1050.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/corelan_wallpaper_dark_1680-1050.jpg -------------------------------------------------------------------------------- /backgrounds/corelan_wallpaper_dark_1920-1080.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/corelan_wallpaper_dark_1920-1080.jpg -------------------------------------------------------------------------------- /backgrounds/corelan_wallpaper_dark_1920-1200.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kernelsmith/env-customization/HEAD/backgrounds/corelan_wallpaper_dark_1920-1200.jpg -------------------------------------------------------------------------------- /debug/windbg_dark.cmd: -------------------------------------------------------------------------------- 1 | "C:\Program Files\Debugging Tools for Windows (x86)\windbg.exe" -WF "C:\Program Files\Debugging Tools for Windows (x86)\windbg_workspace_dark.wew" 2 | -------------------------------------------------------------------------------- /debug/launchLazyInWinDBG.cmd: -------------------------------------------------------------------------------- 1 | "C:\Program Files\Debugging Tools for Windows (x86)\windbg.exe" -WF "c:\windbgScripts\windbg_workspace_dark.wew" -c "$$>< c:\windbgScripts\lazy.wds" 2 | -------------------------------------------------------------------------------- /debug/launchLazyInWinDBGWin8.cmd: -------------------------------------------------------------------------------- 1 | "C:\Program Files\Windows Kits\8.0\Debuggers\x86\windbg.exe" -WF "c:\windbgScripts\windbg_workspace_dark.wew" -c "$$>< c:\windbgScripts\lazy-Win8.wds" 2 | -------------------------------------------------------------------------------- /bash/.gittemplate: -------------------------------------------------------------------------------- 1 | 2 | #Land #1234, fixes blabity blah 3 | 4 | # extended description 5 | 6 | #Fixes the issue mo betta than #1230 did. 7 | 8 | #[FixRM #5678] 9 | #[Closes #1230] 10 | -------------------------------------------------------------------------------- /msf/run_msftidy_last2commits.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | for f in `git diff --stat HEAD~2 | grep '\.rb' | grep -v '\.\.\.'| cut -d '|' -f 1 | cut -d ' ' -f 2`; do echo "[*] Tidying $f" && tools/msftidy.rb "$f";done 4 | -------------------------------------------------------------------------------- /git/delete_branch_local_and_remote: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # $1 is the branch to delete 4 | 5 | # delete local branch 6 | git branch -d $1 7 | # use -D to force delete 8 | 9 | # delete remote branch 10 | git push origin --delete $1 11 | -------------------------------------------------------------------------------- /ssh/config: -------------------------------------------------------------------------------- 1 | Host coolname 2 | Hostname bolivia.coolplace.com 3 | Port 1122 4 | User yourmom 5 | IdentityFile ~/.ssh/moms_rsa 6 | 7 | Host coolername 8 | Hostname coolername.coolerplace.com 9 | User yourdad 10 | PreferredAuthentications publickey 11 | -------------------------------------------------------------------------------- /git/ignore_file_for_now.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | file="$1" 4 | 5 | # So, to temporarily ignore changes in a certain file, run: 6 | git update-index --assume-unchanged $file 7 | # Then when you want to track changes again: 8 | #git update-index --no-assume-unchanged $file 9 | -------------------------------------------------------------------------------- /git/unignore_file_for_now.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | file="$1" 4 | 5 | # So, to temporarily ignore changes in a certain file, run: 6 | #git update-index --assume-unchanged $file 7 | # Then when you want to track changes again: 8 | git update-index --no-assume-unchanged $file 9 | -------------------------------------------------------------------------------- /debug/README.md: -------------------------------------------------------------------------------- 1 | copy the .wew file to "C:\Program Files\Debugging Tools for Windows (x86)\windbg_workspace_dark.wew" 2 | and copy the .cmd file to wherever you want, e.g. the Desktop so you can just double click it. 3 | In Win7 etc, you may want to right-click and run as administrator 4 | -------------------------------------------------------------------------------- /apache2/no-gzip.conf: -------------------------------------------------------------------------------- 1 | # you can modify and put this file in /etc/apache2/conf.d for example 2 | 3 | # for URL paths that begin with "regex" 4 | SetEnvIf Request_URI ^/regex/ no-gzip=1 5 | 6 | # for files that end with ".ext" 7 | # 8 | # SetEnv no-gzip 1 9 | # 10 | -------------------------------------------------------------------------------- /bash/aliases.d/S90_app_aliases.rc: -------------------------------------------------------------------------------- 1 | # 2 | # aliases and soft links to apps 3 | # 4 | 5 | debug "app_aliases.rc" 6 | 7 | alias tl='t timeline -r -l' 8 | alias pastebin='pastebin -l ruby -e N ' 9 | 10 | # For OS X 11 | [ -n "$IS_OSX" ] && alias itunes_real="/Applications/iTunes.app/Contents/MacOS/iTunesX" 12 | -------------------------------------------------------------------------------- /bash/bashrc.d/S30load_rvm.rc: -------------------------------------------------------------------------------- 1 | # 2 | # make sure RVM gets loaded as a function (for system-wide installs) 3 | # 4 | debug "load_rvm" 5 | script="/etc/profile.d/rvm.sh" 6 | # source $script if it's a regular file which is executable and non-zero-length 7 | [ -f "$script" -a -x "$script" -a -s "$script" ] && source $script 8 | -------------------------------------------------------------------------------- /useful_scripts/customizeBT5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | apt-get update 4 | # qemu? terminator if not present already 5 | for pkg in "nvidia-driver smbfs nfs "; do 6 | apt-get -y install $pkg 7 | done 8 | 9 | msfupdate 10 | 11 | # get rc files from github? 12 | # vimrc, bashrc 13 | 14 | # install private key? 15 | 16 | -------------------------------------------------------------------------------- /dot_config/pianobar/config: -------------------------------------------------------------------------------- 1 | user = myemail@mail.com 2 | password = mypass 3 | sort = quickmix_01_name_az 4 | autostart_station = 247782624866357578 5 | ca_bundle = ca_bundle = ~/.config/pianobar/pandora-ca-bundle.crt 6 | # can use this for the .crt: https://gist.github.com/anonymous/cfed4d0b49da8b129dd0 7 | 8 | # save as ~/.config/pianobar/config 9 | -------------------------------------------------------------------------------- /git/reset-local-git.txt: -------------------------------------------------------------------------------- 1 | git reset --hard HEAD (in the git directory) 2 | git clean -f 3 | rm -rf alldirsexcept.git, and maybe that one too 4 | git init 5 | git pull 6 | git remote add origin git@github.com:kernelsmith/msf-shell-mixins.git 7 | make changes, if any, otherwise done 8 | git add . 9 | git status -s 10 | git commit -m "" 11 | git push 12 | -------------------------------------------------------------------------------- /git/obliterate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | file=$1 3 | test -z $file && echo "file required." 1>&2 && exit 1 4 | git filter-branch -f --index-filter "git rm -r --cached $file --ignore-unmatch" --prune-empty --tag-name-filter cat -- --all 5 | git ignore $file 6 | git add .gitignore 7 | git commit -m "Add $file to .gitignore" 8 | echo "Now, if you really mean it, do a: git push --force" 9 | -------------------------------------------------------------------------------- /ssh/burner_rsa.pub: -------------------------------------------------------------------------------- 1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC7cXCJrmtGTeCmOOvRa+hP2kpTXI21J6PVJg3gZGQpDwBR1cyBofw8T5wi+tUDKgN5NnWe2ZeYLttUToAEnDSGWmLzSfrN3rXvbOt2jSXY85Sy+VZS7oUiYVTzdcbWHhjel0Qdz3E2TjYOzBRzf3cWk4rtegYrcDNkfVUN0nmjQrUMruYcYjEj6+wiYLVz4mmvNZJisnorbWhn4yPIBM/Ig5mCiikojAq0/lkCXntEmO2kWpjRn/n8yIwzL83Xra8n0QOgH9F9QWad4IKrm+rvtvffpxTWlNjFpeBIrB3Xjck1bwWeHvfIjYQYd+AjWnJ3pHGhTRxKNCE+9SVOo5HL 2 | -------------------------------------------------------------------------------- /useful_scripts/countdown.sh: -------------------------------------------------------------------------------- 1 | # countdown "00:00:10" # 10 sec 2 | # countdown "00:01:42" # 1 min 42 sec 3 | countdown() 4 | ( 5 | IFS=: 6 | set -- $* 7 | secs=$(( ${1#0} * 3600 + ${2#0} * 60 + ${3#0} )) 8 | while [ $secs -gt 0 ] 9 | do 10 | sleep 1 & 11 | printf "\r%02d:%02d:%02d" $((secs/3600)) $(( (secs/60)%60)) $((secs%60)) 12 | secs=$(( $secs - 1 )) 13 | wait 14 | done 15 | echo 16 | ) 17 | -------------------------------------------------------------------------------- /git/show_last2_committed_files.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | git diff --stat HEAD~2 4 | 5 | # show differences between index and working tree 6 | # that is, changes you haven't staged to commit 7 | # git diff [filename] 8 | # show differences between current commit and index 9 | # that is, what you're about to commit 10 | # git diff --cached [filename] 11 | # show differences between current commit and working tree 12 | # git diff HEAD [filename] 13 | -------------------------------------------------------------------------------- /.tmux.conf: -------------------------------------------------------------------------------- 1 | set -g history-limit 10000 2 | 3 | # Fix copy/paste in vim running inside tmux. Not sure what's happening here but 4 | # this fixes it. Found via this blog post: 5 | # 6 | # http://www.tylercipriani.com/2013/02/09/vim-mac-osx-tmux-clipboard.html 7 | # # 8 | # And it requires doing this first: 9 | # 10 | # $ brew install reattach-to-user-namespace --wrap-pbcopy-and-pbpaste 11 | set-option -g default-command "reattach-to-user-namespace -l zsh" 12 | -------------------------------------------------------------------------------- /bash/aliases.d/S10basic_aliases.rc: -------------------------------------------------------------------------------- 1 | # 2 | # Basic aliases without which one cannot live :) 3 | # 4 | 5 | debug "basic_aliases.rc" 6 | 7 | alias lc='ls --color=auto' 8 | # -F Display (`/') after directories, (`*') after executables, (`@') after symbolic links, 9 | # (`=') after sockets, (`%') after whiteouts, and (`|') after FIFOs. 10 | alias lf='ls -aF' 11 | alias ll='ls -Flah' 12 | alias la='ls -A' 13 | alias l='ls -CF' 14 | alias sudi='sudo -i' 15 | alias suck='sudo -u ks' 16 | alias xclip='xclip -sel clip' -------------------------------------------------------------------------------- /git/make_new_git_or_push_existing.sh: -------------------------------------------------------------------------------- 1 | # It's easiest to first create the repo from your github page 2 | 3 | # 4 | # Create a new repository on the command line 5 | # 6 | touch README.md 7 | git init 8 | git add README.md 9 | git commit -m "first commit" 10 | git remote add origin https://github.com/kernelsmith/repo-name.git 11 | git push -u origin master 12 | 13 | # 14 | # Push an existing repository from the command line 15 | # 16 | git remote add origin https://github.com/kernelsmith/repo-name.git 17 | git push -u origin master 18 | -------------------------------------------------------------------------------- /bash/just_proxy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # location of your proxy-establishing-functions script 4 | thescript="./functions.d/S30proxystate.rc" 5 | 6 | # just a reminder 7 | echo "[*] Don't forget to either export MYPROXY=somevalue or edit $thescript directly to establish" 8 | echo " your proxy value(s) before running this script." 9 | 10 | # source the proxy functions and call them 11 | source $thescript 12 | echo "[*] Turning on the CLI proxies." 13 | proxyon 14 | echo "[*] The current state of CLI proxy variables:" 15 | proxystate 16 | -------------------------------------------------------------------------------- /useful_scripts/posix_workarounds.sh: -------------------------------------------------------------------------------- 1 | 2 | # a simple posix compliant echo command 3 | echo () { printf %s\\n "$*" ; } 4 | inform () { printf %s\\n "[*] $*" ; } 5 | 6 | # a more complex posix compliant echo command which mimics 7 | # bash's echo cmd with -e and -n as possible switches 8 | echoen () { 9 | fmt=%s end=\\n IFS=" " 10 | while [ $# -gt 1 ] ; do 11 | case "$1" in 12 | [!-]*|-*[!ne]*) break ;; 13 | *ne*|*en*) fmt=%b end= ;; 14 | *n*) end= ;; 15 | *e*) fmt=%b ;; 16 | esac 17 | shift 18 | done 19 | printf "$fmt$end" "$*" 20 | } 21 | -------------------------------------------------------------------------------- /useful_scripts/fast_rm.sh: -------------------------------------------------------------------------------- 1 | function fast_rm { 2 | # if perl is readily available, use it's 'unlink' to remove stuff, it's much faster than 'rm' 3 | # This is a hack to keep the syntax the same as that for 'rm' and to avoid 4 | # invoking 'perl -nle' a bunch of times, which would be somewhat counterproductive 5 | # There's probably a smarter way using 'xargs' or something or maybe some crazy 'find' 6 | if [ $(which perl) ] &>/dev/null; then 7 | templist= 8 | for item in "$@"; do templist="${templist}${item}\n";done 9 | echo -en $templist | perl -nle unlink 10 | else 11 | # else use rm -rf as the fall back 12 | rm -rf "$@" 13 | fi 14 | } 15 | -------------------------------------------------------------------------------- /useful_scripts/autoreply.pl: -------------------------------------------------------------------------------- 1 | # cat .irssi/scripts/autoreply.pl 2 | use Irssi; 3 | 4 | sub sig_message_public { 5 | my ($server, $msg, $nick, $nick_addr, $channel) = @_; 6 | if ($channel =~ /(?:#ar|#aha)/) { 7 | #Irssi::print("Public message in $channel from $nick, '$msg'"); 8 | if ($msg =~ /egyp[t7]: p[i!o]+n+g+/i) { 9 | Irssi::print("Ping in $channel from $nick, '$msg'"); 10 | #$server->command("mode $channel +b *!$nick_addr"); 11 | $server->command("kick $channel $nick pong"); 12 | } 13 | } 14 | } 15 | 16 | Irssi::signal_add('message public', 'sig_message_public'); 17 | 18 | jimbow [~admin@pool-71-177-95-243.lsanca.fios.verizon.net] -------------------------------------------------------------------------------- /useful_scripts/init-git.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This thing needs work 4 | 5 | if [ -z $1 ]; then echo "usage: $0 dir2init" && exit 1;fi 6 | 7 | dir2init="$1" 8 | 9 | #Global setup: 10 | 11 | git config --global user.name "kernelsmith" 12 | git config --global user.email kernelsmith@kernelsmith.com 13 | # optional 14 | #git config --global user.url "kernelsmith@kernelsmith.com" 15 | 16 | #Next steps: 17 | # mkdir if nec 18 | if ! [ -d $dir2init ]; then mkdir $dir2init;fi 19 | cd $dir2init 20 | 21 | git init 22 | touch README 23 | git add README 24 | git commit -m 'empty readme' 25 | git remote add origin git@github.com:kernelsmith/${dir2init}.git 26 | git push origin master 27 | 28 | -------------------------------------------------------------------------------- /git/nuke_remote_origin_restore_from_local.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # reset (destroy) remote origin and repair using local repo 4 | # 5 | 6 | # everything is commented out so no one accidentally nukes their remote 7 | # uncomment only one or the other of the remote add lines depending on whether 8 | # you use ssh or https 9 | 10 | # git remote rm origin 11 | # git remote add origin git@github.com:kernelsmith/metasploit-framework.git 12 | # - OR - 13 | # git remote add origin https://github.com/kernelsmith/metasploit-framework.git 14 | # git push -u origin master 15 | 16 | echo "If this script did nothing, it's because everything is commented out for safety." 17 | echo "If you really want to do this, you need to edit this script and comment out some lines" 18 | 19 | -------------------------------------------------------------------------------- /msf/find_evasions_msf.rb: -------------------------------------------------------------------------------- 1 | 2 | # grep -r -l register_evasion_options * 3 | f = 'lib/msf/core/exploit/dcerpc.rb 4 | lib/msf/core/exploit/http/client.rb 5 | lib/msf/core/exploit/http/server.rb 6 | lib/msf/core/exploit/smb.rb 7 | lib/msf/core/exploit/sunrpc.rb 8 | lib/msf/core/exploit/tcp.rb 9 | lib/msf/core/module.rb' 10 | 11 | files = f.split('\n') 12 | 13 | files.each do |file| 14 | begin 15 | File.foreach(file) do |line| 16 | puts file 17 | looking = false 18 | done = false 19 | break if done 20 | looking = true if line =~ /register_evasion_options/ 21 | if looking 22 | puts line if line = /^[\s]*Opt/ 23 | end 24 | done = true if looking and line =~ /^[\s]*\]/ 25 | end 26 | rescue Exception 27 | puts "couldn't open #{file}" 28 | end 29 | end -------------------------------------------------------------------------------- /git/.gitignore_global: -------------------------------------------------------------------------------- 1 | # Sublime Project files # 2 | ######################### 3 | sublime-project/ 4 | *.sublime-project* 5 | 6 | # Temp files etc # 7 | ################## 8 | *.swp 9 | *~ 10 | *.orig 11 | #.rej 12 | 13 | # Compiled source # 14 | ################### 15 | *.com 16 | *.class 17 | *.dll 18 | *.exe 19 | *.o 20 | *.so 21 | 22 | # Packages # 23 | ############ 24 | # it's better to unpack these files and commit the raw source 25 | # git has its own built in compression methods 26 | *.7z 27 | *.dmg 28 | *.gz 29 | *.iso 30 | *.jar 31 | *.rar 32 | *.tar 33 | *.zip 34 | 35 | # Logs and databases # 36 | ###################### 37 | *.log 38 | *.sql 39 | *.sqlite 40 | 41 | # OS generated files # 42 | ###################### 43 | *.DS_Store 44 | *.DS_Store? 45 | ._* 46 | .Spotlight-V100 47 | .Trashes 48 | Icon? 49 | ehthumbs.db 50 | Thumbs.db 51 | -------------------------------------------------------------------------------- /esxi/ssh_mount.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | MOUNT_POINT="/Volumes/sshfs" # like /Volumes/sshfs or /mnt/sshfs 4 | REMOTE_PATH_TO_MOUNT="/vmfs/volumes/datastore_RAID" # like /vmfs/volumes/datastore1 5 | PATH_TO_SSHFS="sshfs" # just use "sshfs" if it's in root's path 6 | SSH_USER="root" # usually root for an esxi server unless you changed stuff 7 | SSH_SERVER="esxi" # IP or hostname of esxi server 8 | 9 | # mkdir if nec 10 | if ! [ -d "$MOUNT_POINT" ]; then 11 | echo "Creating directory for mountpoint" 12 | sudo mkdir -p "$MOUNT_POINT" 13 | fi 14 | cmd="sudo $PATH_TO_SSHFS ${SSH_USER}@${SSH_SERVER}:${REMOTE_PATH_TO_MOUNT} $MOUNT_POINT" 15 | # sshfs user@hostname:path mount_point 16 | echo "Running: $cmd" 17 | echo "First password is the local sudo password, second is the password for ${SSH_USER}@${SSH_SERVER}" 18 | $cmd 19 | -------------------------------------------------------------------------------- /bash/bashrc.d/S10default_shell_prompt.rc: -------------------------------------------------------------------------------- 1 | # 2 | # Basic Shell Prompt Settings 3 | # 4 | # NOTE: These settings may be overriden by code in aliases.d or bashrc.d 5 | 6 | debug "default_shell_prompt" 7 | 8 | # set variable identifying the chroot you work in (used in the prompt below) 9 | if [ -z "$debian_chroot" -a -r /etc/debian_chroot ]; then 10 | debian_chroot=$(cat /etc/debian_chroot) 2>/dev/null 11 | fi 12 | 13 | # Color prompt 14 | # from Kali 15 | PS1='\[\e]0;\u@\h:\w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 16 | # from Ubuntu 17 | #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 18 | 19 | # If this is an xterm set the default title to user@host:dir 20 | case "$TERM" in 21 | xterm*|rxvt*) 22 | PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"' 23 | ;; 24 | *) 25 | ;; 26 | esac 27 | -------------------------------------------------------------------------------- /git/update_branch_from_upstream: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | thebranch="$1" 4 | 5 | # http://gun.io/blog/how-to-github-fork-branch-and-pull-request/ 6 | 7 | # if you haven't added an upsteam yet: 8 | # git remote add --track master upstream git://github.com/rapid7/metasploit-framework.git 9 | 10 | # get the current branch 11 | function git_branch { 12 | git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' 13 | } 14 | 15 | orig_branch=git_branch 16 | 17 | # switch to the branch 18 | git checkout $thebranch 19 | # abort the whole thing if git checkout fails 20 | if [[ $? -ne 0 ]];then echo "Could not checkout the branch:$thebranch";fi 21 | 22 | # get the latest code 23 | git fetch upstream 24 | 25 | # merge it with your local repo, currently active branch 26 | git merge upstream/master 27 | 28 | # now you should consider git push to remote 29 | #git push origin $thebranch 30 | 31 | # switch back to the original branch 32 | git checkout $orig_branch 33 | -------------------------------------------------------------------------------- /mac/.bash_aliases: -------------------------------------------------------------------------------- 1 | # some ls aliases 2 | alias ll='ls -alh' 3 | alias la='ls -A' 4 | alias l='ls -CF' 5 | 6 | # some sudo aliases 7 | alias sudi='sudo -i' 8 | alias suck='sudo -u ks' 9 | 10 | # some functions 11 | function rgrep() { 12 | if [ -n "${2}" ]; then 13 | find -L . -type f -name \*.*rb -exec grep -n -C $2 -i -H --color "$1" {} \; 14 | else 15 | find -L . -type f -name \*.*rb -exec grep -n -i -H --color "$1" {} \; 16 | fi 17 | } 18 | # git branch is also defined in bashrc for clarity it's also here 19 | function git_branch { 20 | git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' 21 | } 22 | # shorten github urls 23 | function shorten() { 24 | curl -s -S -i http://git.io -F "url=$1" | grep Location | cut -d " " -f 2 25 | } 26 | 27 | #launch Sublime Text 2 from the cli 28 | #ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime 29 | alias sublime='/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl' 30 | -------------------------------------------------------------------------------- /bash/functions.d/S70git_helpers.rc: -------------------------------------------------------------------------------- 1 | # 2 | # Functions to help with git, github operations 3 | # 4 | 5 | # show commit "stats" 6 | git_stats() { 7 | git nicelog --merges --since=2014-01-01 | grep -i land | cut -f 2 -d "<" | sort | uniq -c | sort -nr 8 | } 9 | export -f git_stats 10 | 11 | # shorten github urls 12 | git_shorten() { 13 | curl -s -S -i http://git.io -F "url=$1" | grep Location | cut -d " " -f 2 14 | } 15 | export -f shorten 16 | 17 | # update all given git branches with latest from upstream 18 | # default to master branch if no args given 19 | up() { 20 | git fetch upstream 21 | # default to updating the master branch if no branches supplied 22 | if [ -n "$1" ];then 23 | branches="$@" 24 | else 25 | branches="master" 26 | fi 27 | 28 | for branch in $branches; do 29 | git checkout $branch 30 | stash=$(git stash save) 31 | git fetch 32 | git rebase upstream/master 33 | # if anything got stashed, reapply it? 34 | [ "$stash" != "No local changes to save" ] && git stash pop 35 | done 36 | }; export -f up 37 | -------------------------------------------------------------------------------- /git/update_master_from_upstream_simple.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # this script tries to be posix compliant, so no bash'isms 4 | # usage: $0 [branch] 5 | # Updates branch from upstream. If no branch given, master is assumed 6 | 7 | # function declarations 8 | puts() { 9 | echo "[*] $1" 10 | } 11 | branch="master" 12 | if [ -n "$1" ]; then 13 | branch="$1" 14 | fi 15 | echo 16 | git checkout $branch 17 | # we're going to use the https version here because ssh is blocked where I work 18 | upstream='https://github.com/rapid7/metasploit-framework.git' 19 | #upstream='git://github.com/rapid7/metasploit-framework.git' 20 | if [ -z "$(git remote -v | grep $upstream)" ]; then 21 | # add the rapid7 repo as a remote branch and call it "upstream" 22 | puts "Did not find upstream branch, so adding it..." 23 | git remote add upstream 24 | fi 25 | puts "Downloading updates..." 26 | git fetch upstream # download objects from upstream's master to holding area (.git/FETCH_HEAD) 27 | puts "Rebasing your local master branch with downloaded updates..." 28 | git rebase upstream/master # rebase against your local master (you better be on your master branch?) 29 | puts "Done." 30 | echo 31 | -------------------------------------------------------------------------------- /msf/msfconsole.rc: -------------------------------------------------------------------------------- 1 | ### 2 | # 3 | # Aliases 4 | # 5 | ### 6 | 7 | load alias 8 | 9 | # show 10 | alias -f so show options 11 | alias -f sa show advanced 12 | alias -f se show evasion 13 | alias -f st show targets 14 | alias -f sp show payloads 15 | alias -f sact show actions 16 | 17 | # set/use 18 | alias -f pay set PAYLOAD 19 | alias -f multi use exploit/multi/handler 20 | alias -f psexec use exploit/windows/smb/psexec 21 | alias -f ss set SESSION 22 | 23 | # sessions 24 | alias -f s sessions -l -v 25 | alias -f slv session -l -v 26 | alias -f sk sessions -k 27 | alias -f sK sessions -K 28 | alias -f si sessions -i 29 | 30 | # jobs 31 | alias -f j jobs -l -v 32 | alias -f jlv jobs -l -v 33 | alias -f jk jobs -k 34 | alias -f jK jobs -K 35 | 36 | # networking 37 | #alias -f ip ifconfig || ipconfig 38 | alias -f ip "ip addr show" || ifconfig || ipconfig 39 | # the one below just picks the interfaces starting with 192 40 | # it will also blow up on window but you can change the grep to findstr if you need to 41 | #alias -f myip "ifconfig | grep 'inet 192' | cut -d ' ' -f 2" 42 | 43 | # miscellaneous 44 | alias -f in_mem execute -H -i -c -m -d calc.exe -f 45 | # alias -f sockit setg Proxies SOCKS5:127.0.0.1:9050 46 | -------------------------------------------------------------------------------- /git/update_branch_from_upstream_and_push_remote: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | thebranch="$1" 4 | 5 | # http://gun.io/blog/how-to-github-fork-branch-and-pull-request/ 6 | 7 | function puts { 8 | echo -e "[*] $1" 9 | } 10 | 11 | # if you haven't added an upsteam yet: 12 | # git remote add --track master upstream git://github.com/rapid7/metasploit-framework.git 13 | 14 | # get the current branch 15 | orig_branch=$(git branch | grep \* | cut -d ' ' -f 2-) 16 | 17 | # switch to the branch 18 | puts "Switching branch to $thebranch" 19 | git checkout $thebranch 20 | # abort the whole thing if git checkout fails 21 | if [[ $? -ne 0 ]];then echo "[!] Could not checkout the branch:$thebranch" && exit 1;fi 22 | 23 | # get the latest code 24 | puts "Fetching from upstream" 25 | git fetch upstream 26 | 27 | # merge it with your local repo, currently active branch 28 | puts "Merging with local repo" 29 | git merge upstream/master 30 | 31 | # now you should consider git push to remote 32 | puts "Pushing to remote repo" 33 | git push origin $thebranch 34 | 35 | # switch back to the original branch 36 | puts "Switching back to the original branch ($orig_branch)" 37 | puts "Running:git checkout ${orig_branch}" 38 | git checkout ${orig_branch} 39 | -------------------------------------------------------------------------------- /bash/functions.d/S10utils.rc: -------------------------------------------------------------------------------- 1 | # 2 | # Utility functions that are likely to be needed/used 3 | # 4 | # NOTE: add the function to extras.rc if it's rarely used 5 | 6 | debug "utils.rc" 7 | 8 | # mkdir if the dir doesn't already exist 9 | chk_mkdir() { 10 | # make a directory (with -p) if it doesn't exist 11 | if [ ! -d "$1" ]; then 12 | # make the directory, or fail out, use 'die' if available 13 | mkdir -p $1 || type -t die && die "Can't create directory...aborting" $_ERR_CANT_WRITE_DIR 14 | fi 15 | } 16 | export -f chk_mkdir 17 | 18 | # get a nicely formatted, 'ls'-sortable timestamp 19 | # does not automatically add a \n at the end 20 | stampit() { 21 | echo -n "$@.$(date +%Y%m%d-%H%M%S)" 22 | } 23 | export -f stampit 24 | 25 | # easily change the terminal title 26 | ttitle() { 27 | echo -e '\033k'$@'\033\' 28 | } 29 | export -f ttitle 30 | 31 | rgrep() { 32 | if [ -n "${2}" ]; then 33 | find -L . -type f -name \*.*rb -exec grep -n -C $2 -i -H --color "$1" {} \; 34 | else 35 | find -L . -type f -name \*.*rb -exec grep -n -i -H --color "$1" {} \; 36 | fi 37 | } 38 | export -f rgrep 39 | 40 | # find large files. $1 is min size in megs to show 41 | find_large() { 42 | find ~/ -size +${1}M -ls 43 | } -------------------------------------------------------------------------------- /git/merge_a_contribs_stuff: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # The easy way 5 | # 6 | # create a local branch like 7 | git checkout -b bug/RM5810 8 | 9 | # apply the patch for testing 10 | curl https://github.com/rapid7/metasploit-framework/pull/14166.patch | git am 11 | 12 | # 13 | # The harder but more official way 14 | # 15 | 16 | thebranch="$1" 17 | # this assumes you want to create a branch with the same name as the contrib's 18 | # otherwise remove the -b below 19 | git checkout -b $thebranch 20 | git remote add contributor git://github.com/contributor/project 21 | git fetch contributor 22 | git merge contributor/$thebranch 23 | # if you then want to push these changes to github (your remote) 24 | #git push origin master 25 | 26 | # I didn't use the 'contrib' below, but you might want to 27 | # change rapid7 to hdm or whatever if not coming from the rapid7 source 28 | # git checkout -b contrib/feature/search-module-targets-7754 29 | # git remote add contrib/hdmoore-r7 git://github.com/rapid7/metasploit-framework/feature/search-module-targets-7754 30 | # git fetch contrib/hdmoore-r7 31 | # git merge contrib/hdmoore-r7/feature/search-module-targets-7754 32 | # git remote add contrib/lmercer-r7 git://github.com/lmercer-r7/metasploit-framework/feature/rm5810-fakedns-server-support-multiple-targets 33 | -------------------------------------------------------------------------------- /bash/bashrc.d/K90ssh_agent.rc: -------------------------------------------------------------------------------- 1 | # 2 | # SSH Agent 3 | # 4 | 5 | SSH_ENV="$HOME/.ssh/environment" 6 | 7 | # start the ssh-agent 8 | function start_agent { 9 | echo "Initializing new SSH agent..." 10 | # spawn ssh-agent 11 | ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV" 12 | echo succeeded 13 | chmod 600 "$SSH_ENV" 14 | . "$SSH_ENV" > /dev/null 15 | ssh-add 16 | } 17 | 18 | # test for identities 19 | function test_identities { 20 | # test whether standard identities have been added to the agent already 21 | ssh-add -l | grep "The agent has no identities" > /dev/null 22 | if [ $? -eq 0 ]; then 23 | ssh-add 24 | # $SSH_AUTH_SOCK broken so we start a new proper agent 25 | if [ $? -eq 2 ];then 26 | start_agent 27 | fi 28 | fi 29 | } 30 | 31 | # check for running ssh-agent with proper $SSH_AGENT_PID 32 | if [ -n "$SSH_AGENT_PID" ]; then 33 | ps -ef | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null 34 | if [ $? -eq 0 ]; then 35 | test_identities 36 | fi 37 | # if $SSH_AGENT_PID is not properly set, we might be able to load one from 38 | # $SSH_ENV 39 | else 40 | if [ -f "$SSH_ENV" ]; then 41 | . "$SSH_ENV" > /dev/null 42 | fi 43 | ps -ef | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null 44 | if [ $? -eq 0 ]; then 45 | test_identities 46 | else 47 | start_agent 48 | fi 49 | fi -------------------------------------------------------------------------------- /bash/functions.d/S80transfer.sh.rc: -------------------------------------------------------------------------------- 1 | 2 | transfer() { 3 | local curl_cmd="" 4 | local res="" 5 | local urls="" 6 | local bases="" 7 | local site="https://transfer.sh/" 8 | case $# in 9 | 0) >&2 echo "Usage: ${FUNCNAME[0]} file [file...]"; exit 1 10 | ;; 11 | 1) curl_cmd="curl --upload-file $1 ${site}$(basename $1)" 12 | ;; 13 | *) curl_cmd="curl -i" 14 | for f in $@; do curl_cmd="${curl_cmd} -F filedata=@${f}"; done 15 | curl_cmd="${curl_cmd} ${site}" 16 | ;; 17 | esac 18 | res=$(echo $(eval $curl_cmd) | grep -i $site) 19 | echo 20 | #echo "res--${res}--res" 21 | echo "Download url(s):" 22 | echo $res 23 | echo "Combined/compressed downloads:" 24 | for url in $res; do 25 | if echo $url | grep -q $site; then bases="${bases},${url##$site}";fi 26 | done 27 | #bases="${bases##,\,}" # remove leading comma 28 | bases=$(echo $bases | cut -c 2-) 29 | for ext in .tar.gz .tar .zip; do 30 | echo "curl ${site}($bases)${ext}" 31 | done 32 | } 33 | export -f transfer 34 | 35 | # Analysis 36 | # scan using clamav 37 | # curl -X PUT --upload-file $file https://transfer.sh/eicar.com/scan 38 | # Upload malware to VirusTotal, get a permalink in return 39 | # curl -X PUT --upload-file $file https://transfer.sh/test.txt/virustotal 40 | 41 | # Encrypt & upload 42 | #cat $clear_text_file | gpg -ac -o-|curl -X PUT --upload-file "-" https://transfer.sh/test.txt 43 | 44 | # Decrypt & download 45 | #curl $url | gpg -o- > $clear_text_file 46 | -------------------------------------------------------------------------------- /git/.bash_aliases_git: -------------------------------------------------------------------------------- 1 | # Git and RVM prompting 2 | function git-current-branch { 3 | git branch 2> /dev/null | grep \* | cut -d ' ' -f 2- 4 | } 5 | #export PS1="[\$(~/.rvm/bin/rvm-prompt v p g)] \$(git-current-branch)$PS1" 6 | orig_prompt="[\u@\h \W]\\$ " 7 | bold_prompt="\[$(tput bold)\][\u@\h \W]\\$ " 8 | bold="\[$(tput bold)\]" 9 | regular="\[$(tput sgr0)\]" 10 | shorten="14" # set to '' for no shortening, otherwise number of chars to display for long inputs 11 | 12 | function shorten { 13 | str="$1" 14 | len=$2 15 | #if $str -eq "metasploit-framework"; then 16 | # echo "msf" 17 | #else 18 | echo $str | cut -c 1-$len 19 | #fi 20 | } 21 | 22 | function check_shorten { 23 | if [ -n "$shorten" ]; then # this will explode if shorten is 0, but I don't care 24 | echo "$(shorten $1 $shorten)" 25 | else 26 | echo $1 27 | fi 28 | } 29 | 30 | function prompt_git { 31 | local ps=$bold 32 | ps="${ps}(\$(check_shorten \$(git-current-branch)))" 33 | ps="${ps}${regular}$orig_prompt" 34 | export PS1="$ps" 35 | } 36 | 37 | function prompt_ruby { 38 | local ps=$bold 39 | ps="${ps}(\$(check_shorten \$(~/.rvm/bin/rvm-prompt v p g)))" 40 | ps="${ps}${regular}$orig_prompt" 41 | export PS1="$ps" 42 | } 43 | 44 | function prompt_git_ruby { 45 | local ps=$bold 46 | ps="${ps}(\$(check_shorten \$(~/.rvm/bin/rvm-prompt v p g)))" 47 | ps="${ps}(\$(check_shorten \$(git-current-branch)))" 48 | ps="${ps}${regular}$orig_prompt" 49 | export PS1="$ps" 50 | } 51 | 52 | prompt_git_ruby 53 | -------------------------------------------------------------------------------- /ssh/port_forward.sh: -------------------------------------------------------------------------------- 1 | # good ref http://www.symantec.com/connect/articles/ssh-port-forwarding 2 | 3 | # from the host that needs to get out: 4 | 5 | if [ -z $1 ]; then echo "please supply an unused local port" && exit 1;fi 6 | 7 | UNUSED_LOCAL_PORT="$1" # You will tell your app, an irc client here, to use localhost and this port to connect 8 | ULTIMATE_DESTINATION="irc.feenode.net" # where you want your app to be able to reach 9 | ULTIMATE_DESTINATION_PORT="7000" # the port you want your app to be able to reach 10 | SHELL_SERVER="kernelsmith" # ssh config host OR someuser@shellserver where shellserver is an fqdn or ip 11 | LOCALHOST="127.0.0.1" # help's fix some corner case issues. Sometimes 127.0.0.1, 127.0.1.1, localhost work differently 12 | # generally it's a bad idea to use 'localhost' because it can have ipv6 confusion 13 | # http://manas.tungare.name/blog/ssh-port-forwarding-on-mac-os-x/ 14 | 15 | # in our case, we're simulating an ssh config host: 16 | # cat ~/.ssh/config 17 | # Host kernelsmith 18 | # Hostname fqdn.or.ip.com 19 | # User someuser 20 | # PreferredAuthentications publickey # optional, but good for putting in script 21 | # IdentityFile ~/.ssh/my_rsa # optional in this case, good if you have > 1, or rename your key file from default (id_rsa) 22 | 23 | cmd="ssh -L $LOCALHOST:$UNUSED_LOCAL_PORT:$ULTIMATE_DESTINATION:$ULTIMATE_DESTINATION_PORT $SHELL_SERVER" 24 | echo "Running: $cmd" 25 | $cmd 26 | # just login (if not using keys) and as long as this ssh session is open, your tunnel is running 27 | -------------------------------------------------------------------------------- /bash/load_drop_directories.rc: -------------------------------------------------------------------------------- 1 | # 2 | # BASH drop directory hook 3 | # 4 | 5 | orig_indent=$indent 6 | current="load_drop_directories.rc" 7 | debug "Running inside $current" 8 | 9 | run_scripts() 10 | { 11 | script_dir="$1" 12 | if [ -d $script_dir ]; then 13 | for script in $(ls "$script_dir"/S*.rc 2>/dev/null | sort); do 14 | debug "Checking for $script" 15 | # skip non-existent (regular), non-executable, or zero-length files 16 | if [ -f "$script" -a -x "$script" -a -s "$script" ]; then 17 | debug "Sourcing $script" 18 | indent+="$INDENT_VAL" 19 | source $script 20 | if [ "$?" -ne "0" ]; then 21 | # display error even if debug is off 22 | echo "$indent$script returned error code --${?}--" 23 | indent=$orig_indent 24 | else 25 | debug "$script completed successfully" 26 | indent=$orig_indent 27 | fi 28 | else 29 | local msg="$script was not executed because it's either not a regular file," 30 | msg+=" it's not executable, or it has a zero length." 31 | debug "$msg" 32 | fi 33 | done 34 | else 35 | debug "$script_dir does not exist" 36 | fi 37 | } 38 | export -f run_scripts 39 | 40 | # run bashrc.d files first, code there is usually more setup-oriented 41 | drop_dirs="$HOME/bashrc.d $HOME/private.d $HOME/aliases.d $HOME/functions.d" 42 | for d in $drop_dirs; do 43 | debug "Loading drop directory:$d" 44 | run_scripts "$d" 45 | # NOTE: make sure scripts export -f any functions you want available to child processes 46 | done 47 | -------------------------------------------------------------------------------- /ruby/irbrc: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | require 'wirble' 3 | require 'irb/completion' 4 | require 'pp' 5 | #require 'what_methods' # gem install what_methods. Use: 6 | 7 | IRB.conf[:AUTO_INDENT] = true 8 | Wirble.init 9 | Wirble.colorize 10 | class Object 11 | # get all the methods for an object that aren't basic methods from Object 12 | def local_methods 13 | (methods - Object.instance_methods).sort 14 | end 15 | end 16 | 17 | ANSI_BOLD = "\033[1m" 18 | ANSI_RESET = "\033[0m" 19 | ANSI_LGRAY = "\033[0;37m" 20 | ANSI_GRAY = "\033[1;30m" 21 | 22 | def pm(obj, *options) # Print methods 23 | methods = obj.methods 24 | methods -= Object.methods unless options.include? :more 25 | filter = options.select {|opt| opt.kind_of? Regexp}.first 26 | methods = methods.select {|name| name =~ filter} if filter 27 | 28 | data = methods.sort.collect do |name| 29 | method = obj.method(name) 30 | if method.arity == 0 31 | args = "()" 32 | elsif method.arity > 0 33 | n = method.arity 34 | args = "(#{(1..n).collect {|i| "arg#{i}"}.join(", ")})" 35 | elsif method.arity < 0 36 | n = -method.arity 37 | args = "(#{(1..n).collect {|i| "arg#{i}"}.join(", ")}, ...)" 38 | end 39 | klass = $1 if method.inspect =~ /Method: (.*?)#/ 40 | [name, args, klass] 41 | end 42 | max_name = data.collect {|item| item[0].size}.max 43 | max_args = data.collect {|item| item[1].size}.max 44 | data.each do |item| 45 | print " #{ANSI_BOLD}#{item[0].to_s.rjust(max_name)}#{ANSI_RESET}" 46 | print "#{ANSI_GRAY}#{item[1].ljust(max_args)}#{ANSI_RESET}" 47 | print " #{ANSI_LGRAY}#{item[2]}#{ANSI_RESET}\n" 48 | end 49 | data.size 50 | end 51 | -------------------------------------------------------------------------------- /msf/svn_install_msf_ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # This script will install Metasploit Framework + the unstable tree under /opt/metasploit/ 5 | # For Ubuntu. Tested on Ubuntu 10.10 6 | # 7 | 8 | INSTALL_PATH="/opt/metasploit" 9 | 10 | echo "Installing required packages...." 11 | sudo apt-get install -y ruby libopenssl-ruby libyaml-ruby libdl-ruby libiconv-ruby libreadline-ruby irb ri rubygems 12 | sudo apt-get install -y subversion 13 | sudo apt-get install -y build-essential ruby-dev libpcap-dev 14 | 15 | echo "Downloading Metasploit Framework..." 16 | sudo svn checkout https://www.metasploit.com/svn/framework3/trunk $INSTALL_PATH 17 | 18 | echo "Downloading the unstable tree..." 19 | sudo svn checkout https://metasploit.com/svn/framework3/unstable/modules/ $INSTALL_PATH/unstable/ 20 | 21 | echo "Updating Metasploit..." 22 | cd $INSTALL_PATH 23 | sudo svn update 24 | 25 | echo "Creating ~/.msf4/" 26 | echo set LogLevel 5 >> /tmp/msf_load_msf4.rc 27 | echo save >> /tmp/msf_load_msf4.rc 28 | echo exit >> /tmp/msf_load_msf4.rc 29 | cd $INSTALL_PATH 30 | ./msfconsole -q -r /tmp/msf_load_msf4.rc 31 | rm /tmp/msf_load_msf4.rc 32 | 33 | echo "Adding Metasploit to PATH..." 34 | echo \# Metasploit path >> ~/.bashrc 35 | echo export PATH=\$PATH:$INSTALL_PATH/ >> ~/.bashrc 36 | 37 | clear 38 | 39 | echo "Done. Metasploit installed: " $INSTALL_PATH 40 | echo "Unstable tree: " $INSTALL_PATH/unstable/ 41 | echo "Where to place your personal modules: ~/.msf4/modules/" 42 | echo "Loot Directory: ~/.msf4/loot/" 43 | echo "Log File: ~/.msf4/logs/framework.log" 44 | echo "Ruby version:" 45 | ruby -v 46 | echo "-- Metasploit.com" 47 | -------------------------------------------------------------------------------- /useful_scripts/youtube.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # FYI, use ffprobe to get current encoder info for a video 4 | 5 | # transcode/convert 6 | 7 | thumb_time_offset=2 8 | thumb_size="320x240" # 320x240, 640x480, etc, WxH 9 | 10 | for infile in *.mp4; do 11 | name_wo_ext="${infile%%\.*}" # removes all exts, use ${infile%\.*} for just the last extension 12 | out_video="${name_wo_ext}.stream.mp4" 13 | out_thumbnail="${name_wo_ext}.jpg" 14 | # these two ffmpeg operations can be done simultaneously, but they are not for clarity and ease 15 | # plus, the 2nd operation is super quick 16 | # transcode 17 | ffmpeg -i $infile -vcodec h264 -movflags +faststart -acodec libfdk_aac -f mp4 $out_video 18 | # create thumbnail, could use $infile or $out_video as src 19 | ffmpeg -itsoffset -${thumb_time_offset} -i $out_video \ 20 | -vcodec mjpeg -vframes 1 -an -f rawvideo -s ${thumb_size} $out_thumbnail 21 | done 22 | 23 | # for all .mp4s in current dir 24 | # ffmpeg with input file being the located mp4s with the following output settings 25 | # These settings are optimzed for youtube streaming 26 | # -vcodec: video codec of h264 27 | # -movflags: faststart to make it streamable 28 | # -acodec: audio codec of aac (non-experimental) 29 | # - f: output container .mp4 30 | # and a filename of inputfile w/o extensions + .yt.mp4 31 | 32 | # upload to youtube 33 | 34 | #$ youtube-upload \ 35 | # --email=myemail@gmail.com --password=mypassword \ 36 | # --title="A.S. Mutter" --description="A.S. Mutter plays Beethoven" \ 37 | # --category=Music --keywords="mutter, beethoven" anne_sophie_mutter.flv 38 | #www.youtube.com/watch?v=pxzZ-fYjeYs 39 | 40 | # ruby api sample: https://github.com/youtube/api-samples/tree/master/ruby 41 | -------------------------------------------------------------------------------- /git/clone_all_branches.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This script tries to be posix compliant, so no bash'isms 4 | # This script assumes you have an existing repo, the dir for which is your pwd, such as one created with 5 | # git clone https://github.com/kernelsmith/metasploit-framework.git 6 | # The script will create a local branch for each remote branch (origin only) and update the local branch to match the remote 7 | 8 | # Usage: 9 | # $0 [-d] [-f grep_filter] 10 | # -d dryrun,just shows you what would happen but doesn't do anything 11 | # -f filter, filter is applied to branches to be cloned via a grep 12 | 13 | # function declarations 14 | puts() { 15 | echo "[*] $1" 16 | } 17 | 18 | # do the damn thing 19 | me="$0" 20 | dryrun= 21 | filter= 22 | filter_arg= 23 | while getopts df: name; do 24 | case $name in 25 | d) dryrun="true";; 26 | f) filter="true" 27 | filter_arg="$OPTARG";; 28 | ?) puts "Usage: $me [-d] [-f grep_filter]" 29 | exit 2;; 30 | esac 31 | done 32 | echo 33 | puts "Doing some housekeeping first..." 34 | puts " - Garbage collecting..." 35 | git gc --prune=now 36 | puts " - Pruning remote origin..." 37 | git remote prune origin 38 | branches_to_add=$(git branch -r | grep origin | grep -v msdn_|grep -v 'HEAD\|master') 39 | if [ -n "$filter" ]; then branches_to_add=$(echo $branches_to_add | grep $filter_arg);fi 40 | for branch in $branches_to_add; do 41 | local_branch=$(echo $branch | cut -d "/" -f 2-) 42 | puts "Creating local branch:$local_branch and downloading:$branch" 43 | if [ -n "$dryrun" ];then 44 | echo git checkout -b $local_branch $branch 45 | else 46 | git checkout -b $local_branch $branch # create (and checkout) local branch and download remote branch "into" it 47 | fi 48 | done 49 | git checkout master 50 | puts "Done." 51 | echo 52 | -------------------------------------------------------------------------------- /ruby_dev_env/ruby_instrospection.rb: -------------------------------------------------------------------------------- 1 | # introspecting your ruby program: 2 | 3 | #Print all modules, except classes 4 | puts Module.constants.sort.select {|x| eval(x.to_s).instance_of? Module} 5 | 6 | #Print all classes (excluding exceptions) 7 | puts Module.constants.sort.select {|x| c = eval(x.to_s);c.is_a? Class and not c.ancestors.include? Exception} 8 | 9 | # just classes 10 | puts Module.constants.sort.select {|x| eval(x.to_s).instance_of? Class} 11 | 12 | #Print all exceptions 13 | puts Module.constants.sort.select {|x| c = eval(x.to_s);c.instance_of? Class and c.ancestors.include? Exception} 14 | 15 | #reference your current method name 16 | __method__ 17 | 18 | input = Rex::Ui::Text::Input::Stdio.new 19 | # lib/rex/ui/text/input/buffer.rb 20 | 21 | # msf exceptions 22 | ArgumentError 23 | ClassArgumentError 24 | DnsTimeoutArgumentError 25 | EOFError 26 | EncodingError 27 | Exception 28 | ExpandError 29 | FiberError 30 | FloatDomainError 31 | HeaderArgumentError 32 | HeaderDuplicateID 33 | HeaderWrongCount 34 | HeaderWrongOpcode 35 | HeaderWrongRecursive 36 | IOError 37 | IndexError 38 | Interrupt 39 | InvalidLength 40 | InvalidObjectId 41 | InvalidTag 42 | KeyError 43 | LoadError 44 | LocalJumpError 45 | MissingSourceFile 46 | NameError 47 | NoMemoryError 48 | NoMethodError 49 | NoResponseError 50 | NotImplementedError 51 | OutOfData 52 | PacketArgumentError 53 | PacketError 54 | ParseError 55 | QuestionArgumentError 56 | QuestionNameError 57 | RRArgumentError 58 | RRDataError 59 | RangeError 60 | RegexpError 61 | ResolverArgumentError 62 | RuntimeError 63 | ScanError 64 | ScriptError 65 | SecurityError 66 | SignalException 67 | SocketError 68 | StandardError 69 | StopIteration 70 | SyntaxError 71 | SystemCallError 72 | SystemExit 73 | SystemStackError 74 | ThreadError 75 | TimeoutError 76 | TypeArgumentError 77 | TypeError 78 | ZeroDivisionError 79 | 80 | -------------------------------------------------------------------------------- /dot_config/deluge/gtkui.conf: -------------------------------------------------------------------------------- 1 | { 2 | "file": 1, 3 | "format": 1 4 | }{ 5 | "close_to_tray": true, 6 | "ntf_sound_path": "/home/ks", 7 | "window_width": 920, 8 | "default_load_path": null, 9 | "window_y_pos": 0, 10 | "ntf_email": false, 11 | "tray_upload_speed_list": [ 12 | 5.0, 13 | 10.0, 14 | 30.0, 15 | 80.0, 16 | 300.0 17 | ], 18 | "show_statusbar": true, 19 | "ntf_popup": false, 20 | "ntf_pass": "", 21 | "show_sidebar": true, 22 | "window_maximized": false, 23 | "enable_system_tray": true, 24 | "tray_download_speed_list": [ 25 | 5.0, 26 | 10.0, 27 | 30.0, 28 | 80.0, 29 | 300.0 30 | ], 31 | "show_connection_manager_on_start": true, 32 | "lock_tray": false, 33 | "createtorrent.trackers": [], 34 | "ntf_sound": false, 35 | "tray_password": "", 36 | "focus_add_dialog": true, 37 | "ntf_server": "", 38 | "start_in_tray": false, 39 | "ntf_tray_blink": true, 40 | "check_new_releases": false, 41 | "autoadd_queued": false, 42 | "autoconnect_host_id": null, 43 | "classic_mode": true, 44 | "window_pane_position": 284, 45 | "enabled_plugins": [], 46 | "show_rate_in_title": false, 47 | "autoadd_enable": false, 48 | "ntf_username": "", 49 | "interactive_add": true, 50 | "sidebar_show_zero": false, 51 | "window_x_pos": 0, 52 | "window_height": 592, 53 | "ntf_security": null, 54 | "connection_limit_list": [ 55 | 50, 56 | 100, 57 | 200, 58 | 300, 59 | 500 60 | ], 61 | "sidebar_position": 170, 62 | "show_new_releases": false, 63 | "autoconnect": false, 64 | "choose_directory_dialog_path": "/home/ks", 65 | "sidebar_show_trackers": true, 66 | "autostart_localhost": false, 67 | "show_toolbar": true, 68 | "autoadd_location": "", 69 | "ntf_email_add": "", 70 | "signal_port": 40000 71 | } -------------------------------------------------------------------------------- /esxi/usage-my-vmware-cmd.txt: -------------------------------------------------------------------------------- 1 | Usage: 2 | Local execution- 3 | my-vmware-cmd.sh [operation] [vm_input_file] 4 | Remote execution- 5 | my-vmware-cmd.sh remote [ESX_ESXI_IP_ADDRESS] [operation] [vm_input_file] 6 | 7 | Operations: 8 | start [vm_input_file] 9 | -- Start all VMs in the input file 10 | stop [vm_input_file] 11 | -- Stop all VMs in the input file 12 | suspend [vm_input_file] 13 | -- Suspend all VMs in the input file 14 | resume [vm_input_file] 15 | -- Resume all suspended VMs in the input file 16 | reset [vm_input_file] 17 | -- Hard reset all VMs in the input file 18 | shutdown [vm_input_file] 19 | -- Shutdown all VMs in the input file (VMware Tools required) 20 | reboot [vm_input_file] 21 | -- Reboot all VMs in the input file (VMware Tools required) 22 | snap [vm_input_file] 23 | -- Create administrative pristine snapshot of all VMs in the input file 24 | revert [vm_input_file] 25 | -- Revert all VMs in the input file back to pristine state 26 | purge [vm_input_file] 27 | -- Removes from local inventory and purges all VMs in the input file 28 | mac [vm_input_file] [generic|nixdhcp] [http://NETWORK (172.30.0)|http://NETWORK (172.30.0)] [HOST_COUNT_START (200)] default=0 29 | -- Extracts MAC addresses and generates either a generic file or one compatible with *nix dhcpd 30 | ( e.g. my-vmware-cmd.sh mac [vm_input_file] generic ) 31 | ( e.g. my-vmware-cmd.sh mac [vm_input_file] nixdhcp 172.30.0 200 ) 32 | vnic [vm_input_file] default=0 33 | -- Change vNic portgroup for all VMs in the input file 34 | ( e.g. my-vmware-cmd.sh vnic [vm_input_file] 3 ) 35 | -------------------------------------------------------------------------------- /bash/.bashrc: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # NOTE: I only maintain the additions to this file as I don't currently 6 | # want to overwrite the entire default version. This file should be 7 | # appended to the end of the default version. See the 8 | # augment_my_env.sh script 9 | # Altho, that's exactly what I'm doing right now 10 | 11 | # set to anything to see debug output, otherwise nothing 12 | export DEBUG_BASH_FRAMEWORK= 13 | if [ -n "$DEBUG_BASH_FRAMEWORK" ];then 14 | on_off="on" 15 | else 16 | on_off="off" 17 | fi 18 | echo "[*] Debugging is currently $on_off on $(hostname). To change, edit .bashrc." 19 | debug() { 20 | if [ -n "$DEBUG_BASH_FRAMEWORK" ];then 21 | echo "[DEBUG] $@" 22 | fi 23 | } 24 | export -f debug 25 | export indent=" " 26 | orig_indent=$indent 27 | current=".bashrc" # can't use $0 as these files are sourced, not ran 28 | debug "Running inside $current" 29 | 30 | # enable color support of ls and also add handy aliases 31 | # NOTE, moved to aliases.d which runs after bashrc. Whichever runs last, wins. 32 | 33 | # Set the default editor 34 | export EDITOR=/usr/bin/vim 35 | 36 | # Possibly load additional setup from drop directories 37 | script="load_drop_directories.rc" 38 | debug "Sourcing $script if available" 39 | 40 | # Edit the load_drop_directories.rc file above to fine tune file loads, or 41 | # you can comment out the source line below to disable the load entirely (or 42 | # you can remove/rename the rc file) 43 | # source $script if it's a regular file which is executable and non-zero-length 44 | indent+="$INDENT_VAL" 45 | [ -f "$script" -a -x "$script" -a -s "$script" ] && source $script 46 | indent=$orig_indent 47 | 48 | # export a var to indicate bashrc has been run 49 | debug "Setting BASHRC_COMPLETE to true" 50 | export BASHRC_COMPLETE="true" 51 | 52 | PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting 53 | -------------------------------------------------------------------------------- /bash/install_bashrc_framework.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | inform() { 4 | echo "[*] $@" 5 | } 6 | warn() { 7 | echo "[!] $@" 8 | } 9 | backup() { 10 | # $@ are files to be backed up 11 | for file in $@; do 12 | # @todo: this test is not posix, update it to be if framework is to 13 | # work on other shells in the future 14 | # backup the file if it exists and is not a softlink 15 | if [ -f "$file" -a ! -L "$file" ]; then 16 | inform "Backing up $file to ${file}.bkp" 17 | mv "$file" "${file}.bkp" 18 | fi 19 | done 20 | } 21 | homelink() { 22 | # $1 is the file to link, it will get linked from ~/ to point to the 23 | # downloaded source_dir 24 | #ln -s -f FILE_TO_WHICH_TO_LINK NAME_OF_LINK 25 | ln -s -f "${source_dir}/${1}" "${HOME}/$1" 26 | } 27 | 28 | # check that we are in the right starting place 29 | # also save the directory for use later 30 | if grep -q BASHRC_COMPLETE "./.bashrc" 2> /dev/null; then 31 | # then we are probably in the right place 32 | source_dir=$(pwd) 33 | # inform "DEBUG: source_dir is $source_dir" 34 | else 35 | warn "You don't seem to be running this installer from the downloaded bash directory." 36 | warn "Try cd'ing to the 'bash' dir inside the downloaded bashrc framework." 37 | exit 128 38 | fi 39 | 40 | home_files_to_backup="${HOME}/.bash_profile ${HOME}/.bashrc 41 | ${HOME}/.vimrc ${HOME}/.bash_aliases" 42 | inform "backing up $home_files_to_backup" 43 | backup $home_files_to_backup 44 | 45 | # softlink to the framework files. You should check these files since 46 | # you don't know for sure what code you are getting when you git 47 | # clone/pull 48 | home_files_to_backup=".bash_profile .bashrc .vimrc load_drop_directories.rc" 49 | inform "Linking your dot files to the framework files" 50 | # regular files 51 | for f in $home_files_to_backup; do 52 | homelink "$f" 53 | done 54 | # and the directories 55 | for dropdir in $(ls ${source_dir} | grep '\.d' 2>/dev/null); do 56 | homelink "$dropdir" 57 | done 58 | 59 | priv="${HOME}/private.d" 60 | if ! [ -d $priv ]; then 61 | inform "Creating $priv, put anything private in there that you want to 62 | get loaded. See the new *.d directories in ${HOME} for examples" 63 | mkdir "$priv" # for your secret sauce, it will get loaded automatically 64 | # put stuff in private.d, and don't forget to chmod them 65 | inform "Setting perms on private.d to RWX by owner only" 66 | chmod -R 700 "$priv" # or whatever 67 | fi 68 | -------------------------------------------------------------------------------- /bash/functions.d/S30proxystate.rc: -------------------------------------------------------------------------------- 1 | # 2 | # Functions used to change or display the proxy state 3 | # 4 | 5 | debug "proxystate.rc" 6 | 7 | # investigate function is repeated here for portability but, we 8 | # only define it if investigate isn't already a defined function 9 | if ! type -t investigate &> /dev/null; then 10 | debug "investigate function was not previously declared, doing so now" 11 | # allows you to easily debug variables as varname:varvalue or similar 12 | investigate() { 13 | # if $3 isn't given, don't prefix output with anything 14 | local output_prefix='' # could be something like [*] 15 | if [ -n "$3" ]; then output_prefix="$3";fi 16 | 17 | # if $2 isn't given, default separator to something 18 | local output_sep=": " # could be ", " ": " etc 19 | if [ -n "$2" ]; then output_sep="$2";fi 20 | 21 | # if $1 is given, then good, if not, well jeez, don't do anything 22 | local var2investigate='' 23 | if [ -n "$1" ]; then 24 | var2investigate="$1" 25 | echo -n "${output_prefix}${var2investigate}${output_sep}" 26 | v='echo -n $' 27 | v="${v}$(echo -n $var2investigate)" 28 | eval $v 29 | echo 30 | fi 31 | } 32 | 33 | export -f investigate 34 | fi 35 | 36 | # establish proxy site values from either env or set it explicitly 37 | # establish your own https proxy if different than http 38 | if [ -n "$MYPROXY" ]; then 39 | prox="$MYPROXY" 40 | else 41 | prox="http://your-proxy-here.com:8080" 42 | fi 43 | # NOTE, we don't read the MYPROXY value at function runtime to help prevent 44 | # malicious use of the MYPROXY env var. If you want to re-define the proxies 45 | # either by re-reading MYPROXY or changing the prox var, re-source this file 46 | proxyon() { 47 | export http_proxy=$prox 48 | export https_proxy=$prox # use diff val here if https is diff from http 49 | } 50 | proxyoff() { 51 | unset http_proxy 52 | unset https_proxy 53 | } 54 | 55 | # Display the state of the proxy variables 56 | proxystate() { 57 | local HTTP="off" 58 | local HTTPS="off" 59 | local SOCKS="off" 60 | if export | grep -q http_proxy;then 61 | HTTP=$http_proxy 62 | fi 63 | if export | grep -q https_proxy;then 64 | HTTPS=$https_proxy 65 | fi 66 | if export | grep -q socks_proxy;then 67 | SOCKS=$socks_proxy 68 | fi 69 | # Show the current state of proxy variables 70 | vars2show="HTTP HTTPS SOCKS" 71 | for proto in $vars2show; do investigate $proto;done 72 | } 73 | export -f proxystate 74 | -------------------------------------------------------------------------------- /dot_config/gpg.pub: -------------------------------------------------------------------------------- 1 | -----BEGIN PGP PUBLIC KEY BLOCK----- 2 | Version: GnuPG v2.0.19 (Darwin) 3 | 4 | mQMuBFErrG0RCAC/TfsFJa0V8+ERFsnbczOk+8cSYl9Uyu0yHE0NgS0qrD2o/ubA 5 | Nk3rbLWV2vEGLhv1qbixGmg/t4iDFUDkHLdKHwSrMrgc5OuU2RnLEcPgS6xsuZDy 6 | KmHffmGpBKF2RedNbxxG/U899jaUeXipFCbtjC6f86ACXGAB+wjhUGWJtIQf7xiQ 7 | cu1CtGKErQ33v4oE8M6SIjTZklxtytUU48r506qSH0BPe85jFhvlDathxOce7cS3 8 | MYT1BnTEe2gPJwEuW4xwJqAiRaNXUwPnx19bXKFzv5irD25B9a36fwJfk0uo753U 9 | iaVAZP8sb4S14fFYvaU4VeSui7X6YcNEcZgnAQD/rNsap0vJAbWaTXNZcNKNBzGV 10 | DmNRXrBZWqQ2Z7jiiQgAtQXwsQ8n5dRV3rMVYnBuhDrMg2vXhUoXD5AH6AwCWXBh 11 | CiuWBGULY8JMwltC0nUTFySgUC2+rP+O9la916XsaC+UNde51xu8BsFEvoxpryRg 12 | 6gQx7Gm7cLBkp9Ud80qYDGL7Fzt5LYW6UVln9N7ih3ls77oZHRrBOEBYB52ZEL3X 13 | o1LtwcN3Lw3ycnrdgFOmewuelriYyqCqk1xZO1eODx3alw0KelASmr/o2rfQNH67 14 | 9oTCFgYzH1TGABFjqmwSIRa+0VRCWyvlDAs4827QE8reMj4RTZJbERuS6p//RTU8 15 | yIgpO8Y09s/P/kb7m6Lx/+kapKGtmVNsymo3W7/FxggAnacvvMUxh78fS/5FynYe 16 | TqVQigQeJwqyxepFwFwqw9ne8ApbsUUXImbhoMHrlNSxFwNfBHaIeeS8/Bivt+P+ 17 | 4MobD4TecaYSwxUygSDywNXiFqFtpSqY2o9C0+uzmubqWzGRuOAdDUcu2YTi1tX3 18 | /uNmh214K4P2uqkBJvBzKUYsXoBDAEBoqua6KGwWesRib3Yv4EOVJJwQtsuBUxZ3 19 | qwW07dBhJIM8vijBdAKdP8jHiEMJir0zMRJG8o0tNIZ/s2SYmRF3rCgVD12UzB4X 20 | f7XNLOXu3Lmwh3LmrSLXiajeMgwNi9PGM3Dvy+7+eQZLSMhG9FXYpCw9STlMY+Yf 21 | 9bQ9Sm9zaHVhIEEuIFNtaXRoICh5b3Uga25vdyBpdCdzIG1lIHBsYXlhKSA8bGF6 22 | eWRqOThAZ21haWwuY29tPoh6BBMRCAAiBQJRK6xtAhsDBgsJCAcDAgYVCAIJCgsE 23 | FgIDAQIeAQIXgAAKCRCSNJNpuZGnQp9OAP9aMBJ+aBkVG7YHoNkI5lG8QL9HtnT2 24 | nCjtNi+oatOY7gD/Rlt/qsM2uAnAIFpeDMNwD+1w7Nlnh8Ujs0qqlrCWjEG5Ag0E 25 | USusbRAIAMjg7foplt+P9vIX2Spb58UWkD08lKi4jYC2O5LGOTdzoiqy0dCwQnR4 26 | zqlt3kF/t5LvmxfulxSrgoicSxFDUJ9wqeAPvNYH8HlzQal8OQ4gh3mM72lc4kGL 27 | km7EzZk7YM5rewjFQdrfl0BcYyOBZVr4/re6wVVaLVj4yuZidIKdvmMLIYntVeOa 28 | H3vm52s8g8bFZWR5bKyN5TynKDkfnkLh802VGYo6pBbP64GTzdOnA0jtHyiqog4n 29 | tTiS53SqqcW/6vqL+mBqwqFMjNDsngHN4Eg5uIVl9s3H3LlpeZaLslaOZS7hCAQu 30 | SYTLm1py61w8z0Eq09mvePK+jV1OO0sAAwYH/2EWD8IJKUtKBJXRrWIIjRWkjhkj 31 | H+n0Rw4owY/I2GO+tsmwFxUgPiawCyO3YWcCR8vsVVLKeNc4Q0MtSB72dir4ANjV 32 | JGA4wxoUxyWb2Z7e9ljPLnOAEm3bGyz33qxE5zBWlBZD9+T5kdMBU5iaaGdpZgx4 33 | BAkNfc7qGgOdxHWXdKZKLTQsJ/D//QHJsedlSVDybbpmatVFg6CM3yxNkU0nhnu9 34 | V8s9CsLnj+8hu7OWtVr6IOx6+/1SJN5ZeoqTn3Htyj7fs9zvHLZ7fb+ej1R67aVd 35 | wPjwyWIqx659B33F3WWaytWtGD/RMgDhkRMUTB3JfrrfowBp/BoIvjKqXQKIYQQY 36 | EQgACQUCUSusbQIbDAAKCRCSNJNpuZGnQix1AQCz/YXEfY+Fd6abLIdi1ya3XXbX 37 | 25z0B+8HcXjLNiIuXwEA32wlsGYcKjDVaXpaLDYyjp7xWgXzdyUMgH90dSxiAzM= 38 | =oUdl 39 | -----END PGP PUBLIC KEY BLOCK----- 40 | -------------------------------------------------------------------------------- /ssh/mount_sshfs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | MOUNT_POINT="${HOME}/sshfs" # like /Volumes/sshfs or /mnt/sshfs 4 | #REMOTE_PATH_TO_MOUNT="/vmfs/volumes/datastore_RAID" # like /vmfs/volumes/datastore1 5 | REMOTE_PATH_TO_MOUNT="/" 6 | PATH_TO_SSHFS="sshfs" # just use "sshfs" if it's in root's path 7 | SSH_USER="user" # usually root for an esxi server unless you changed stuff 8 | SSH_SERVER="server" # IP or hostname of esxi server 9 | LOCAL_USER_ID=501 # The UID of the local user to map to remote user 10 | LOCAL_GROUP_ID=20 # The GID of the local group to map to remote group 11 | # The UID/GID help avoid permissions/ownership issues 12 | SSH_KEY="${HOME}/.ssh/rsa" 13 | OTHER_SSH_OPTIONS="allow_other no_readahead noappledouble nolocalcaches" 14 | # use "StrictHostKeyChecking=no" if you want ssh to ignore if a machine's ssh key has changed, but you can be MitM'd 15 | SSHFS_DEBUG_OPTIONS="debug,sshfs_debug,loglevel=debug" 16 | 17 | # mkdir if nec 18 | if ! [ -d "$MOUNT_POINT" ]; then 19 | mkdir -p "$MOUNT_POINT" && echo "[*] Created $MOUNT_POINT" 20 | fi 21 | 22 | echo "[*] Unless you have passwordless sudo or have sudo'ed recently, the first " 23 | echo "[*] password request is for sudo, the second is for the ssh server, unless you are using keys" 24 | 25 | command="$PATH_TO_SSHFS ${SSH_USER}@${SSH_SERVER}:${REMOTE_PATH_TO_MOUNT} $MOUNT_POINT" 26 | # add ssh key identity if given 27 | if [ -n "$SSH_KEY" ]; then command="$command -o IdentityFile=$SSH_KEY";fi 28 | # add local user id option if given 29 | if [ -n "$LOCAL_USER_ID" ]; then command="$command -o idmap=user -o uid=$LOCAL_USER_ID";fi 30 | # add local group id option if given (this isn't supported by all implementations) 31 | if [ -n "$LOCAL_GROUP_ID" ]; then command="$command -o gid=$LOCAL_GROUP_ID";fi 32 | # add all the 'other' options 33 | if [ -n "$OTHER_SSH_OPTIONS" ]; then 34 | for opt in $OTHER_SSH_OPTIONS; do 35 | command="$command -o $opt"; 36 | done 37 | fi 38 | # add sshfs debug options if given 39 | if [ -n "$SSHFS_DEBUG_OPTIONS" ]; then command="$command -o $SSHFS_DEBUG_OPTIONS";fi 40 | echo "[*] Running the following command:" 41 | echo "sudo $command" 42 | sudo $command 43 | # sshfs username@hostname:remote_path local_mount_point -o idmap=user -o allow_other -o uid=1001 -o gid=1001 44 | # idmap=user,uid=501,no_readahead,noappledouble,nolocalcaches 45 | -------------------------------------------------------------------------------- /useful_scripts/install_pianobar.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # a dir (GIT_DIR) will be created and a git repo will be cloned there, i.e. src code goes there 4 | 5 | INSTALL_DIR="/usr/local/src/pianobar" 6 | SRC_DIR="/usr/local/src/pianobar" 7 | PKGS="git-core build-essential libao-dev libmad0-dev libfaad-dev libjson0-dev" 8 | 9 | function echo2(){ 10 | echo "[*] $1" 11 | } 12 | 13 | echo2 "Installing required packages if nec" 14 | sudo apt-get install -y $PGKS 15 | 16 | echo2 "Downloading the pianobar source code as git repo to ${SRC_DIR}" 17 | 18 | # git cloning 19 | sudo git clone https://github.com/PromyLOPh/pianobar.git $SRC_DIR 20 | cd $SRC_DIR 21 | 22 | # if *_DIR's don't exist already, make them 23 | for d in "$INSTALL_DIR $SRC_DIR";do 24 | if ! [ -d "$d" ]; then sudo mkdir -p $d;fi 25 | done 26 | echo2 "Compiling pianobar and installing to $INSTALL_DIR" 27 | sudo make -C ${INSTALL_DIR} clean 28 | sudo make -C ${INSTALL_DIR} 29 | sudo make -C ${INSTALL_DIR} install 30 | echo2 "Creating softlink in /usr/bin" 31 | # create a softlink to pianobar in /usr/bin so it will be in our paths going forward 32 | # altho it might already be in the path if INSTALL_DIR was changed to something in the path 33 | sudo chmod 777 $INSTALL_DIR/pianobar 34 | sudo ln -sf $INSTALL_DIR/pianobar /usr/bin/pianobar 35 | 36 | # optional, create a config file at ~/.config/pianobar/config 37 | # keep in mind where you want this config, ie /root or /home/user etc, if running this as root 38 | # best thing to do is run this with sudo so you're home dir will not become /root 39 | echo2 "Copying example config to ~/.config/pianobar, if it doesn't already exist" 40 | echo2 "The dir will be created if it doesn't exist" 41 | CONFIG_DIR="$(readlink -f ~/)/.config/pianobar" 42 | if ! [ -f ${CONFIG_DIR}/config ]; then 43 | mkdir -p $CONFIG_DIR 44 | cp ${INSTALL_DIR}/contrib/config-example ${CONFIG_DIR}/config 45 | fi 46 | # edit the config, most notably: user, password, and autostart_station 47 | # to get your station id, press 'i' while pianobard is running, it's ~18 digit number 48 | echo2 49 | echo2 "#####################################################################" 50 | echo2 "Use your favoriite editor to edit the config such as: vim ${config_dir}/config" 51 | echo2 "You'll probably want to edit user, password, and autostart_station, but up to you" 52 | echo2 "#####################################################################" 53 | echo2 54 | 55 | # cleanup 56 | #rm -rf "$SRC_DIR" # only do this if SRC_DIR and INSTALL_DIR are different, 57 | # # you will remove the binary 58 | exit 0 59 | -------------------------------------------------------------------------------- /esxi/install_vmware_tools_ubuntu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # you must mount the vmware tools iso by right-clicking the host in viclient, goto guest, install/upgrade vmware tools 4 | # you'll see it in dmesg when you do, try dmesg | sr0 5 | 6 | MOUNT_POINT="/media/cdrom" 7 | CDROM_DEVICE="/dev/cdrom" 8 | UNZIP_DIR="/tmp" 9 | 10 | mkdir_if_nec() { 11 | if ! [ -d "$1" ]; then 12 | sudo mkdir -p "$1" 13 | fi 14 | } 15 | 16 | inform() { 17 | echo "[*] $@" 18 | } 19 | 20 | inform "Updating packages" 21 | sudo apt-get update > /dev/null 22 | sudo apt-get -y upgrade 23 | 24 | inform "Creating mount point ($MOUNT_POINT) if necessary" 25 | mkdir_if_nec "$MOUNT_POINT" 26 | 27 | inform "Mounting the vmware tools ISO, you will likely see a write-protected/read-only message" 28 | sudo mount "$CDROM_DEVICE" "$MOUNT_POINT" 29 | 30 | # You should see a message similar to: mount: block device /dev/sr0 is write-protected, mounting read-only 31 | 32 | inform "Creating unzip dir ($UNZIP_DIR) if nec" 33 | mkdir_if_nec "$UNZIP_DIR" 34 | cd "$UNZIP_DIR" 35 | 36 | inform "Copying installer to unzip dir ($UNZIP_DIR)" 37 | sudo cp "$MOUNT_POINT"/VM*.tar.gz . 38 | 39 | inform "Installing build tools as necessary" 40 | sudo apt-get -y install gcc linux-headers-server build-essential 41 | 42 | inform "Unmounting $MOUNT_POINT" 43 | sudo umount "$MOUNT_POINT" 44 | # you could also remove the $MOUNT_POINT if you wanted, but we don't presume 45 | 46 | inform "Decompressing installer" 47 | sudo tar xzf VM*.tar.gz 48 | cd vmware-tools-dist* 49 | 50 | # To prevent the potential error below, on Ubuntu 11.10+, create a special directory 51 | # 'Unable to create symlink “/usr/lib64/libvmcf.so” pointing to file "/usr/lib/vmware-tools/lib64/libvmcf.so/libvmcf.so"' 52 | inform "Creating lib64 dir (/usr/lib64) if nec" 53 | mkdir_if_nec "/usr/lib64" 54 | 55 | # Run the Install Script. The -d flag automatically answers the default to all questions. To customize it, just omit the -d. 56 | inform "Starting installer using default options" 57 | sudo ./vmware-install.pl -d 58 | 59 | inform "***************************************************** [*]" 60 | inform " [*]" 61 | inform " !!! WARNING! !!! [*]" 62 | inform " [*]" 63 | inform " REBOOTING in 5 seconds unless you ctl-C to quit [*]" 64 | inform " [*]" 65 | inform " !!! WARNING! !!! [*]" 66 | inform " [*]" 67 | inform "***************************************************** [*]" 68 | sleep 5 && sudo reboot 69 | -------------------------------------------------------------------------------- /bash/bashrc.d/S50git_ruby_shell_additions.rc: -------------------------------------------------------------------------------- 1 | # By default, this file will affect the PS1 shell prompt 2 | 3 | # 4 | # Build a more complex dev shell prompt 5 | # 6 | 7 | debug "git_ruby_shell_additions" 8 | 9 | # Load RVM into a shell session *as a function* (if non-system-wide install) 10 | rvm_func="$HOME/.rvm/scripts/rvm" 11 | if [ -x "$rvm_func" -a -s "$rvm_func" ]; then 12 | source "$rvm_func" 13 | # Add RVM to PATH for scripting 14 | export PATH=$PATH:$HOME/.rvm/bin 15 | fi 16 | 17 | # Git and RVM prompting 18 | git-current-branch() { 19 | # do not put spaces in these messages 20 | local MSG_NOT_GIT_REPO="not_repo" 21 | local MSG_GIT_UNAVAILABLE="git_unavail" 22 | 23 | if which git &> /dev/null; then 24 | if git branch &> /dev/null; then 25 | git branch 2> /dev/null | grep \* | cut -d ' ' -f 2- 26 | else 27 | echo $MSG_NOT_GIT_REPO 28 | fi 29 | else 30 | echo $MSG_GIT_UNAVAILABLE 31 | fi 32 | } 33 | 34 | orig_prompt="$PS1" 35 | #orig_prompt="[\u@\h \W]\\$ " # set this to "$PS1" to preserve your current prompt 36 | #bold_prompt="\[$(tput bold)\][\u@\h \W]\\$ " 37 | BOLD="\[$(tput bold)\]" 38 | REGULAR="\[$(tput sgr0)\]" 39 | export shorten="14" # set to '' for no shortening, otherwise number of chars to display for long inputs 40 | 41 | # shorten a string passed as $1 to the length given as $2 42 | shorten() { 43 | str="$1" 44 | len=$2 45 | #if $str -eq "metasploit-framework"; then 46 | # echo "msf" 47 | #else 48 | echo $str | cut -c 1-$len 49 | #fi 50 | } 51 | 52 | # check if the shorten variable has a value, if so, send $1 to be shortened 53 | check_shorten() { 54 | if [ -n "$shorten" ]; then # this will explode if shorten is 0, but I don't care 55 | echo "$(shorten $1 $shorten)" 56 | else 57 | echo $1 58 | fi 59 | } 60 | 61 | # add git branch info, shortened, to the shell prompt 62 | prompt_git() { 63 | local ps=$BOLD 64 | ps="${ps}(\$(check_shorten \$(git-current-branch)))" 65 | ps="${ps}${REGULAR}$orig_prompt" 66 | export PS1="$ps" 67 | } 68 | 69 | # add ruby ver info, shortened, to the shell prompt 70 | prompt_ruby() { 71 | if which rvm &> /dev/null; then 72 | local ps=$BOLD 73 | ps="${ps}(\$(check_shorten \$(~/.rvm/bin/rvm-prompt v p g)))" 74 | ps="${ps}${REGULAR}$orig_prompt" 75 | export PS1="$ps" 76 | else 77 | export PS1="(no rvm)$orig_prompt" 78 | fi 79 | } 80 | 81 | # add both git branch and ruby ver info, shortened, to the shell prompt 82 | prompt_git_ruby() { 83 | local ps=$BOLD 84 | if which rvm &> /dev/null; then 85 | ps="${ps}(\$(check_shorten \$(~/.rvm/bin/rvm-prompt v p g)))" 86 | fi 87 | if which git &> /dev/null; then 88 | ps="${ps}(\$(check_shorten \$(git-current-branch)))" 89 | fi 90 | ps="${ps}${REGULAR}$orig_prompt" 91 | export PS1="$ps" 92 | } 93 | 94 | # actually change the prompt 95 | prompt_git_ruby 96 | -------------------------------------------------------------------------------- /bash/.vimrc: -------------------------------------------------------------------------------- 1 | " All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just 2 | " /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime 3 | " you can find below. If you wish to change any of those settings, you should 4 | " do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten 5 | " everytime an upgrade of the vim packages is performed. It is recommended to 6 | " make changes after sourcing debian.vim since it alters the value of the 7 | " 'compatible' option. 8 | 9 | " This line should not be removed as it ensures that various options are 10 | " properly set to work with the Vim-related packages available in Debian. 11 | runtime! debian.vim 12 | 13 | " Uncomment the next line to make Vim more Vi-compatible 14 | " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous 15 | " options, so any other options should be set AFTER setting 'compatible'. 16 | "set compatible 17 | 18 | " Vim5 and later versions support syntax highlighting. Uncommenting the next 19 | " line enables syntax highlighting by default. 20 | syntax on 21 | hi ExtraWhitespace ctermbg=darkgreen guibg=darkgreen 22 | au Filetype ruby match ExtraWhitespace /\s\+$\|\t\+ \+\| \+\t\+/ 23 | "hi ExtraWhitespace ctermbg=darkgreen guibg=darkgreen 24 | "match ExtraWhitespace /\s\+$/ 25 | 26 | " If using a dark background within the editing area and syntax highlighting 27 | " turn on this option as well 28 | set background=dark 29 | 30 | " Uncomment the following to have Vim jump to the last position when 31 | " reopening a file 32 | if has("autocmd") 33 | au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") 34 | \| exe "normal! g'\"" | endif 35 | endif 36 | 37 | " Uncomment the following to have Vim load indentation rules according to the 38 | " detected filetype. Per default Debian Vim only load filetype specific 39 | " plugins. 40 | if has("autocmd") 41 | filetype indent on 42 | endif 43 | 44 | " Some of this from https://gist.github.com/todb-r7/4658778 45 | set nocompatible 46 | colorscheme slate 47 | set background=dark 48 | filetype plugin indent on 49 | set hls 50 | set ruler 51 | 52 | " Idiotmatic Ruby default tab indentation 53 | set tabstop=2 softtabstop=2 shiftwidth=2 expandtab shiftround smarttab 54 | retab 55 | 56 | " Automatic text wrapping. 57 | "set textwidth=82 58 | 59 | " http://vim.wikia.com/wiki/Highlight_unwanted_spaces 60 | set list listchars=tab:»·,trail:· 61 | 62 | set number 63 | " The usual settings (not VI compat mostly) 64 | "set showcmd " Show (partial) command in status line. 65 | set showmatch " Show matching brackets. 66 | set ignorecase " Do case insensitive matching 67 | "set smartcase " Do smart case matching 68 | "set incsearch " Incremental search 69 | "set autowrite " Automatically save before commands like :next and :make 70 | "set hidden " Hide buffers when they are abandoned 71 | set mouse-=a " Disable auto entering Visual mode when mouse selecting 72 | set colorcolumn=80 " Display a line at 80 chars 73 | -------------------------------------------------------------------------------- /bash/functions.d/S20input_output.rc: -------------------------------------------------------------------------------- 1 | # 2 | # I/O functions, those generally involving stdout, stderr, stdin 3 | # 4 | 5 | debug "input_output.rc" 6 | 7 | # most of these functions will check the length of var $quiet and will not 8 | # output anything (or less at least) if $quiet is not empty, allows scripts 9 | # to do stuff like if [ "$arg" == "-q" ]; then quiet=1;fi 10 | puts() { 11 | # echos '[*] ' and arguments with the -e and -n flags (to stdout) 12 | # only print something if quiet is empty 13 | [ -z "$quiet" ] && echo -en "[*] $@" 14 | } 15 | export -f puts 16 | 17 | eqo() { 18 | # echos the arguments with no frills, but only if not quiet 19 | # only print something if quiet is empty 20 | [ -z "$quiet" ] && echo "$@" 21 | } 22 | export -f eqo 23 | 24 | warn() { 25 | # warnings, i.e. non-fatal errors to stdout 26 | # echos '[-] ' and arguments with the -e and -n flags (to stdout) 27 | # only print something if quiet is empty or not empty but less than a value? 28 | # local quiet_threshold 29 | # [ $quiet -lt $quiet_threshold ] && echo -en "[-] $@" 30 | [ -z "$quiet" ] && echo -en "[-] $@" 31 | } 32 | export -f warn 33 | 34 | die() { 35 | # fatal or nearly-fatal errors, if you give a second argument, it is used as an exit code 36 | # echos '[!] ' and first argument with the -e and -n flags and redirect to stderr 37 | # if a second argument is given, this function will exit with that argument as the code 38 | # NOTE: $quiet does not affect the output 39 | echo -en "[!] $1" >&2 40 | if [ $2 ]; then exit $2;fi 41 | } 42 | export -f die 43 | 44 | # allows you to easily debug variables as varname:varvalue or similar 45 | investigate() { 46 | # if $3 isn't given, don't prefix output with anything 47 | local output_prefix='' # could be something like [*] 48 | if [ -n "$3" ]; then output_prefix="$3";fi 49 | 50 | # if $2 isn't given, default separator to something 51 | local output_sep=": " # could be ", " ": " etc 52 | if [ -n "$2" ]; then output_sep="$2";fi 53 | 54 | # if $1 is given, then good, if not, well jeez, don't do anything 55 | local var2investigate='' 56 | if [ -n "$1" ]; then 57 | var2investigate="$1" 58 | echo -n "${output_prefix}${var2investigate}${output_sep}" 59 | v='echo -n $' 60 | v="${v}$(echo -n $var2investigate)" 61 | eval $v 62 | echo 63 | fi 64 | } 65 | export -f investigate 66 | 67 | function fastrm { 68 | # if perl is readily available, use it's 'unlink' to remove stuff, it's much faster than 'rm' 69 | # This is a hack to keep the syntax the same as that for 'rm' and to avoid 70 | # invoking 'perl -nle' a bunch of times, which would be somewhat counterproductive 71 | # There's a smarter way using 'find' find $DIR -type f -exec perl -nle unlink '{}' \; 72 | if [ $(which perl) ] &>/dev/null; then 73 | templist= 74 | for item in "$@"; do templist="${templist}${item}\n";done 75 | echo -en $templist | perl -nle unlink 76 | else 77 | # else use rm -rf as the fall back 78 | rm -rf "$@" 79 | fi 80 | } 81 | export fastrm 82 | -------------------------------------------------------------------------------- /useful_scripts/progression.rb: -------------------------------------------------------------------------------- 1 | # Time.local(2011,"may",21,18,0,0 2 | # usage examples 3 | # p = Progression.new(0, 5000);p.show {|curr| sleep 1;curr + 500} 4 | # p = Progression.new(0, 5000);p.fill_upward = true;p.show {|curr| sleep 1;curr + 500} 5 | # p = Progression.new(0, 60);p.show {|curr| sleep 2;curr + 2} 6 | # p = Progression.new(Time.now, Time.now + 10);p.show 7 | # p = Progression.new(Time.now, Time.now + 10);p.show {sleep 1; Time.now} 8 | # p = Progression.new(Time.now, Time.now + 10);p.fill_upward = true;p.show 9 | # above example is broken 10 | 11 | class Progression 12 | attr_accessor :start_val, :stop_val, :title, :color, :end_val, :fill_upward 13 | attr_reader :progress, :last_length, :orig_delta, :remaining, :current_value 14 | 15 | # TODO: no color opt, hide method, pause?, stop? 16 | # use block to calculate remaining or when loop should stop 17 | MAX_BAR_LENGTH = 100 18 | 19 | def initialize(color = true, title = "Progress", start_val, end_val) 20 | @start_val = start_val 21 | @current_value = @start_val 22 | @end_val = end_val 23 | @title = title 24 | @color = color 25 | @orig_delta = end_val - start_val 26 | @fill_upward = false 27 | # negate remaining if 28 | #@remaining = @remaining < 0 ? @remaining * -1 : @remaining 29 | @last_length = 8 30 | end 31 | 32 | def show(&block) 33 | puts "DEBUG: start_val:#{start_val}, current_value:#{current_value}, " + 34 | "end_val:#{end_val}, orig_delta:#{orig_delta}, title:#{title}, " + 35 | "color:#{color}, fill_upward:#{fill_upward}" 36 | print(title + " ") 37 | block ||= Proc.new {sleep 1;Time.now} 38 | update(block) until remaining <= 0 39 | # render an empty an empty progress bar 40 | @current_value = end_val 41 | render_basics 42 | render_progress(0) 43 | puts 44 | end 45 | 46 | # def decrement(amount) 47 | # increment(amount * -1) 48 | # end 49 | 50 | # def increment(amount) 51 | # remaining = remaining + amount 52 | # end 53 | 54 | def update(block) 55 | render_basics 56 | render_progress(remaining_percentage) 57 | @current_value = block.call(current_value) 58 | end 59 | 60 | private 61 | 62 | def render_basics 63 | progressbar_length = 106 + last_length 64 | move_cursor = "\e[#{progressbar_length}D" 65 | print(move_cursor + (" " * progressbar_length) + move_cursor) 66 | STDOUT.flush 67 | print("\e[33m#{title} \e[0m") 68 | end 69 | 70 | def render_progress(percent) 71 | print("\e[33m[\e[0m") # yellow [ 72 | fill_amount = percent.to_i 73 | space_amount = MAX_BAR_LENGTH - percent.to_i 74 | if fill_upward 75 | # then exchange the values 76 | fill_amount, space_amount = space_amount, fill_amount 77 | end 78 | 79 | print("\e[31m=\e[0m" * fill_amount) # red = 80 | if percent < 97 81 | print("|#{percent.to_s}%") 82 | space_amount -= 4 83 | end 84 | print(" " * space_amount) # spaces 85 | print("\e[33m]\e[0m") # yellow ] 86 | #print(" cv:#{current_value}, rem:#{remaining}") 87 | # print("\e[31m=\e[0m" * [[percent.to_i, 46].min, 0].max )# red = 88 | # print(" " * [46 - [percent.to_i, 46].min, 46].min) 89 | # print("\e[33m#{remaining.to_s}\e[0m") # yellow 90 | # print("\e[31m=\e[0m" * [percent.to_i - 54, 0].max) # red = 91 | # print(" " * [46 - (percent.to_i - 54), 46].min) 92 | # print("\e[33m]\e[0m") # yellow ] 93 | 94 | # new_length = remaining.to_s.length 95 | # if last_length > new_length 96 | # print " " * (last_length - new_length) 97 | # print "\e[#{last_length - new_length}D" 98 | # end 99 | # @last_length = new_length 100 | STDOUT.flush 101 | end 102 | 103 | def remaining_percentage 104 | # since orig_delta is an int if start & end are ints, remaining truncates 105 | remaining * 100 / orig_delta 106 | end 107 | 108 | def remaining 109 | end_val - current_value 110 | end 111 | end -------------------------------------------------------------------------------- /msf/irc_nuggets: -------------------------------------------------------------------------------- 1 | irc_nuggets 2 | 3 | egypt 4 | 11:25 the default exe parses the template and puts shellcode in the .text section 5 | 11:26 the exe-small method uses the old PAYLOAD: tag technique 6 | 11:26 which is easier, but requires a custom-built exe as the tempalte template, too 7 | 11:26 whereas the default technique is more generic and works with pretty much any exe 8 | 11:27 also, it makes metasploit technically a virus. since it can infect executables 9 | 10 | // is the general format 11 | since it doesn't have a / at the end, it's a single 12 | there is no non-staged windows meterpreter 13 | 14 | kernelsmith 15 | egypt: is there every going to be an unstaged meterpreter_reverse_http/s? like after meterpreter goes into it's own repo? Would be useful since the http/s payloads aren't dependent on constant connectivity like reverse_tcp 16 | 17 | You would write a post mod that uploads and silently installs pcap, then load the C-extension which would run in memory on the vic 18 | 11:35 The C-extension links your C code to meterpreter, to it's a specific format. The incognito one is a good example, possibly not the least complex tho 19 | 11:36 extensions are here: https://github.com/rapid7/metasploit-framework/tree/master/external/source/meterpreter/source/extensions 20 | 11:36 the lanattacks one is the one egypt mentioned 21 | 11:36 that's where the C is located 22 | 11:36 the ruby for that is… sec 23 | 11:39 here: https://github.com/rapid7/metasploit-framework/tree/master/lib/rex/post/meterpreter/extensions 24 | 11:39 and if your extension is going to add commands to the meterpreter user interface, then you need something here: https://github.com/rapid7/metasploit-framework/tree/master/lib/rex/post/meterpreter/ui/console/command_dispatcher 25 | 11:40 sounds confusing, but it's not really 26 | 11:41 the command-dispatcher location is where commands are added, so when somebody loads your extension from the meterpreter/extensions folder they get those new commands, and that extension will push the C code, compiled as a dll, you put in that external directory 27 | 11:42 I don't know why lanattacks has no command-dispatcher, I guess they don't add any commands 28 | 11:43 I have written command-dispatcher before, they are actually pretty easy, I have not written an extension, I have started to, but never finished. Looks like scriptjunkie has, he's on IRC quite a bit, but possibly not during the work day. I think his daily work environment is pretty locked down so he might not have irc 29 | 11:45 obviously the paths in those urls are the same as in your installation starting at "lib" which is in the root of your msf install, which is usually something like /opt/metasploit etc 30 | 31 | egypt 32 | 3:14 basically, wrap at 80; use "# @param name [Type] Description." for arguments 33 | 3:14 and "# @return [Type] Optional description" for return values 34 | 35 | could you wrap meterpreter so that the socket it gets handed is from a DLL you control, which responds to the communication from the meterpreter and then passes it along on another socket home once you get bi-directional communication patched up? 36 | i don't know how complex the response messages are from the backend for meterpreter 37 | but if they aren't terribly complex, at least that would allow you to not have to change meterpreter and maintain your changes going forward against the trunk 38 | that's the tack azerton is taking to get dns tunneling 39 | semantics being, do you have to parse anything coming from it and then respond accordingly or can you just give it the equivalent of an HTTP200 all the time 40 | 41 | mihi 42 | 3:11 thelightcosine: 1) http://schierlm.users.sourceforge.net/CVE-2012-1723.html the gray paragraph at the top should answer one of your questions 2) if you want to psexec against MS Security Essentials, just use original psexec binary and do your stuff thru the command shell - the original psexesvc.exe is not flagged 43 | 3:11 thelightcosine: 3) you can do "powershell -ExecutionPolicy Unrestricted foo.ps1" even if you have no perm to Set-ExecutionPolicy (and it works) 44 | -------------------------------------------------------------------------------- /bash/.bash_profile: -------------------------------------------------------------------------------- 1 | # ~/.bash_profile generally gets executed from the following sequence 2 | # when logging in via an INTERACTIVE LOGIN, see below for more 3 | # 1) execute /etc/profile 4 | # then execute the FIRST of the following which exists and is readable 5 | # 2a) ~/.bash_profile # <-- often (but not always) sources ~/.bashrc 6 | # 2b) ~/.bash_login 7 | # 2c) ~/.profile 8 | 9 | # AN INTERACTIVE LOGIN is typically when you login at a TTY by hitting 10 | # Ctrl+Alt+F2 etc or when logging in via SSH. You can check if 11 | # BASH was started as a login-shell by running: 12 | # shopt login_shell # => if result is 'on' then it's a login shell 13 | 14 | # NOTE: I only maintain the additions to this file as I don't currently 15 | # want to overwrite the entire default version. This file should be 16 | # appended to the end of the default version. See the 17 | # augment_my_env.sh script 18 | 19 | export INDENT_VAL=" " # value used for indentation 20 | export indent="" # the current total indentation to use 21 | 22 | # 23 | # DEBUGGING 24 | # 25 | # To enable debug output, uncomment the following line 26 | #export DEBUG_DOT_FILES="true" 27 | debug() { 28 | [ -n "$DEBUG_DOT_FILES" ] && echo "$indent[DEBUG] $@" 29 | } 30 | export -f debug # make this debug function available to child shells 31 | 32 | current=".bash_profile" # can't use $0 going forward as the files are sourced, not ran 33 | debug "Running inside $current" 34 | 35 | IS_OSX=$(uname -a | grep Darwin) # close enuf for me 36 | # export IS_OSX if we end up needing it elsewhere 37 | 38 | # Note, in Linux bashrc is sometimes run automatically for any non-login shell 39 | # by ~/.bash_profile or other dot file, however, OS X by default runs just 40 | # ~/.bash_profile, hence the code below. Additionally, it varies in Linux, 41 | # so we are going to try to handle that. 42 | # run ~/.bashrc if it is executable and non-zero length 43 | script="$HOME/.bashrc" 44 | if [ -n "$IS_OSX" ]; then 45 | debug "We are running in OS X so sourcing $script" 46 | # update PATH, xcode has its own git and it's crappy, we want ours from /usr/local/bin 47 | export PATH="/usr/local/bin:$PATH" 48 | indent+="$INDENT_VAL" 49 | [ -f "$script" -a -x "$script" -a -s "$script" ] && source "$script" 50 | elif [ -n "$BASHRC_COMPLETE" ]; then 51 | # then it's likely that it's NOT already been run, or didn't complete 52 | # BASHRC_COMPLETE is defined and exported when my bashrc file completes 53 | debug "Doesn't seem bashrc has been run, so sourcing $script" 54 | indent+="$INDENT_VAL" 55 | [ -f "$script" -a -x "$script" -a -s "$script" ] && source "$script" 56 | fi 57 | 58 | # ssh-agent if not OS X (OS X uses keychain) 59 | #if [ -z "$IS_OSX" ]; then 60 | # SSHAGENT=/usr/bin/ssh-agent 61 | # SSHAGENTARGS="-s" 62 | # if [ -z "$SSH_AUTH_SOCK" -a -x "$SSHAGENT" ]; then 63 | # eval `$SSHAGENT $SSHAGENTARGS` 64 | # trap "kill $SSH_AGENT_PID" 0 65 | # fi 66 | #fi 67 | 68 | SSH_ENV="$HOME/.ssh/environment" 69 | 70 | function start_agent { 71 | echo "Initialising new SSH agent..." 72 | /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" 73 | echo succeeded 74 | chmod 600 "${SSH_ENV}" 75 | . "${SSH_ENV}" > /dev/null 76 | /usr/bin/ssh-add; 77 | } 78 | 79 | # Source SSH settings, if applicable 80 | if [ -z "$IS_OSX" ]; then 81 | if [ -f "${SSH_ENV}" ]; then 82 | . "${SSH_ENV}" > /dev/null 83 | #ps ${SSH_AGENT_PID} doesn't work under cywgin 84 | ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || { 85 | start_agent; 86 | } 87 | else 88 | start_agent; 89 | fi 90 | fi 91 | 92 | indent="" # reset the current indent 93 | # Finally, call any functions we want to actually be run 94 | # NOTE: If the env var MYPROXY is set, it will affect these proxy functions 95 | echo "[*] Turning on the CLI proxies from $current." 96 | proxyon 97 | echo "[*] The current state of CLI proxy variables:" 98 | proxystate 99 | 100 | # disable debugging if set 101 | unset DEBUG_DOT_FILES 102 | #source ~/.profile 103 | [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* 104 | export PATH=/usr/local/sbin:$PATH 105 | -------------------------------------------------------------------------------- /mac/.bashrc: -------------------------------------------------------------------------------- 1 | # ~/.bashrc: executed by bash(1) for non-login shells. 2 | # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) 3 | # for examples 4 | 5 | # If not running interactively, don't do anything 6 | [ -z "$PS1" ] && return 7 | 8 | # don't put duplicate lines in the history. See bash(1) for more options 9 | #export HISTCONTROL=ignoredups 10 | 11 | # check the window size after each command and, if necessary, 12 | # update the values of LINES and COLUMNS. 13 | shopt -s checkwinsize 14 | 15 | # make less more friendly for non-text input files, see lesspipe(1) 16 | [ -x /usr/bin/lesspipe ] && eval "$(lesspipe)" 17 | 18 | # set variable identifying the chroot you work in (used in the prompt below) 19 | if [ -z "$debian_chroot" -a -r /etc/debian_chroot ]; then 20 | debian_chroot=$(cat /etc/debian_chroot) 21 | fi 22 | 23 | # set a fancy prompt (non-color, unless we know we "want" color) 24 | #case "$TERM" in 25 | #xterm-color) 26 | #PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 27 | # ;; 28 | #*) 29 | # PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 30 | # ;; 31 | #esac 32 | function git_branch { 33 | git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' 34 | } 35 | 36 | # Comment in the above and uncomment this below for a color prompt 37 | PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(git_branch)\$ ' 38 | 39 | # If this is an xterm set the title to user@host:dir 40 | case "$TERM" in 41 | xterm*|rxvt*) 42 | PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"' 43 | ;; 44 | *) 45 | ;; 46 | esac 47 | 48 | # Alias definitions. 49 | # You may want to put all your additions into a separate file like 50 | # ~/.bash_aliases, instead of adding them here directly. 51 | # See /usr/share/doc/bash-doc/examples in the bash-doc package. 52 | 53 | if [ -f ~/.bash_aliases ]; then 54 | . ~/.bash_aliases 55 | fi 56 | 57 | # enable color support of ls and also add handy aliases 58 | export CLICOLOR=1 59 | export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx 60 | if [ "$TERM" != "dumb" ]; then 61 | #eval "`dircolors -b`" 62 | alias ls='ls -a -F' # -G is just too annoying 63 | #alias dir='ls --color=auto --format=vertical' 64 | #alias vdir='ls --color=auto --format=long' 65 | fi 66 | 67 | # enable programmable completion features (you don't need to enable 68 | # this, if it's already enabled in /etc/bash.bashrc and /etc/profile 69 | # sources /etc/bash.bashrc). 70 | #if [ -f /etc/bash_completion ]; then 71 | # . /etc/bash_completion 72 | #fi 73 | 74 | # 75 | ### SSH Stuff 76 | # 77 | 78 | # SSH_ENV="$HOME/.ssh/environment" 79 | 80 | # # start the ssh-agent 81 | # function start_agent { 82 | # echo "Initializing new SSH agent..." 83 | # # spawn ssh-agent 84 | # ssh-agent | sed 's/^echo/#echo/' > "$SSH_ENV" 85 | # echo succeeded 86 | # chmod 600 "$SSH_ENV" 87 | # . "$SSH_ENV" > /dev/null 88 | # ssh-add 89 | # } 90 | 91 | # # test for identities 92 | # function test_identities { 93 | # # test whether standard identities have been added to the agent already 94 | # ssh-add -l | grep "The agent has no identities" > /dev/null 95 | # if [ $? -eq 0 ]; then 96 | # ssh-add 97 | # # $SSH_AUTH_SOCK broken so we start a new proper agent 98 | # if [ $? -eq 2 ];then 99 | # start_agent 100 | # fi 101 | # fi 102 | # } 103 | 104 | # # check for running ssh-agent with proper $SSH_AGENT_PID 105 | # if [ -n "$SSH_AGENT_PID" ]; then 106 | # ps -ef | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null 107 | # if [ $? -eq 0 ]; then 108 | # test_identities 109 | # fi 110 | # # if $SSH_AGENT_PID is not properly set, we might be able to load one from 111 | # # $SSH_ENV 112 | # else 113 | # if [ -f "$SSH_ENV" ]; then 114 | # . "$SSH_ENV" > /dev/null 115 | # fi 116 | # ps -ef | grep "$SSH_AGENT_PID" | grep ssh-agent > /dev/null 117 | # if [ $? -eq 0 ]; then 118 | # test_identities 119 | # else 120 | # start_agent 121 | # fi 122 | # fi 123 | 124 | # show full path in finder title bar 125 | defaults write com.apple.finder _FXShowPosixPathInTitle -bool true 126 | -------------------------------------------------------------------------------- /ruby_dev_env/jcran_guide.txt: -------------------------------------------------------------------------------- 1 | Developer Setup 2 | No-Bitrock setup 3 | Start w/ an ubuntu 10.04+ base 4 | 5 | Install system prereqs: 6 | sudo apt-get install postgresql-8.4 7 | sudo apt-get install libpq-dev 8 | # sudo apt-get install postgresql 9 | Set up Ruby using RVM 10 | Follow instructions here: http://beginrescueend.com/rvm/install/ 11 | rvm install 1.9.1p378 12 | If you run into problems, check the RVM_Troubleshooting Guide 13 | install the compatible version of rubygems 14 | gem install rubygems-update 15 | gem update --system 1.4.2 16 | # rvm all do gem install rubygems-update 17 | # rmv all do gem update --system 18 | install all gems: 19 | actionmailer-2.3.5/ 20 | actionpack-2.3.5/ 21 | activerecord-2.3.5/ 22 | activeresource-2.3.5/ 23 | activesupport-2.3.5/ 24 | authlogic-2.1.3/ 25 | pg-0.9.0/ 26 | rack-1.0.1/ 27 | rails-2.3.5/ 28 | thin-1.2.7/ 29 | #gems="actionmailer actionpack activerecord activeresource activesupport authlogic pg rack rails thin" 30 | # for g in $gems; do rvm all do gem install $g; done 31 | Also these gems are available in the production environment, and may need a manual install, 32 | but should be installed as dependencies of the above 33 | cgi_multipart_eof_fix-2.5.0/ 34 | color-1.4.1/ 35 | daemons-1.0.10/ 36 | eventmachine-0.12.10/ 37 | fastthread-1.0.7/ 38 | gem_plugin-0.2.3/ 39 | hoe-2.6.0/ 40 | json_pure-1.4.2/ 41 | transaction-simple-1.4.0/ 42 | rubyforge-2.0.4/ 43 | rubyzip-0.9.4/ 44 | rake-0.8.7/ 45 | postgres-0.7.9.2008.01.28/ 46 | 47 | checkout from svn (hdm sets up svn acccess via your pubkey) -- SVN_Structure 48 | #svn co --no-externals http://dev.metasploit.com/home/svnr7/projects/pro/ pro 49 | svn co --ignore-externals http://dev.metasploit.com/home/svnr7/projects/pro/ pro 50 | svn co http://dev.metasploit.com/home/svn/framework3/trunk/ framework 51 | symlink the framework directory to pro/msf3 52 | configure postgresql 53 | configure your database.yml 54 | 55 | jcran@disko:~/pro/ui/config$ cat database.yml 56 | test: 57 | adapter: postgresql 58 | database: msf3_test 59 | host: localhost 60 | port: 7336 61 | username: msf3 62 | password: [password] 63 | pool: 5 64 | timeout: 5 65 | development: 66 | adapter: postgresql 67 | database: msf3_dev 68 | host: localhost 69 | port: 7336 70 | username: msf3 71 | password: [password] 72 | pool: 5 73 | timeout: 5 74 | production: 75 | adapter: postgresql 76 | database: msf3_prod 77 | host: localhost 78 | port: 7336 79 | username: msf3 80 | password: [password] 81 | pool: 5 82 | timeout: 5 83 | 84 | start the prosvc 85 | 86 | start the rails service 87 | 88 | pro/ui/script/server -p 3001 89 | 90 | use dev key: Development_Keys 91 | 92 | Setting up an environment to run integration tests: 93 | 94 | see: QA_environment_setup_guide 95 | Bitrock'd Installation setup (Alternative Development Environment) 96 | 97 | The best way to ensure you're working in a production environment is to install w/ the bitrock installer, and replace the packaged tree with a metasploit pro and framework svn checkout. This is an alternative to manually installing the dependencies. 98 | 99 | Install w/ latest installer (3.6.0 at time of writing) 100 | move the codebase snapshot out of the way: 101 | 102 | mv $install_base/apps/pro $install_base/apps/pro_old 103 | 104 | pull down svn to $install_base/apps/pro (or symlink) 105 | 106 | mkdir $install_base/apps/pro 107 | svn co svn+ssh://metasploit.com/home/svnr7/projects/pro/ $install_base/apps/pro 108 | 109 | rm the msf3 directory (pulled in from externals) 110 | pull down msf3 to a separate directory & symlink 111 | 112 | mkdir $install_base/apps/pro/msf3 113 | svn co metasploit.com/home/svn/framework3/trunk/ $install_base/apps/pro/msf3 114 | 115 | run bitrock script - this will copy the database.yml & other config files to the svn tree 116 | 117 | $install_base/apps/pro/bitrocked.rb $install_base/apps/pro_old" 118 | 119 | use dev key: Development_Keys 120 | 121 | 122 | -------------------------------------------------------------------------------- /bash/README.md: -------------------------------------------------------------------------------- 1 | These scripts form a framework for managing BASH configuration etc. It is 2 | modeled after the rc.d startup scripts and is slightly slanted towards git and 3 | ruby. However it's very easy to alter once you get the idea. 4 | 5 | Basically: 6 | In the general case, .bash_profile is executed which sources .bashrc if it 7 | has not already been run. .bash_profile will also source 8 | load_drop_directories.rc which looks for a group of .d diretories and sources 9 | any scripts found in those directories that start with 'S' and end in '.rc'. 10 | To enable some debugging information, edit .bash_profile and uncomment the line: 11 | export DEBUG_DOT_FILES="true". You will then see file searches and loads etc. 12 | This stuff is not ready for primetime, I haven't even written an "install" script 13 | yet, so it's easiest to just do this: 14 | ```Bash 15 | git clone https://github.com/kernelsmith/env-customization.git 16 | ln -s ~/.bash_profile env-customization/bash/.bash_profile 17 | ln -s ~/.bashrc env-customization/bash/.bashrc 18 | ln -s ~/load_drop_directories.rc env-customization/bash/load_drop_directories.rc 19 | for dropdir in $(ls env-customization/bash/*.d); do 20 | ln -s ~/$dropdir env-customization/bash/dropdir 21 | done 22 | mkdir ~/private.d # for your secret sauce, it will get loaded automatically 23 | # put stuff in private.d, and don't forget to chmod them 24 | chmod -R +ox ~/private.d # or whatever 25 | ``` 26 | and put any additional stuff you want to add in the various .d directories. 27 | Generally speaking: 28 | * bashrc.d for core bashrc-like stuff, prompt changes etc 29 | * functions.d for, umm functions you want available to you & your shell 30 | * aliases.d for, umm, aliases. 31 | * private.d for stuff you wouldn't want out there, stuff I don't want on github 32 | You can mix and match the .d dirs, there's nothing magical them or their names, 33 | they are just organizational containers. 34 | 35 | Obviously, with anythign like this, you should review the code so you are 36 | assured it's not doing anything nefarious. 37 | 38 | For Reference, BASH .config file load sequences: 39 | ================================================ 40 | 41 | Interactive Login Shell 42 | -------------------------------- 43 | (typically when you login at the console (Ctrl+Alt+F2 etc) or SSH 44 | You can check if your Bash shell is started as a login-shell by running: 45 | shopt login_shell # on = login shell 46 | 47 | * STARTUP Execution Sequence: 48 | 49 | ** Execute /etc/profile 50 | ** Then execute the FIRST of the following which exists and is readable 51 | **** ~/.bash_profile # which often sources ~/.bashrc 52 | **** ~/.bash_login 53 | **** ~/.profile 54 | 55 | *** In pseudo-code, this might look like: 56 | 57 | ``` 58 | Execute /etc/profile 59 | IF ~/.bash_profile exists THEN 60 | execute ~/.bash_profile # which you should have source ~/.bashrc, see below 61 | ELSE 62 | IF ~/.bash_login exist THEN 63 | execute ~/.bash_login 64 | ELSE 65 | IF ~/.profile exist THEN 66 | execute ~/.profile 67 | END IF 68 | END IF 69 | END IF 70 | ``` 71 | 72 | If none of the above are triggered, bash stops looking for . files and gives a 73 | prompt. Since .bashrc is not read by default in the above situation, you might 74 | want to add, depending on your exact situation, source ~/.bashrc somewhere near 75 | the end of your .bash_profile 76 | 77 | * LOGOUT Execution Sequence: 78 | 79 | ``` 80 | IF ~/.bash_logout exists THEN 81 | execute ~/.bash_logout 82 | END IF 83 | ``` 84 | 85 | Interactive Non-Login Shell 86 | -------------------------------- 87 | (typically when you open a terminal from the GUI) 88 | 89 | * STARTUP Execution Sequence: 90 | 91 | ** Lookup and execute file name stored in ENV variable, typically $HOME/.bashrc 92 | 93 | ``` 94 | IF ~/.bashrc exists THEN 95 | execute ~/.bashrc # typically sources /etc/bashrc if it exists 96 | END IF 97 | ``` 98 | 99 | For more information: 100 | --------------------------------- 101 | Excerpt from man bash: 102 | 103 | *When bash is invoked as an interactive login shell, or as a non-interactive 104 | shell with the --login option, it first reads and executes commands from the 105 | file /etc/profile, if that file exists. After reading that file, it looks for 106 | ~/.bash_profile, ~/.bash_login, and ~/.profile, in that order, and reads and 107 | executes commands from the first one that exists and is readable." 108 | su does not start a login shell by default, you can force it with -l or --login* 109 | -------------------------------------------------------------------------------- /esxi/package_vmx.sh: -------------------------------------------------------------------------------- 1 | #!/bin/ash 2 | 3 | debug_msg() { 4 | debug="true" 5 | if [ -n "$debug" ]; then echo -e "[*] $@";fi 6 | } 7 | 8 | usage() { 9 | echo "USAGE: `basename $0` vmx_file [[vnc_port]|[mac_addy]]" 10 | echo 11 | echo -e "Packages the vmx_file for distibution or cloning etc. Optionally a mac_addy or" 12 | echo -e "vnc_port or both can be given to assign a static mac address and/or enable vnc on" 13 | echo -e "the provided port. The order of args after vmx_file is inconsequential" 14 | echo 15 | echo -e "\tEXAMPLE:" 16 | echo -e "\t $0 /my/coolVM.vmx 5901 00:50:56:XX:YY:ZZ" 17 | echo 18 | # Args 2 & 3 are differentiated by a crappy but effective regex and can be given in any order 19 | # Mac addy should be given in the format shown above (with :) 20 | } 21 | 22 | package_vmx() { 23 | debug_msg "called package_vmx" 24 | debug_msg "args len = $#: vmx:$1 vnc/mac:$2 vnc/mac:$3" 25 | vmx="$1" 26 | # give usage if requested or needed 27 | if [ $vmx == "-h" ]; then usage && exit 0;fi 28 | # should be 1 to 3 args 29 | if [ $# -gt 3 ]; then echo && usage && exit 3;fi 30 | if [ $# -lt 1 ]; then echo && usage && exit 1;fi 31 | 32 | echo "Packaging vmx file: $vmx" 33 | echo "Removing mac address and uuid references" 34 | remove_autogen_mac $vmx 35 | 36 | # if more than one argument given 37 | if [ $# -gt 1 ]; then 38 | debug_msg "processing mac/vnc" 39 | # this is a ghetto regex for mac addy but it will work fine and allows ':'s 40 | debug_msg "checking $2 as a mac" 41 | if echo "$2" | grep -qe '[:0-9A-Fa-f]\{12\}'; then 42 | # then a mac address was given as the 2nd arg 43 | debug_msg "processing $2 as a mac" 44 | echo "Assigning the provided mac address" 45 | add_mac "$vmx" "$2" 46 | debug_msg "checking $3" 47 | if echo "$3" | grep -qe '[0-9]\{1,5\}'; then 48 | debug_msg "processing $3 as a vnc port" 49 | # then a vnc port was given too 50 | echo "Enabling VNC on port $3" 51 | add_vnc $1 $3 52 | fi 53 | else 54 | debug_msg "checking $2 as a vnc port" 55 | if echo "$2" | grep -qe '[0-9]\{1,5\}'; then 56 | # then a vnc port was given as the 2nd arg 57 | debug_msg "processing $2 as a vnc port" 58 | echo "Enabling VNC on port $2" 59 | add_vnc $1 $2 60 | debug_msg "checking $3" 61 | if echo "$3" | grep -qe '[:0-9A-Fa-f]\{12\}'; then 62 | debug_msg "processing $3 as a mac" 63 | # then a mac address was given too 64 | echo "Assigning the provided mac address" 65 | add_mac "$vmx" "$3" 66 | fi 67 | fi 68 | fi 69 | fi 70 | 71 | # 72 | # These items will get regenerated once the vm is booted for the first time 73 | # 74 | # Remove derived name 75 | echo "Removing derivedName" 76 | sed -i '/sched.swap.derivedName/d' $vmx > /dev/null 2>&1 77 | 78 | debug_msg "finished package_vmx" 79 | } 80 | 81 | remove_autogen_mac() { 82 | # $1 is the vmx file to edit 83 | # Remove remnants of an autogenerated or static mac address 84 | # currently this only works on ethernet0, you can duplicate and change the 0 as needed tho 85 | # or you could fix the sed call so that it will work on any number instead of just 0 86 | debug_msg "called remove_autogen_mac" 87 | thevmx="$1" 88 | sed -i '/ethernet0.generatedAddress/d' $thevmx > /dev/null 2>&1 89 | sed -i '/ethernet0.addressType/d' $thevmx > /dev/null 2>&1 90 | sed -i '/ethernet0.address/d' $thevmx > /dev/null 2>&1 91 | sed -i '/uuid.location/d' $thevmx > /dev/null 2>&1 92 | sed -i '/uuid.bios/d' $thevmx > /dev/null 2>&1 93 | debug_msg "finished remove_autogen_mac" 94 | } 95 | 96 | add_mac() { 97 | debug_msg "called add_mac" 98 | # the vmx file is $1, the mac addy is $2 99 | thevmx="$1" 100 | mac_addy="$2" 101 | # format = ethernet[n].address = 00:50:56:XX:YY:ZZ 102 | echo "ethernet0.address = $mac_addy" >> $thevmx 103 | debug_msg "finished add_mac" 104 | } 105 | 106 | add_vnc() { 107 | # the vmx file is $1, the vnc port is $2 108 | # a vnc port was provided, let's use it and use a hardcoded password for now 109 | # NOTE: You may need to adjust the esxi firewall (for certain versions of esxi) 110 | debug_msg "called add_vnc" 111 | thevmx="$1" 112 | vnc_port="$2" 113 | VNC_PASS="lab" 114 | # Remove all vnc related lines 115 | echo "Removing vnc references" 116 | sed -i '/RemoteDisplay.vnc.*/d' $thevmx > /dev/null 2>&1 117 | # now add them back (except vnc.key) with our stuff 118 | echo "Adding new vnc references back in" 119 | echo "RemoteDisplay.vnc.enabled = \"true\"" >> $thevmx 120 | echo "RemoteDisplay.vnc.port = \"$vnc_port\"" >> $thevmx 121 | echo "RemoteDisplay.vnc.password = \"$VNC_PASS\"" >> $thevmx 122 | debug_msg "finished add_vnc" 123 | } 124 | 125 | debug_msg "started script" 126 | debug_msg "args len = $#: vmx:$1 vnc/mac:$2 vnc/mac:$3" 127 | package_vmx "$@" 128 | echo "Done." 129 | -------------------------------------------------------------------------------- /useful_scripts/find_block.sh: -------------------------------------------------------------------------------- 1 | # usage: ./find_block.sh [target_file] [target_partition] 2 | 3 | ############ BEGIN SCRIPT ###################### 4 | #!/bin/sh 5 | 6 | self="$0" 7 | 8 | #`'~.~'^\_/^*-..-*`'~.~'^\_/^*-..-*`'~.~'^\_/^*-..-*`'~.~'^\_/^*\ 9 | # * 10 | # function defs, helps with staying posix compliant | 11 | # * 12 | #_.~*~._/^\_,-''-._.~*~._/^\_,-''-._.~*~._/^\_,-''-._.~*~._/^\_,/ 13 | 14 | # a simple posix compliant echo command 15 | echo () { printf %s\\n "$*" ; } 16 | inform () { printf %s\\n "[*] $*" ; } 17 | 18 | # usage 19 | usage() 20 | { 21 | err_lev=$1 22 | echo 23 | echo "Usage: $self target_file target_partition" 24 | echo 25 | echo "target_file is the file for which you want to find the fs block." 26 | echo "target_partition is the partition on which target_file can be found." 27 | echo 28 | if [[ -n "$err_lev" ]]; then exit $err_lev;fi 29 | } 30 | 31 | # if "-h" given, give usage & exit 0 32 | if [[ "$1" -eq "-h" ]]; then usage 0;fi 33 | # if not given 2 options, barf 34 | if [[ $* -ne 2 ]]; then usage 255;fi 35 | 36 | # if options seem good, press on 37 | target_file="$1" 38 | target_part="$2" 39 | 40 | # posix compliant basename 41 | basename() 42 | { 43 | _basename "$@" && 44 | printf "%s\n" "$_BASENAME" 45 | } 46 | 47 | _basename() ## 48 | { 49 | [ "$1" = "--" ] && shift 50 | fn_path=$1 51 | fn_suffix=$2 52 | case $fn_path in 53 | ## The spec says: "If string is a null string, it is 54 | ## unspecified whether the resulting string is '.' or a 55 | ## null string. This implementation returns a null string 56 | "") return ;; 57 | *) ## strip trailing slashes 58 | while : 59 | do 60 | case $fn_path in 61 | */) fn_path=${fn_path%/} ;; 62 | *) break ;; 63 | esac 64 | done 65 | case $fn_path in 66 | "") fn_path="/" ;; 67 | *) fn_path=${fn_path##*/} ;; 68 | esac 69 | ;; 70 | esac 71 | case $fn_path in 72 | $fn_suffix | "/" ) _BASENAME="$fn_path" ;; 73 | *) _BASENAME=${fn_path%$fn_suffix} 74 | esac 75 | } 76 | 77 | get_path() { 78 | # $1 is command to check, it's basename will be fed to which to see if one exists in path 79 | # e.g. if args are /bin/ifconfig eth0, this function will probably return /sbin/ifconfig eth0 80 | # if which finds ifconfig there in the path, otherwise /bin/ifconfig eth0 will be returned 81 | base=`basename "$1"` 82 | c=`which "$base"` 83 | if test -z "$c"; then c="$1";fi 84 | shift 85 | echo "$c" "$@" 86 | } 87 | 88 | run_path() { 89 | # $1 is command to check, it's basename will be fed to 'which' to see if one exists in path 90 | # e.g. if args are /bin/ifconfig eth0, this function will probably run /sbin/ifconfig eth0 91 | # if which finds ifconfig there in the path, otherwise /bin/ifconfig eth0 will be run 92 | base=`basename "$1"` 93 | c=`which "$base"` 94 | if test -z "$c"; then c="$1";fi 95 | shift 96 | "$c" "$@" 97 | } 98 | 99 | get_block_size() { 100 | # $1 is the target partition, like /dev/sda1 101 | # using dump2efs for now 102 | bs=`run_path /sbin/dumpe2fs "$1" | grep 'Block size' | tr -d " " | cut -d ':' -f 2` 103 | # end dump2efs method 104 | 105 | echo $bs 106 | } 107 | 108 | get_inode() { 109 | # $1 is the target file, like /test.txt 110 | # using ls -i for now 111 | i=`run_path /bin/ls -i "$1" | cut -d " " -f 1` 112 | # end ls -i method 113 | # alt method using debugfs # /inode/number/0/0/$target_file/7/ 114 | # debugfs $target_part -R "ls -pd" | grep $1 | cut -d '/' -f 2 115 | # end debugfs method 116 | 117 | echo $i 118 | } 119 | 120 | get_block(){ 121 | # $1 is the target partition, $2 is the inode 122 | # ghetto 123 | # if extent do this 124 | tmp=`run_path /sbin/debugfs "$1" -R "stat <${2}>" | grep -A 1 EXTENTS | tail -n 1 | tr -d " " | cut -d ":" -f 2` 125 | # if fragmented, you get something like: (0-399): 59820544-59820943 126 | blk=`echo $tmp | cut -d "-" -f 1` 127 | 128 | echo $blk 129 | } 130 | 131 | # get block_size 132 | block_size=`get_block_size $target_part` 133 | echo "block size is:$block_size" 134 | # get inode 135 | inode=`get_inode "$target_file"` 136 | echo "inode is:$inode" 137 | # get block/extent 138 | block=`get_block $target_part $inode` 139 | echo "block is:$block" 140 | 141 | echo "Performing bulk extraction test on your targeted area of disk" 142 | run_path /bin/dd if=$target_part bs=$block_size skip=$block count=10 | `get_path /usr/bin/strings` 143 | #run_path /bin/dd if=$target_part bs=$block_size skip=$block count=10 | `get_path /usr/bin/strings` | `get_path /bin/egrep` '\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' 144 | -------------------------------------------------------------------------------- /debug/lazy.wds: -------------------------------------------------------------------------------- 1 | $$ ============================================================================= 2 | $$ lazy.wds 3 | $$ 4 | $$ Matt Molinyawe for the Zero Day Initiative 5 | $$ 6 | $$ ============================================================================= 7 | 8 | .block 9 | { 10 | as ${/v:crashCmds} $$>a< c:\\windbgScripts\\lazy.wds std 11 | } 12 | 13 | .block 14 | { 15 | as ${/v:setSymbols} $$>a< c:\\windbgScripts\\lazy.wds setsymbols 16 | } 17 | 18 | .block 19 | { 20 | as ${/v:getSymbols} $$>a< c:\\windbgScripts\\lazy.wds getsymbols 21 | } 22 | 23 | .block 24 | { 25 | as ${/v:coolHeapBPs} $$>a< c:\\windbgScripts\\lazy.wds heapbps 26 | } 27 | .block 28 | { 29 | as ${/v:writeBP} $$>a< c:\\windbgScripts\\lazy.wds writebp 30 | } 31 | .block 32 | { 33 | as ${/v:killIE} .shell cmd.exe /c "taskkill /f /im iexplore.exe && taskkill /f /im WerFault.exe" 34 | } 35 | 36 | .block 37 | { 38 | as ${/v:lazy} $$>< c:\\windbgScripts\\lazy.wds 39 | } 40 | 41 | .block 42 | { 43 | .if(0 == $sicmp("${$arg1}", "std")) 44 | { 45 | .printf "kv\n"; 46 | kv; 47 | .printf "\n"; 48 | 49 | .printf "u .\n"; 50 | u .; 51 | .printf "\n"; 52 | 53 | .printf "ub .\n"; 54 | ub .; 55 | .printf "\n"; 56 | 57 | .printf "!gflag\n"; 58 | !gflag; 59 | .printf "\n"; 60 | 61 | .printf "vertarget\n"; 62 | vertarget; 63 | .printf "\n"; 64 | 65 | .printf "!lmi mshtml\n"; 66 | !lmi mshtml; 67 | .printf "\n"; 68 | } 69 | .elsif(0 == $sicmp("${$arg1}", "setsymbols")) 70 | { 71 | .sympath SRV*c:\symbols*http://msdl.microsoft.com/download/symbols 72 | } 73 | .elsif(0 == $sicmp("${$arg1}", "getsymbols")) 74 | { 75 | .reload /f 76 | } 77 | .elsif(0 == $sicmp("${$arg1}", "writebp")) 78 | { 79 | .printf "YO DUDE Modify this to suit your needs:\n" 80 | .printf /D "bu [instrADDR] \"ba w4 [write location] \\\"r; ub eip; kv; g\\\";g\"" 81 | } 82 | .elsif(0 == $sicmp("${$arg1}", "heapbps")) 83 | { 84 | bu101 KERNEL32!HeapFree+0xe ".printf \"HeapFree(%08x, %08x, %08x)\\n\", poi(ebp+8), poi(ebp+0c), poi(ebp+10); g" 85 | bu102 KERNEL32!HeapFree ".printf \"---\\n\"; ln poi(esp); g" 86 | bu201 ntdll!RtlAllocateHeap ".printf \"---\\n\"; ln poi(esp); g" 87 | bu202 ntdll!RtlAllocateHeap+0x5 ".printf \"RtlAllocateHeap(%08x, %08x, %08x)\", poi(ebp+8), poi(ebp+0c), poi(ebp+10); g" 88 | bu203 ntdll!RtlAllocateHeap+e6 ".printf \" at %08x\\n\", eax; g" 89 | bu301 ntdll!RtlReAllocateHeap ".printf \"---\\n\"; ln poi(esp); g" 90 | bu302 ntdll!RtlReAllocateHeap+0x5 ".printf \"RtlReAllocateHeap(%08x, %08x, %08x, %08x)\", poi(ebp+8), poi(ebp+0c), poi(ebp+10), poi(ebp+14); g" 91 | bu303 ntdll!RtlReAllocateHeap+0x98 ".printf \" at %08x\\n\", eax; g" 92 | bp jscript9+00035d78 ".echo;dds ebp-28 L1;g" 93 | } 94 | .else 95 | { 96 | .printf /D "Lazy - Lazy script to ensure that standard debug is not missed and other laziness\n\n"; 97 | 98 | .printf /D "Type 'al' to list aliases for script usage\n\n"; 99 | 100 | .printf /D "Symbols:\n" 101 | .printf /D "Set Symbols\n" 102 | .printf /D /oP "Get Symbols\n\n" 103 | 104 | 105 | .printf /D "Standard debug:\n" 106 | .printf /D /oP "Standard debug crash commands\n\n" 107 | 108 | .printf /D "Scan for Images:\n" 109 | .printf /D "Scan for images\n\n" 110 | 111 | .printf /D "Fun shell things to do:\n" 112 | .printf /D "Enable page heap for iexplore.exe \n\n" 113 | .printf /D "start calc\n\n" 114 | 115 | .printf /D "weird commands:\n" 116 | .printf /D "Get last error\n\n" 117 | 118 | .printf /D "Reminders for some commands:\n" 119 | .printf /D "Get code flow: .dml_flow [start_addr] [end_addr]\n\n" 120 | .printf /D "Get calls made by this function\n\n" 121 | .printf /D "Get number of instructions in this routine\n\n" 122 | .printf /D "List Modules\n\n" 123 | 124 | .printf /D "!heap:\n" 125 | .printf /D "!heap for eax\n\n" 126 | .printf /D "!heap for ebx\n\n" 127 | .printf /D "!heap for ecx\n\n" 128 | .printf /D "!heap for edx\n\n" 129 | .printf /D "!heap for esi\n\n" 130 | .printf /D "!heap for edi\n\n" 131 | } 132 | 133 | } 134 | 135 | 136 | -------------------------------------------------------------------------------- /debug/lazy-Win8.wds: -------------------------------------------------------------------------------- 1 | $$ ============================================================================= 2 | $$ lazy.wds 3 | $$ 4 | $$ Matt Molinyawe for the Zero Day Initiative 5 | $$ 6 | $$ ============================================================================= 7 | 8 | .block 9 | { 10 | as ${/v:crashCmds} $$>a< c:\\windbgScripts\\lazy.wds std 11 | } 12 | 13 | .block 14 | { 15 | as ${/v:setSymbols} $$>a< c:\\windbgScripts\\lazy.wds setsymbols 16 | } 17 | 18 | .block 19 | { 20 | as ${/v:getSymbols} $$>a< c:\\windbgScripts\\lazy.wds getsymbols 21 | } 22 | 23 | .block 24 | { 25 | as ${/v:coolHeapBPs} $$>a< c:\\windbgScripts\\lazy.wds heapbps 26 | } 27 | .block 28 | { 29 | as ${/v:writeBP} $$>a< c:\\windbgScripts\\lazy.wds writebp 30 | } 31 | .block 32 | { 33 | as ${/v:killIE} .shell cmd.exe /c "taskkill /f /im iexplore.exe && taskkill /f /im WerFault.exe" 34 | } 35 | 36 | .block 37 | { 38 | as ${/v:lazy} $$>< c:\\windbgScripts\\lazy.wds 39 | } 40 | 41 | .block 42 | { 43 | .if(0 == $sicmp("${$arg1}", "std")) 44 | { 45 | .printf "kv\n"; 46 | kv; 47 | .printf "\n"; 48 | 49 | .printf "u .\n"; 50 | u .; 51 | .printf "\n"; 52 | 53 | .printf "ub .\n"; 54 | ub .; 55 | .printf "\n"; 56 | 57 | .printf "!gflag\n"; 58 | !gflag; 59 | .printf "\n"; 60 | 61 | .printf "vertarget\n"; 62 | vertarget; 63 | .printf "\n"; 64 | 65 | .printf "!lmi mshtml\n"; 66 | !lmi mshtml; 67 | .printf "\n"; 68 | } 69 | .elsif(0 == $sicmp("${$arg1}", "setsymbols")) 70 | { 71 | .sympath SRV*c:\symbols*http://msdl.microsoft.com/download/symbols 72 | } 73 | .elsif(0 == $sicmp("${$arg1}", "getsymbols")) 74 | { 75 | .reload /f 76 | } 77 | .elsif(0 == $sicmp("${$arg1}", "writebp")) 78 | { 79 | .printf "YO DUDE Modify this to suit your needs:\n" 80 | .printf /D "bu [instrADDR] \"ba w4 [write location] \\\"r; ub eip; kv; g\\\";g\"" 81 | } 82 | .elsif(0 == $sicmp("${$arg1}", "heapbps")) 83 | { 84 | bu101 KERNEL32!HeapFree+0xe ".printf \"HeapFree(%08x, %08x, %08x)\\n\", poi(ebp+8), poi(ebp+0c), poi(ebp+10); g" 85 | bu102 KERNEL32!HeapFree ".printf \"---\\n\"; ln poi(esp); g" 86 | bu201 ntdll!RtlAllocateHeap ".printf \"---\\n\"; ln poi(esp); g" 87 | bu202 ntdll!RtlAllocateHeap+0x5 ".printf \"RtlAllocateHeap(%08x, %08x, %08x)\", poi(ebp+8), poi(ebp+0c), poi(ebp+10); g" 88 | bu203 ntdll!RtlAllocateHeap+e6 ".printf \" at %08x\\n\", eax; g" 89 | bu301 ntdll!RtlReAllocateHeap ".printf \"---\\n\"; ln poi(esp); g" 90 | bu302 ntdll!RtlReAllocateHeap+0x5 ".printf \"RtlReAllocateHeap(%08x, %08x, %08x, %08x)\", poi(ebp+8), poi(ebp+0c), poi(ebp+10), poi(ebp+14); g" 91 | bu303 ntdll!RtlReAllocateHeap+0x98 ".printf \" at %08x\\n\", eax; g" 92 | bp jscript9+00035d78 ".echo;dds ebp-28 L1;g" 93 | } 94 | .else 95 | { 96 | .printf /D "Lazy - Lazy script to ensure that standard debug is not missed and other laziness\n\n"; 97 | 98 | .printf /D "Type 'al' to list aliases for script usage\n\n"; 99 | 100 | .printf /D "Symbols:\n" 101 | .printf /D "Set Symbols\n" 102 | .printf /D /oP "Get Symbols\n\n" 103 | 104 | 105 | .printf /D "Standard debug:\n" 106 | .printf /D /oP "Standard debug crash commands\n\n" 107 | 108 | .printf /D "Scan for Images:\n" 109 | .printf /D "Scan for images\n\n" 110 | 111 | .printf /D "Fun shell things to do:\n" 112 | .printf /D "Enable page heap for iexplore.exe \n\n" 113 | .printf /D "start calc\n\n" 114 | 115 | .printf /D "weird commands:\n" 116 | .printf /D "Get last error\n\n" 117 | 118 | .printf /D "Reminders for some commands:\n" 119 | .printf /D "Get code flow: .dml_flow [start_addr] [end_addr]\n\n" 120 | .printf /D "Get calls made by this function\n\n" 121 | .printf /D "Get number of instructions in this routine\n\n" 122 | .printf /D "List Modules\n\n" 123 | 124 | .printf /D "!heap:\n" 125 | .printf /D "!heap for eax\n\n" 126 | .printf /D "!heap for ebx\n\n" 127 | .printf /D "!heap for ecx\n\n" 128 | .printf /D "!heap for edx\n\n" 129 | .printf /D "!heap for esi\n\n" 130 | .printf /D "!heap for edi\n\n" 131 | } 132 | 133 | } 134 | 135 | 136 | -------------------------------------------------------------------------------- /bash/.gitconfig: -------------------------------------------------------------------------------- 1 | [user] 2 | name = My Name 3 | email = my@email.com 4 | signingkey = XXXXXXXX 5 | [github] 6 | user = replace_w_yer_uname 7 | [credential] 8 | helper = cache 9 | [push] 10 | default = simple 11 | [helper] 12 | osxkeychain 13 | #ssh-agent 14 | [filter "media"] 15 | clean = git-media-clean %f 16 | smudge = git-media-smudge %f 17 | [commit] 18 | template = %{HOME}/.gittemplate 19 | [merge] 20 | tool = vimdiff 21 | [push] 22 | # 'git push' should only hit this branch, not all. Why this isn't 23 | # default? 24 | default = current 25 | [color] 26 | # All this coloring makes life so much nicer. 27 | branch = auto 28 | ui = true 29 | [color "branch"] 30 | current = yellow reverse 31 | local = yellow 32 | remote = green 33 | [color "diff"] 34 | meta = yellow bold 35 | frag = magenta bold 36 | old = red bold 37 | new = green bold 38 | whitespace = red reverse 39 | [core] 40 | # Make sure this editor blocks the terminal (unlike gvim), 41 | # otherwise commit # messages will be ignored. 42 | editor = /usr/bin/vim 43 | whitespace=fix,-indent-with-non-tab 44 | excludesfile = %{HOME}/.gitignore 45 | [alias] 46 | # minimal git status 47 | s = "status -s" 48 | # When syncing with a remote, try to be noninvasive. 49 | refresh = pull --ff-only 50 | # [c]heckout [u]pstream [m]aster; switches branches and refreshes 51 | cum = !"git checkout upstream-master && git refresh" 52 | # Shorthand commands to always sign (-S) and always edit the commit 53 | # message. 54 | m = merge -S --no-ff --edit 55 | c = commit -S --edit 56 | # Shorthand to always blame without looking at just whitespace changes 57 | b = blame -w 58 | # Super handy way to create a local temp branch for testing merges. 59 | temp = !"git branch -D temp; git checkout -b temp" 60 | # Create and push a tag. Usually used for sprint tags like sprint-A01 61 | tag-sprint=!"git tag -s $1 -m \"Tagging as $1\" && git push --tags upstream upstream-master:master && echo Tagged as" 62 | 63 | # --== LOGs ==-- 64 | # handy one 65 | lg = "log --oneline --all --graph --decorate" 66 | # A gitk-like ASCII display. 67 | lol = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative 68 | # A slightly more useful gitlol that provides diff stats 69 | lolstat = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --stat 70 | # Show commit logs with signatures 71 | slog = log --show-signature 72 | logs = log --show-signature --name-status 73 | # Show commit logs with filenames 74 | flog = log --name-status 75 | # A pretty and short commit log 76 | nicelog = log --pretty=format:'%Cred%h%Creset -%Creset %s %Cgreen(%cr) %C(bold blue)<%aE>%Creset' 77 | 78 | # Wipe out local changes and reset to the last local commit. 79 | wipe = reset --hard HEAD 80 | # Merge (not signed) without fast-forwarding 81 | noff = merge --no-ff 82 | # Merge (not signed) with fast-forwarding 83 | ff = merge --ff-only 84 | # Sync all remote upstream branches locally (discarding local changes). 85 | branch-sync-upstream = !"for remote in `git branch -r | grep -e \"[[:space:]]upstream\" | grep -v \"upstream/master$\"`; do git checkout --track $remote ; git reset HEAD --hard; git checkout master; git wipe; done" 86 | # Display the branch I'm on now, used in some shell functions 87 | branch-current = rev-parse --abbrev-ref HEAD 88 | thisbranch = !"git branch-current" 89 | # List all branches on that have made it to upstream master. 90 | merged-branches-ls =!"git branch -r --merged upstream/master | grep $1 | grep -v -e $1/pr -e $1/master | sed s#^[[:space:]]*$1/## #" # Trailing comment on purpose 91 | # Remove all branches on that have made it to upstream master. 92 | merged-branches-rm =!"for b in `git merged-branches-ls $1`; do git push $1 :refs/heads/$b; done #" 93 | # Create a local land-1234-some-feature-or-fix branch against upstream/pr/1234 94 | land = !"git checkout upstream/pr/$1 && git checkout -b landing/$1 -t upstream/pr/$1 && bundle install" # Needs trailing comment 95 | # Shorthand for land 96 | l = !"git land" 97 | # actually do the land merge 98 | landpr = !"git fetch upstream && git checkout upstream-master && git rebase upstream/master && git m $1" 99 | # Publish is more serious than just "push" since it takes my 100 | # upstream-master and pushes to remote's master. I never remember this 101 | # syntax otherwise. 102 | publish = push upstream upstream-master:master 103 | # so the sequence, assuming no changes to the pr, is: 104 | # git land (or git l); git landpr; git publish 105 | # Usage: $1 is HISNAME, $2 is HISBRANCH 106 | # Linux 107 | pr-url =!"xdg-open https://github.com/$(git config github.user)/$(basename $(git rev-parse --show-toplevel))/pull/new/$1:$2...$(git branch-current) #" 108 | # OS X Note: Replace Chrome w/whatever browser you want 109 | #pr-url =!"open -a \"Google Chrome\" https://github.com/$(git config github.user)/$(basename $(git rev-parse --show-toplevel))/pull/new/$1:$2...$(git branch-current) #" 110 | -------------------------------------------------------------------------------- /useful_scripts/lock-keyboard-for-baby.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | use warnings; 3 | use strict; 4 | use Data::Dumper; 5 | my $lastmod="2006/05/25"; 6 | my $datemod="2008/07/03"; 7 | my $defaultpassword="QuitNow"; 8 | my $progname=$0; 9 | $progname =~ s%.*/%%g; 10 | 11 | sub usage($) 12 | { 13 | my ($exitcode)=@_; 14 | 15 | print STDERR < 40 | END_OF_USAGE 41 | 42 | exit($exitcode); 43 | } 44 | 45 | 46 | my $password=$defaultpassword; 47 | my $message="Type the password to quit\n:"; 48 | my $true=1; 49 | my $false=0; 50 | my $noshow=$true; 51 | my $withmouse=$false; 52 | my $maxshownlength=30; 53 | my $defaults_changed=$false; 54 | my $defaults_changed_vis=$false; 55 | 56 | my @startpos=(0,0); 57 | 58 | while (@ARGV) 59 | { 60 | my $arg=shift @ARGV; 61 | if($arg =~ /^-xy=(\d+),(\d+)$/i) 62 | { 63 | @startpos=($1,$2); 64 | } 65 | elsif($arg =~ /^(-|--)(h|help|usage|[?])$/i) 66 | { 67 | usage(0); 68 | } 69 | elsif($arg =~ /^(-|--)(p|pass|password)$/i) 70 | { 71 | if(!@ARGV) 72 | { 73 | print STDERR "missing argument\n"; 74 | usage(-1); 75 | } 76 | $password=shift @ARGV; 77 | $defaults_changed=$true; 78 | } 79 | elsif($arg =~ /^(-|--)(s|stars)$/i) 80 | { 81 | $noshow="stars"; 82 | $defaults_changed=$true; 83 | } 84 | elsif($arg =~ /^(-|--)(w|withmouse)$/i) 85 | { 86 | $withmouse=$true; 87 | $defaults_changed=$true; 88 | $defaults_changed_vis=$true; 89 | } 90 | elsif($arg =~ /^(-|--)(v|vis|visible)(=(\d+)|)$/i) 91 | { 92 | $noshow=$false; 93 | if(length($4)) 94 | { 95 | $maxshownlength=$4; 96 | } 97 | $defaults_changed=$true; 98 | $defaults_changed_vis=$true; 99 | } 100 | elsif($arg =~ /^(-|--)(m|msg|message)$/i) 101 | { 102 | if(!@ARGV) 103 | { 104 | print STDERR "missing argument\n"; 105 | usage(-1); 106 | } 107 | $message=shift @ARGV; 108 | if(length($message)) 109 | { 110 | $message.="\n"; 111 | } 112 | $defaults_changed=$true; 113 | } 114 | else 115 | { 116 | usage(-1); 117 | } 118 | } 119 | if(!$defaults_changed) 120 | { 121 | $noshow=$false; 122 | } 123 | if((!$defaults_changed || $defaults_changed_vis)) 124 | { 125 | $message="Type '$password' to quit\n"; 126 | } 127 | 128 | use Gtk2 -init; 129 | my $w = new Gtk2::Window -popup; 130 | my $l = new Gtk2::Label $message; 131 | my $eb = new Gtk2::EventBox; 132 | my $gdkwin; 133 | my $grabstatus; 134 | my $typed=""; 135 | 136 | sub do_grab() 137 | { 138 | $grabstatus= Gtk2::Gdk->keyboard_grab( 139 | $gdkwin,$true,Gtk2::Gdk::X11->get_server_time($gdkwin) ); 140 | if($grabstatus ne "success") 141 | { 142 | $l->set_text("keyboard grab failed"); 143 | } 144 | if($withmouse) 145 | { 146 | $grabstatus= Gtk2::Gdk->pointer_grab( 147 | $gdkwin,$true,['button-press-mask','button-release-mask'],undef,undef,Gtk2::Gdk::X11->get_server_time($gdkwin)); 148 | if($grabstatus ne "success") 149 | { 150 | $l->set_text("pointer grab failed"); 151 | } 152 | } 153 | } 154 | 155 | sub do_ungrab() 156 | { 157 | Gtk2::Gdk->keyboard_ungrab(Gtk2::Gdk::X11->get_server_time($gdkwin)); 158 | if($withmouse) 159 | { 160 | Gtk2::Gdk->pointer_ungrab(Gtk2::Gdk::X11->get_server_time($gdkwin)); 161 | } 162 | } 163 | 164 | sub do_keypress(@) 165 | { 166 | my ($widg,$evt)=@_; 167 | my $kv = $evt->keyval; 168 | my $cs = Gtk2::Gdk->keyval_name($kv); 169 | 170 | if($cs =~ /Return|Enter/) 171 | { 172 | if($typed eq $password) 173 | { 174 | do_ungrab(); 175 | Gtk2->main_quit; 176 | } 177 | else 178 | { 179 | $typed=""; 180 | } 181 | } 182 | elsif(length($cs) == 1 && $cs =~ /[[:print:]]/) 183 | { 184 | $typed .= $cs; 185 | } 186 | my $showtyped=$typed; 187 | if($noshow eq "stars") 188 | { 189 | $showtyped =~ s/[^*]/*/g; 190 | } 191 | elsif($noshow) 192 | { 193 | $showtyped=""; 194 | } 195 | if(length($showtyped) > $maxshownlength) 196 | { 197 | $showtyped=substr($showtyped,0,$maxshownlength); 198 | } 199 | $l->set_text($message.$showtyped); 200 | } 201 | $w->add($eb); 202 | $eb->add($l); 203 | $w->add_events( [ qw(key_press_mask) ]); 204 | $w->signal_connect('key_press_event', \&do_keypress); 205 | $w->signal_connect('realize', sub { $w->window->move(@startpos); }); 206 | $w->signal_connect('map', sub { $gdkwin=$w->window; do_grab(); }); 207 | $w->show_all; 208 | Gtk2->main; 209 | -------------------------------------------------------------------------------- /zsh/.zshrc: -------------------------------------------------------------------------------- 1 | # Path to your oh-my-zsh installation. 2 | export ZSH=$HOME/.oh-my-zsh 3 | 4 | # Set name of the theme to load. 5 | # Look in ~/.oh-my-zsh/themes/ 6 | # Optionally, if you set this to "random", it'll load a random theme each 7 | # time that oh-my-zsh is loaded. 8 | ZSH_THEME="robbyrussell" 9 | 10 | # git completion 11 | #source ~/git-completion.zsh 12 | 13 | # Colors 14 | autoload -U colors 15 | colors 16 | setopt prompt_subst 17 | 18 | # Prompt 19 | #PROMPT=' 20 | #%{$fg[blue]%}%~%{$reset_color%} 21 | #%{$reset_color%}' 22 | 23 | #RPROMPT='%{$fg_bold[grey]%} $(~/.rvm/bin/rvm-prompt)$(~/bin/git-cwd-info)%{$reset_color%}' 24 | 25 | # Uncomment the following line to use case-sensitive completion. 26 | # CASE_SENSITIVE="true" 27 | 28 | # Uncomment the following line to disable bi-weekly auto-update checks. 29 | DISABLE_AUTO_UPDATE="false" 30 | DISABLE_UPDATE_PROMPT="false" 31 | 32 | # Uncomment the following line to change how often to auto-update (in days). 33 | # export UPDATE_ZSH_DAYS=13 34 | 35 | # Uncomment the following line to disable colors in ls. 36 | # DISABLE_LS_COLORS="true" 37 | 38 | # Uncomment the following line to disable auto-setting terminal title. 39 | # DISABLE_AUTO_TITLE="true" 40 | 41 | # Uncomment the following line to enable command auto-correction. 42 | # ENABLE_CORRECTION="true" 43 | 44 | # Uncomment the following line to display red dots whilst waiting for completion. 45 | COMPLETION_WAITING_DOTS="true" 46 | 47 | # Uncomment the following line if you want to disable marking untracked files 48 | # under VCS as dirty. This makes repository status check for large repositories 49 | # much, much faster. 50 | # DISABLE_UNTRACKED_FILES_DIRTY="true" 51 | 52 | # Uncomment the following line if you want to change the command execution time 53 | # stamp shown in the history command output. 54 | # The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" 55 | export HIST_STAMPS='%Y%m%d%H%M%S' 56 | 57 | # Would you like to use another custom folder than $ZSH/custom? 58 | # ZSH_CUSTOM=/path/to/new-custom-folder 59 | 60 | # Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*) 61 | # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ 62 | # Example format: plugins=(rails git textmate ruby lighthouse) 63 | # Add wisely, as too many plugins slow down shell startup. 64 | plugins=( 65 | git 66 | git-lfs 67 | github 68 | bundler 69 | rake 70 | rbenv 71 | ruby 72 | ) 73 | # plugins=($plugins ruby gem bundler rails) 74 | # plugins=($plugins osx brew) 75 | # plugins=($plugins linux) 76 | 77 | source $ZSH/oh-my-zsh.sh 78 | 79 | # User configuration 80 | # 81 | export PATH=$HOME/bin:/usr/local/bin:$PATH 82 | # export MANPATH="/usr/local/man:$MANPATH" 83 | 84 | # You may need to manually set your language environment 85 | # export LANG=en_US.UTF-8 86 | 87 | # Preferred editor for local and remote sessions 88 | if [[ -n $SSH_CONNECTION ]]; then 89 | export EDITOR='vim' 90 | else 91 | export EDITOR='vim' 92 | fi 93 | 94 | # Compilation flags 95 | # export ARCHFLAGS="-arch x86_64" 96 | # export PKG_CONFIG_PATH="/usr/local/opt/libpq/lib/pkgconfig" 97 | 98 | # SSH 99 | # export SSH_KEY_PATH="~/.ssh/dsa_id" 100 | 101 | # Set personal aliases, overriding those provided by oh-my-zsh libs, 102 | # plugins, and themes. Aliases can be placed here, though oh-my-zsh 103 | # users are encouraged to define aliases within the ZSH_CUSTOM folder. 104 | # For a full list of active aliases, run `alias`. 105 | 106 | # Universal aliases 107 | # 108 | alias zshconfig="$EDITOR ~/.zshrc" 109 | alias ohmyzsh="$EDITOR ~/.oh-my-zsh" 110 | alias ll='ls -lah' 111 | alias dos2unix="sed 's/\r$//' $1 > $2" 112 | alias timestamp="date +'%Y%m%d%H%M%S'" 113 | alias datestamp="date +'%Y%m%d%H'" 114 | 115 | # rails/rake aliases 116 | # 117 | # alias prime_db="rake db:drop db:create db:migrate dev:prime" 118 | # alias assets="rails tmp:clear && rails assets:precompile; echo 'you may need to brew install yarn'" 119 | 120 | # git/github (if not in ~/.gitconfig) aliases 121 | # 122 | # alias gho='GH_HOST=github.other gh' 123 | 124 | # Universal functions 125 | # 126 | function fingerprint() { ssh-keygen -lf $1 -E sha256; } 127 | function prep() { cd "$ZSH" && ls -l && git branch; } 128 | 129 | # Depending on OS 130 | # 131 | if `uname |grep -q -i darwin`; then 132 | # MacOS-specific items 133 | 134 | plugins=($plugins osx brew macos) 135 | 136 | # brew aliases 137 | # 138 | alias brew_list_services="brew services list" 139 | alias brew_list_services_long="brew services list --debug" 140 | alias bsl="brew services list" 141 | alias bsll="brew services list --debug" 142 | # alias stop_postgres="brew services stop postgresql@14" 143 | # alias start_postgres="brew services start postgresql@14" 144 | # alias restart_postgres="brew services restart postgresql@14" 145 | # if you don't want/need a background service you can just run: 146 | # /usr/local/opt/redis/bin/redis-server /usr/local/etc/redis.conf 147 | # alias stop_redis="brew services stop redis" 148 | # alias start_redis="brew services start redis" 149 | # alias restart_redis="brew services restart redis" 150 | 151 | # search/find aliases 152 | # 153 | alias mf="mdfind -name " 154 | 155 | # Functions 156 | # 157 | function cap() { 158 | screencapture -l$(osascript -e 'tell app "iTerm" to id of window 1') $ZSH/themes/$ZSH_THEME.png 159 | } 160 | function umount() { diskutil unmount $1; } 161 | 162 | else 163 | # Unix/Linux-specific items 164 | 165 | plugins=($plugins linux) 166 | 167 | # search/find aliases 168 | # 169 | alias mf="find . -iname *$1*" 170 | 171 | fi 172 | 173 | -------------------------------------------------------------------------------- /osx/setup_new_box.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # script to setup a new host 4 | # 5 | 6 | # Script control: 7 | DO_HOSTNAME=1 8 | HNAME=biggeek 9 | 10 | DO_PROXY=1 11 | MYPROXY="http://proxy.houston.hp.com:8080" 12 | 13 | DO_XCODE_CLI_TOOLS=1 14 | 15 | DO_BREW=1 16 | DO_PORTS=0 17 | PKG_MGR='0' 18 | if [ $DO_BREW -eq 1 ]; do 19 | PKG_MGR='brew' 20 | elif [ $DO_PORTS -eq 1 ]; do 21 | PKG_MGR='sudo port' 22 | fi 23 | 24 | DO_GPG=1 25 | 26 | DO_SUBLIME=1 27 | SUBLIME_URL="http://c758482.r82.cf2.rackcdn.com/Sublime%20Text%20Build%203065.dmg" 28 | DO_VIM=0 29 | 30 | # TODO: wireshark?, SSL Cert?, SSH Key? 31 | # DO_WIRESHARK_DEV=1 32 | # WIRESHARK_URL="http://wiresharkdownloads.riverbed.com/wireshark/osx/Wireshark%201.99.0%20Intel%2064.dmg" 33 | 34 | DO_VPN_PPP=1 35 | 36 | # Error constants: 37 | _ERR_CANT_WRITE_DIR=4 38 | 39 | # 40 | # Functions 41 | # 42 | # echo can be pretty retarded and sometimes unpredictable, make it less so 43 | # ref: http://www.etalabs.net/sh_tricks.html 44 | echo () { 45 | fmt=%s end=\\n IFS=" " 46 | while [ $# -gt 1 ] ; do 47 | case "$1" in 48 | [!-]*|-*[!ne]*) break ;; 49 | *ne*|*en*) fmt=%b end= ;; 50 | *n*) end= ;; 51 | *e*) fmt=%b ;; 52 | esac 53 | shift 54 | done 55 | printf "$fmt$end" "$*" 56 | } 57 | 58 | puts() { 59 | # echos '[*] ' and arguments with the -e and -n flags (to stdout) 60 | # only print something if quiet is empty 61 | [ -z "$quiet" ] && echo -en "[*] $@" 62 | #TODO: I don't think this is posix, it's using test right? 63 | } 64 | 65 | eqo() { 66 | # echos the arguments with no frills, but only if not quiet 67 | # only print something if quiet is empty 68 | [ -z "$quiet" ] && echo "$@" 69 | #TODO: I don't think this is posix, it's using test right? 70 | } 71 | 72 | warn() { 73 | # warnings, i.e. non-fatal errors to stdout 74 | # echos '[-] ' and arguments with the -e and -n flags (to stdout) 75 | # only print something if quiet is empty or not empty but less than a value? 76 | # local quiet_threshold 77 | # [ $quiet -lt $quiet_threshold ] && echo -en "[-] $@" 78 | [ -z "$quiet" ] && echo -en "[-] $@" 79 | #TODO: I don't think this is posix, it's using test right? 80 | } 81 | 82 | die() { 83 | # fatal or nearly-fatal errors, if you give a second argument, it is used as an exit code 84 | # echos '[!] ' and first argument with the -e and -n flags and redirect to stderr 85 | # if a second argument is given, this function will exit with that argument as the code 86 | # NOTE: $quiet does not affect the output 87 | echo -en "[!] $1" >&2 88 | if [ $2 ]; then exit $2;fi 89 | } 90 | 91 | # allows you to easily debug variables as varname:varvalue or similar 92 | investigate() { 93 | # if $3 isn't given, don't prefix output with anything 94 | local output_prefix='' # could be something like [*] 95 | if [ -n "$3" ]; then output_prefix="$3";fi 96 | 97 | # if $2 isn't given, default separator to something 98 | local output_sep=": " # could be ", " ": " etc 99 | if [ -n "$2" ]; then output_sep="$2";fi 100 | 101 | # if $1 is given, then good, if not, well jeez, don't do anything 102 | local var2investigate='' 103 | if [ -n "$1" ]; then 104 | var2investigate="$1" 105 | echo -n "${output_prefix}${var2investigate}${output_sep}" 106 | v='echo -n $' 107 | v="${v}$(echo -n $var2investigate)" 108 | eval $v 109 | echo 110 | fi 111 | } 112 | 113 | chk_mkdir() { 114 | # make a directory (with -p) if it doesn't exist 115 | if [ ! -d "$1" ]; then 116 | # make the directory, or fail out, use 'die' if available 117 | mkdir -p $1 || type -t die && die "Can't create directory...aborting" $_ERR_CANT_WRITE_DIR 118 | fi 119 | } 120 | 121 | # start from home 122 | cd ~ 123 | 124 | # make a .ssh dir if nec 125 | chk_mkdir ${HOME}/.ssh 126 | 127 | # set hostname 128 | if [ $DO_HOSTNAME -eq 1 ]; do 129 | puts "Setting hostname" 130 | hostname $HNAME 131 | fi 132 | 133 | # proxy settings 134 | if [ $DO_PROXY -eq 1]; do 135 | puts "Setting proxy" 136 | export http_proxy=$MYPROXY 137 | export https_proxy=$MYPROXY 138 | fi 139 | 140 | if [ $DO_XCODE_CLI_TOOLS -eq 1 ]; do 141 | puts "Installing XCode Command Line Tools" 142 | xcode-select --install 143 | fi 144 | 145 | # Brew (This will also install xcode command line tools if needed) 146 | if [ $DO_BREW -eq 1 ]; do 147 | puts "Installing brew" 148 | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" 149 | brew doctor 150 | elif [ $DO_PORTS -eq 1 ]; do 151 | puts "Nothing for ports install yet" 152 | fi 153 | # TODO: Is that the correct elif syntax? 154 | 155 | # GPG 156 | if [ $DO_GPG -eq 1 ]; do 157 | puts "Installing gpg" 158 | $PKG_MGR install gpg 159 | # for RVM 160 | if [ $DO_RVM -eq 1 ]; do 161 | puts "Fetching RVM's public key" 162 | gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 163 | fi 164 | fi 165 | 166 | #RVM 167 | if [ $DO_RVM -eq 1 ]; do 168 | puts "Installing RVM" 169 | \curl -sSL https://get.rvm.io | bash -s stable --ruby 170 | rvm rvmrc to ruby-version # optional. can also throw an ignorable error 171 | fi 172 | 173 | # other stuff for package manager to install 174 | if [ $PKG_MGR -neq 0 ]; do 175 | PACKAGES="nmap wget" 176 | puts "Installing packages: $PACKAGES" 177 | $PKG_MGR install $BREW_PACKAGES 178 | fi 179 | 180 | # 181 | # Editors 182 | # 183 | 184 | # Sublime Text 3 185 | if [ $DO_SUBLIME -eq 1 ]; do 186 | puts "Downloading Sublime Text" 187 | wget -O sublime_text_3.dmg $SUBLIME_URL 188 | puts "Installing Sublime Text" 189 | open sublime_text_3.dmg 190 | # soft link sublime 191 | # sudo not required if you use ~/bin but you'll need to add ~/bin to $PATH 192 | puts "Creating soft link" 193 | sudo ln -s "/Applications/Sublime Text 3.app/Contents/SharedSupport/bin/subl" /usr/bin/subl 194 | # set as default editor? 195 | export EDITOR='subl -w' 196 | fi 197 | 198 | # vi/vim 199 | if [ $DO_VIM -eq 1 ]; do 200 | puts "Configuring vim" 201 | # what, pkg_mgr install vim?, does that doing anything? 202 | # Janus? 203 | export EDITOR='vim' 204 | puts "Nothing for vim yet" 205 | fi 206 | 207 | # 208 | # VPN Stuff 209 | # 210 | 211 | # Create PPP network script to make VPN'ing not suck 212 | if [ $DO_VPN_PPP -eq 1 ]; do 213 | puts "Creating PPP network script" 214 | cat << EOF > /etc/ppp/ip-up 215 | #!/bin/sh 216 | 217 | # Create /etc/ppp if it does not exist (it should tho and is root:wheel 755 on mine) 218 | # Then create /etc/ppp/ip-up as world executable with the following contents: 219 | 220 | if [ "${4%%.*}" = "16" ]; then 221 | /sbin/route add 15.0.0.0/8 $4 222 | else 223 | if [ "${4%%.*}" = "15" ]; then 224 | /sbin/route add 16.0.0.0/8 $4 225 | fi 226 | fi 227 | EOF 228 | fi 229 | -------------------------------------------------------------------------------- /ruby_dev_env/make_dope_ruby_dev_env.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # 4 | # Usage: see usage function definition 5 | # 6 | # NOTE: bash version >= 3.2 is required. Use bash --version to verify 7 | 8 | # 9 | # Function Defs 10 | # 11 | 12 | # Simple IO functions 13 | function puts { 14 | # echos '[*] ' and arguments with the -e and -n flags (to stdout) 15 | # only print something if quiet is empty 16 | if [ -z "$QUIET" ]; then 17 | echo -en "[*] $@" 18 | fi 19 | } 20 | function eqo { 21 | # echos the arguments if quiet is false 22 | # only print something if quiet is empty 23 | if [ -z "$QUIET" ]; then 24 | echo "$@" 25 | fi 26 | } 27 | function warn { 28 | # warnings, i.e. non-fatal errors to stdout 29 | # echos '[-] ' and arguments with the -e and -n flags (to stdout) 30 | echo -en "[-] $@" 31 | } 32 | function die { 33 | # fatal or nearly-fatal errors, if you give a second argument, it is used as an exit code 34 | # and implode is called (attempt to remove all the damage so far) 35 | # echos '[!] ' and first argument with the -e and -n flags and redirect to stderr 36 | # if a second argument is given, this function will exit with that argument as the code 37 | echo -en "[-] $1" >&2 38 | if [ $2 ]; then implode && exit $2;fi 39 | } 40 | 41 | # Functional functions 42 | 43 | function for_each_ver { 44 | # this fxn just runs $cmd ${thing}$ver, so $ver is appended to end of thing 45 | # $1 should be the command to run on each thing 46 | cmd="$1" 47 | # $2 should be a list of things to do for each ver 48 | things="$2" 49 | for ver in $RUBY_VERS; do 50 | for thing in $things; do 51 | $cmd ${thing}$ver 52 | done 53 | done 54 | } 55 | 56 | function cleanup { 57 | # Called after successful or unsuccessful install, so shouldn't be destructive 58 | # Instead see the implode function if you want to undo the damage you've done 59 | apt-get autoremove 60 | } 61 | 62 | myself="$0" 63 | function usage { 64 | # if arguments provided, assume they are warning messages to be displayed 65 | echo 66 | if [ -n "$1" ]; then warn "$@";fi 67 | echo "Usage: $myself [multi|single]" 68 | echo "Multi is multi-user mode (or system-wide), must be run with sudo (NOT as root)" 69 | echo "Single is single-user mode, run script as that user" 70 | } 71 | 72 | function validate_options { 73 | # Validates options and calls usage if any fail 74 | 75 | # we only expect one argument 76 | if [ ! $# == 1 ]; then usage "Wrong number of arguments" && exit 1;fi 77 | #check that the argument is kickass 78 | if [ "$1" == "single" ] || "$opt" == multi ]]; then usage "Unrecognized argument" && exit 1;fi 79 | mode="$1" 80 | } 81 | 82 | function get_user_home { 83 | # argument is assumed to be a complete user name 84 | if [ -z "$1" ]; then die "No user given\n" "0";fi 85 | check_valid_users "$u" 86 | echo $(grep ^$u: /etc/passwd | cut -d":" -f6) 87 | } 88 | 89 | function implode { 90 | # Called when catastrophic failure or interrupted, it attemps to undo everything 91 | 92 | # rvm implode, and in case that doesn't work, also run the script from 93 | # http://beginrescueend.com/support/troubleshooting/#remove 94 | 95 | rvmsudo rvm implode || rvm implode 96 | /usr/bin/sudo rm -rf $HOME/.rvm $HOME/.rvmrc /etc/rvmrc /etc/profile.d/rvm.sh /usr/local/rvm /usr/local/bin/rvm 97 | /usr/bin/sudo /usr/sbin/groupdel rvm 98 | puts "RVM is removed. Please check all .bashrc|.bash_profile|.profile|.zshrc for 99 | RVM source lines and delete or comment out if this was a Per-User installation." 100 | 101 | # purge every package we've installed so far 102 | apt-get -y purge $aptq 103 | } 104 | 105 | function apt_que { 106 | # let's track everything we install so we can remove it if need be 107 | $aptq="${aptq} $@" 108 | apt-get -y install "$@" 109 | } 110 | 111 | function install_RVM { 112 | # 113 | # Install RVM 114 | # 115 | # TODO: if statement and install differently if single mode 116 | if "$mode" == "single"; then 117 | die "Homey don't play dat right now" 99 118 | else # multi 119 | #warn "Manually skipping rvm intall for now\n" 120 | puts "Installing rvm in multi-user mode\n" 121 | puts "--> See: http://beginrescueend.com/rvm/install/ for details or if troubles" 122 | if [ -z "$(which curl)" ]; then 123 | # no curl, let's install it 124 | puts "Installing curl\n" 125 | apt_que -y install curl 126 | fi 127 | 128 | puts "Curling\n" 129 | # !! IMPORTANT !! this is where it's critical this script be run with sudo, NOT as root 130 | # for details see: http://beginrescueend.com/support/troubleshooting/#sudo 131 | bash < <( curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer ) 132 | 133 | puts "Adding users $USERS to the rvm group, you'll have to add others yourself\n" 134 | for user in $USERS; do usermod -a -G rvm $user;done 135 | 136 | # Update bashrc_profile for each user 137 | #for user in $USERS; do 138 | # basher=$(get_user_home $user)/.bashrc_profile 139 | # if ! $(grep -q "Load RVM source" $basher); then 140 | # puts "Updating bashrc_profile for $user\n" 141 | # # in multi user mode, bashrc is updated for eveyone by creating 142 | # # /etc/profile.d/rvm.sh. We will source that here, but you may need to log out and in 143 | # echo "# Enable Tab Completion in RVM 144 | #[[ -r /usr/local/rvm/scripts/completion ]] && source /usr/local/rvm/scripts/completion" >> $basher 145 | # fi 146 | # done 147 | echo "[[ -r /usr/local/rvm/scripts/completion ]] && source /usr/local/rvm/scripts/completion" >> /etc/profile.d/rvm.sh 148 | source /etc/profile.d/rvm.sh 149 | fi # end mode if 150 | } 151 | 152 | function install_rubies { 153 | for ver in $@; do 154 | puts "Installing ruby $ver\n" 155 | if $(echo $ver | grep -q '1.9'); then 156 | # if we're installing a 1.9* version, we need to make sure of some things 157 | # installing zlib is required for the rvm install 1.9.1 158 | #apt_que -qq install libzlib-ruby zlibc zlib-bin 159 | #rvm pkg install zlib 160 | # rvm install $ver -C --with-zlib-dir='$rvm_path'/usr 161 | rvm install $ver 162 | else 163 | # just do the install 164 | #warn "Skipping rvm install $ver" 165 | rvm install $ver 166 | fi 167 | done 168 | } 169 | 170 | function configure_irbrc { 171 | #configure irb http://ruby-doc.org/docs/ProgrammingRuby/html/irb.html 172 | # $@ is a list of users for which to configure 173 | for user in $@; do 174 | irbrc="$(get_user_home $user)/.irbrc" #let's assume ~/.irbc for now 175 | puts "Updating $irbc\n" 176 | echo "puts \"Loading $irbrc\"" >> $irbrc 177 | echo "require 'rubygems'" >> $irbrc 178 | echo "require 'wirble'" >> $irbrc 179 | echo "require 'irb/completion'" >> $irbrc 180 | echo "Wirble.init" >> $irbrc 181 | echo "Wirble.colorize" >>$irbrc 182 | echo -e "class Object\n\t# get all the methods for an object that aren't basic methods from Object\n\tdef local_methods\n\t\t(methods - Object.instance_methods).sort\n\tend\nend" 183 | done 184 | } 185 | 186 | function ifdo { 187 | # $1 is what to check for nonzero length, $2 is what to execute 188 | if [ -n "$1" ]; then echo "running $2" && eval "$2";fi 189 | } 190 | 191 | # TRAPS 192 | trap ' warn "Caught interrupt signal... trying to revert everything" && implode && cleanup ' ABRT HUP INT TERM QUIT 193 | 194 | # 195 | # END Function Defs 196 | # 197 | 198 | # -- Prep -- 199 | # Whether to be quiet, anything but an empty string is considered true 200 | QUIET='' 201 | # Check for valid usage & set the mode 202 | #validate_options "$@" 203 | 204 | # 205 | # Configuration 206 | # 207 | 208 | # List of ruby versions to install with rvm 209 | RUBY_VERS="1.9.2" 210 | # Version of ruby to set as system default 211 | RUBY_DEFAULT_VER="1.9.2" 212 | # List of gems that always get installed 213 | ALWAYS_GEMS="hpricot sqlite3 pg wirble mysql" 214 | # List of packages that always get installed 215 | ALWAYS_PKGS="" 216 | # Nokogiri has some special dependencies... 217 | # Whether to install Nokogiri. Anything but an empty string is considered true 218 | INSTALL_NOKO="true" 219 | # List of additional packages to install. 220 | # dradis: rubygems libsqlite3-0 libsqlite3-dev libxml2-dev libxslt1-dev 221 | MY_PKGS="libsqlite3-0 libsqlite3-dev libxml2-dev libxslt1-dev" 222 | # List of additional gems to install. Installed after all other actions. 223 | MY_GEMS="bundler rest-client mechanize" 224 | # For now, just get the *real* user running this script 225 | USERS=$(who am i | cut -d" " -f1) 226 | 227 | # 228 | # END Configuration 229 | # 230 | 231 | source "$HOME/.rvm/scripts/rvm" 232 | puts "Updating apt cache\n" 233 | apt-get -qq update 234 | # install git if needed 235 | if [ -z "$(which git)" ]; then 236 | puts "Installing git-core\n" 237 | apt_que git-core 238 | fi 239 | 240 | #ifdo "$INSTALL_RVM" "install_RVM" 241 | #ifdo "$RUBY_VERS" "install_rubies $RUBY_VERS" 242 | 243 | puts "Installing gems:$ALWAYS_GEMS\n" 244 | ifdo $ALWAYS_GEMS "rvm gem install $ALWAYS_GEMS" 245 | puts "Setting ruby default to $RUBY_DEFAULT_VER\n" 246 | ifdo "$RUBY_DEFAULT_VER" "rvm $RUBY_DEFAULT_VER --default" 247 | 248 | #ifdo "$USERS" "configure_irbrc $USERS" 249 | 250 | # NOKOGIRI 251 | if [ -n "$INSTALL_NOKO" ]; then 252 | puts "Installing Nokogiri and it's dependencies\n" 253 | # TODO: need to check what rvm has already installed, see if ri,irb etc are included 254 | # dev_packages="ruby-dev ri rdoc irb" 255 | 256 | # this seems unnec if rvm install 1.9.2 was performed 257 | #dev_packages="libreadline-ruby libopenssl-ruby" 258 | #puts "\tInstalling $dev_packages\n" 259 | #for_each_ver 'apt_que' $dev_packages 260 | 261 | packages="libxslt1-dev libxml2-dev" 262 | puts "\tInstalling $packages\n" 263 | for pkg in $packages; do apt_que $pkg;done 264 | 265 | # rvm gem install nokogiri, this will install gem into all versions rvm knows about 266 | puts "\tInstalling Nokogiri gem\n" 267 | rvm gem install nokogiri 268 | fi 269 | 270 | # MY PACKAGES 271 | if [ -n "$MY_PKGS" ]; do 272 | puts "Installing additional packages: $MY_PKGS\n" 273 | for pkg in $MY_PKGS; do puts "\tInstalling pkg: $pkg\n" && apt_que $pkg;done 274 | fi 275 | 276 | # MY GEMS 277 | # Do this last in case it depends on anything above 278 | if [ -n "$MY_GEMS" ]; do 279 | puts "Installing additional gems: $MY_GEMS\n" 280 | for gem in $MY_GEMS; do puts "\tInstalling gem: $gem\n" && rvm gem install $gem;done 281 | fi 282 | 283 | 284 | : <<-EOF 285 | apt-get -y install git-core 286 | apt-get -y install curl 287 | bash < <( curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer ) 288 | edit "$HOME/.bashrc 289 | source "$HOME/.bashrc" 290 | # 1.9.2 stuff isn't in default ubuntu libs 291 | rvmsudo apt-get install libreadline-ruby1.9.2 libopenssl-ruby1.9.2 libxslt1-dev libxml2-dev 292 | rvm gem install hpricot wirble pg 293 | rvm $RUBY_DEFAULT_VER --default 294 | sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 81C0BE11 295 | sudo add-apt-repository ppa:ubuntu-on-rails/pp 296 | sudo apt-get install libreadline-ruby1.9.2 libruby1.9.2 297 | rvm gem install nokogiri rest-client mechanize bundler sqlite3 sqlite3-ruby 298 | EOF 299 | -------------------------------------------------------------------------------- /useful_scripts/bt4-joshomise.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Tested on GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu) 4 | # Bash script to customize the BackTrack 4 R* iso 5 | # by kernelsmith {kernelsmith \x40 kernelsmith \x2E com} 6 | 7 | # 8 | # some "constants" 9 | # 10 | # EXIT CODES 11 | _ERR_WRONG_ARGS=41 #wrong number or type of _A_rguments 12 | _ERR_CANT_FIND_ISO=70 #can't _F_ind the source iso file ($btisoname) 13 | _ERR_CANT_MOUNT=77 #can't _M_ount 14 | _ERR_YOU_NOT_ROOT=82 #you're not _R_oot so I can't mount stuff, try 'sudo -i' or 'su -' first 15 | _ERR_CANT_WRITE_DIR=87 #can't _W_rite to a directory 16 | 17 | # 18 | # some variables 19 | # 20 | origdir="$(pwd)" 21 | builddir="${origdir}/BUILD" 22 | btisoname= 23 | outname="${origdir}/bt4-mod.iso" 24 | tstamp= 25 | quiet= 26 | shell= 27 | myself="$(basename $0)" 28 | #mypid=$$ 29 | logfile=".${myself}.log" 30 | 31 | # 32 | #define some fxns 33 | # 34 | function puts { 35 | # echos '[*] ' and arguments with the -e and -n flags (to stdout) 36 | # only print something if quiet is empty 37 | echo -en "[*] $@" > $logfile 38 | if [ -z "$quiet" ]; then 39 | echo -en "[*] $@" 40 | fi 41 | } 42 | function eqo { 43 | # echos the arguments if quiet is false 44 | # only print something if quiet is empty 45 | echo "$@" > $logfile 46 | if [ -z "$quiet" ]; then 47 | echo "$@" 48 | fi 49 | } 50 | function warn { 51 | # warnings, i.e. non-fatal errors 52 | # echos '[!] ' and arguments with the -e and -n flags (to stdout) 53 | echo -en "[!] $@" > $logfile 54 | echo -en "[!] $@" 55 | } 56 | function err { 57 | # fatal or nearly-fatal errors, if you give a second argument, it is used as an exit code 58 | # echos '[-] ' and first argument with the -e and -n flags and redirect to stderr 59 | # if a second argument is given, this function will exit with that argument as the code 60 | echo -en "[-] $1" > $logfile 61 | echo -en "[-] $1" >&2 62 | if [ $2 ]; then exit $2;fi 63 | } 64 | function chk_mkdir { 65 | # make a directory (with -p) if it doesn't exist 66 | if [ ! -d "$1" ]; then 67 | # make the directory, or fail out 68 | mkdir -p $1 || err "Cannot write to current directory...aborting" $_ERR_CANT_WRITE_DIR 69 | fi 70 | } 71 | 72 | function interact { 73 | echo 74 | echo 75 | puts "Starting interactive shell, type 'exit' when done\n" 76 | oldPS1="$PS1" 77 | export PS1='[Interacting with iso. Enter exit to exit chroot]# ' 78 | chroot edit 79 | PS1="$oldPS1" 80 | puts "Exited the interactive shell\n" 81 | echo 82 | echo 83 | } 84 | 85 | function fastrm { 86 | # if perl is readily available, use it's 'unlink' to remove stuff, it's much faster than 'rm' 87 | # This is a hack to keep the syntax the same as that for 'rm' and to avoid 88 | # invoking 'perl -nle' a bunch of times, which would be somewhat counterproductive 89 | # There's probably a smarter way using 'xargs' or something or maybe some crazy 'find' 90 | if [ $(which perl) ] &>/dev/null; then 91 | templist= 92 | for item in "$@"; do templist="${templist}${item}\n";done 93 | echo -en $templist | perl -nle unlink 94 | else 95 | # else use rm -rf as the fall back 96 | rm -rf "$@" 97 | fi 98 | } 99 | 100 | function cleanup { 101 | 102 | # "remove" all the remnants 103 | puts "Cleaning up..." 104 | 105 | # change back to the original directory, as we won't always know when this will get called 106 | cd $origdir 107 | 108 | #-stuff that's possibly mounted 109 | mountain="edit/dev edit/proc squashfs mnt" 110 | for mounty in $mountain; do 111 | umount ${builddir}/${mounty} &> /dev/null || warn "Could not unmount ${builddir}/${mounty}\n" 112 | done 113 | chroot edit 114 | 115 | #-files 116 | fastrm $outname || warn "Could not remove $outname\n" 117 | 118 | #-directories 119 | fastrm $builddir || warn "Could not remove the build directory: $builddir" 120 | 121 | #-variables/"constants" 122 | for c in $(set | grep '^_ERR_' | cut -d'=' -f1); do unset ${v}; done 123 | for v in "builddir btisoname myself mypid"; do unset ${c}; done 124 | 125 | #-functions? ugh. 126 | #unset -f fxnname 127 | puts "Done." 128 | } 129 | 130 | function stampit { 131 | echo "$@.$(date +%Y%m%d-%H%M%S)" 132 | } 133 | 134 | function usage { 135 | if [ -n "$1" ]; then err "$@";fi 136 | echo 137 | echo "Usage: $myself input-iso [-o output-iso] [-t] [-s] [-q]" 138 | echo " -o name the output file output-iso instead of bt4-mod.iso" 139 | echo " -t append a sortable timestamp (YrMoDay-HrMinSec) to the output file (no clobber)" 140 | echo " -s definitely provide an interactive shell (requires interaction to complete)" 141 | echo " -q be quiet, only give warnings and errors, don't provide a shell (overrides -s)" 142 | echo "Examples:" 143 | echo " $myself /isos/bt4.iso -o mybt4.iso -t -q" 144 | echo " Takes /isos/bt4.iso and produces mybt4.iso.20110429-235609 in the current dir" 145 | } 146 | 147 | # 148 | # TRAPS 149 | # 150 | trap ' err "Caught interrupt signal... cleaning up" && cleanup ' ABRT HUP INT TERM QUIT 151 | 152 | ###################################################################### 153 | # OK, let's do this shiz 154 | ###################################################################### 155 | 156 | if [ -z "$1" ]; then 157 | usage "Missing source iso name\n" 158 | exit $_ERR_WRONG_ARGS 159 | fi 160 | 161 | btisoname="$(readlink -f $1)" 162 | shift 163 | 164 | while getopts 'o:tqsh' OPTION 165 | do 166 | case $OPTION in 167 | o) outname="$OPTARG" 168 | ;; 169 | t) tstamp=1 170 | ;; 171 | q) quiet=1 172 | ;; 173 | s) shell=1 174 | ;; 175 | h) usage 176 | exit 0 177 | ;; 178 | ?) usage "Unrecognized or missing arguments\n" 179 | exit $_ERR_WRONG_ARGS 180 | ;; 181 | esac 182 | done 183 | shift $(($OPTIND - 1)) 184 | 185 | # check if root 186 | if [[ $EUID -ne 0 ]]; then 187 | err "You must be root for these shenanigans... sudo?\n" $_ERR_YOU_NOT_ROOT 188 | fi 189 | 190 | # 191 | # Validate args 192 | # 193 | # if $btisoname doesn't exist, then abort 194 | if ! [ -f $btisoname ]; then 195 | err "Cannot find $btisoname... aborting\n\n" $_ERR_CANT_FIND_ISO 196 | fi 197 | # if can't touch outname, then can't write to destination dir, abort 198 | if ! touch $outname; then 199 | err "Cannot write to $(dirname $outname)" $_ERR_CANT_WRITE_DIR 200 | fi 201 | outname="$(readlink -f $outname)" 202 | # if can't touch logfile, then can't write it, abort 203 | if ! touch $logfile; then 204 | err "Cannot write to $(dirname $logfile)" $_ERR_CANT_WRITE_DIR 205 | fi 206 | logfile="$(readlink -f $logfile)" 207 | 208 | # create the builddir if nec 209 | chk_mkdir $builddir 210 | cd $builddir 211 | 212 | clear 213 | puts "----------------------------------------------------------- [*]\n" 214 | puts "BackTrack 4 joshomization script\n" 215 | puts "Setting up the build environment...\n" 216 | 217 | chk_mkdir mnt 218 | mount -o loop $btisoname mnt/ || err "Cannot mount the iso (requires -o loop)\n" $_ERR_CANT_MOUNT 219 | chk_mkdir extract-cd 220 | rsync --exclude=/casper/filesystem.squashfs -a mnt/ extract-cd 221 | chk_mkdir squashfs 222 | mount -t squashfs -o loop mnt/casper/filesystem.squashfs squashfs/ || \ 223 | err 'Cannot mount the squashfs (requires -t squashfs)\n' $_ERR_CANT_MOUNT 224 | chk_mkdir edit 225 | puts 'Copying over files, please wait ... \n' 226 | 227 | puts "...squashfs..." 228 | cp -a squashfs/* edit/ 229 | puts "...resolv.conf..." 230 | cp /etc/resolv.conf edit/etc/ 231 | puts "...hosts..." 232 | cp /etc/hosts edit/etc/ 233 | puts "...fstab..." 234 | cp /etc/fstab edit/etc/ 235 | puts "..mtab..." 236 | cp /etc/mtab edit/etc/ 237 | 238 | eqo 239 | 240 | mount --bind /dev/ edit/dev || err 'Cannot mount /dev/ (requires --bind)\n' $_ERR_CANT_MOUNT 241 | mount -t proc /proc edit/proc || err 'Cannot mount /proc (requires -t proc)\n' $_ERR_CANT_MOUNT 242 | 243 | puts "----------------------------------------------------------- [*]\n" 244 | puts "Entering the live iso.\n" 245 | puts "----------------------------------------------------------- [*]\n" 246 | puts "If you are running a large update, you might need to stop\n" 247 | puts "services like crond, udev, cups, etc in the chroot\n" 248 | puts "before exiting your chroot environment.\n" 249 | puts "----------------------------------------------------------- [*]\n" 250 | puts "Starting modifications\n" 251 | puts "----------------------------------------------------------- [*]\n" 252 | 253 | ############################################################################### 254 | # At this point, anything starting with 'chroot edit' is in the build environ 255 | 256 | #------------------------------------------- 257 | # OS & TOOL(REPO) UPDATES 258 | #------------------------------------------- 259 | puts "Updating the OS with apt-get update and upgrade\n" 260 | chroot edit /usr/bin/apt-get update --fix-missing 261 | chroot edit /usr/bin/apt-get -y upgrade 262 | puts "Cleaning the apt cache\n" 263 | chroot edit /usr/bin/apt-get -y clean 264 | 265 | #-------------------------------------------- 266 | # TOOL SPECIFIC UPDATES 267 | #-------------------------------------------- 268 | 269 | #update metasploit, note svn update is called directly so server cert issues can be avoided 270 | puts "Updating metasploit\n" 271 | chroot edit cd /opt/metasploit3/msf3/ && /usr/bin/svn update --non-interactive --trust-server-cert 272 | # update fast-track 273 | # command line updating was disabled by the fasttrack author 274 | #chroot edit "cd /pentest/exploits/fasttrack && python fast-track.py -c 1" 275 | # update SET 276 | #chroot edit cd /pentest/exploits/SET && python set-update 277 | 278 | #-------------------------------------------- 279 | # CUSTOM UPDATES 280 | #-------------------------------------------- 281 | 282 | #NOTE: You may need to add these to the removal section of the manifest and/or rc 283 | puts "Installing custom packages: $newinstalls" 284 | newinstalls="vim kde-guidance-kde3 bashish" 285 | for melikey in $newinstalls; do 286 | apt-get -y install $melikey 287 | done 288 | 289 | #-------------------------------------------- 290 | # MANUAL UPDATES (INTERACTIVE) 291 | #-------------------------------------------- 292 | 293 | # If quiet not requested, decide on whether to present an interactive shell 294 | if [ -z "$quiet" ]; then 295 | # first check if shell is already requested 296 | if [ -n "$shell" ]; then 297 | interact 298 | else 299 | # Ask if they want to enter some manual commands in an interactive shell 300 | # default is no 301 | CHOICE="n" 302 | read -t 30 -p "[-?-] Want to start an interactive shell for manual commands? [y/n] (timeout=30): " 303 | echo 304 | case "$CHOICE" in 305 | [yY1]) interact;; 306 | * ) puts "Skipping interactive shell\n";; 307 | esac 308 | fi 309 | fi 310 | 311 | ##################################################################### 312 | # EXITING THE BUILD ENVIRONMENT 313 | ##################################################################### 314 | puts "Exited the build environment, unmounting images...\n" 315 | 316 | rm -rf edit/etc/mtab 317 | rm -rf edit/etc/fstab 318 | 319 | umount edit/dev || warn "Could not unmount edit/dev\n" 320 | umount edit/proc || warn "Could not unmount edit/proc\n" 321 | umount squashfs || warn "Could not unmount sqashfs\n" 322 | umount mnt || warn "Could not unmount mnt\n" 323 | puts "Done.\n" 324 | 325 | chmod +w extract-cd/casper/filesystem.manifest 326 | 327 | puts "Building manifest, give me a sec..." 328 | chroot edit dpkg-query -W --showformat='${Package} ${Version}\n' > extract-cd/casper/filesystem.manifest 329 | 330 | # 331 | # Remove some services from the rc.d 332 | # 333 | services="inetutils-inetd tinyproxy iodined knockd openvpn atftpd ntop nstxd nstxcd apache2 sendmail atd dhcp3-server winbind miredo miredo-server pcscd wicd wacom cups bluetooth binfmt-support mysql" 334 | 335 | for service in $services;do 336 | chroot edit update-rc.d -f $service remove 337 | done 338 | 339 | # 340 | # Remove some entries in the manifest 341 | # 342 | REMOVE='ubiquity casper live-initramfs user-setup discover xresprobe os-prober libdebian-installer4' 343 | for i in $REMOVE;do 344 | sed -i "/${i}/d" extract-cd/casper/filesystem.manifest-desktop 345 | done 346 | 347 | cp extract-cd/casper/filesystem.manifest extract-cd/casper/filesystem.manifest-desktop 348 | puts "Done.\n" 349 | 350 | sed -i '/ubiquity/d' extract-cd/casper/filesystem.manifest-desktop 351 | 352 | fastrm extract-cd/casper/filesystem.squashfs 353 | puts "Building squashfs image..." 354 | 355 | mksquashfs edit extract-cd/casper/filesystem.squashfs 356 | puts "Done.\n" 357 | 358 | fastrm extract-cd/md5sum.txt 359 | 360 | (cd extract-cd && find . -type f -print0 | xargs -0 md5sum > md5sum.txt) 361 | 362 | cd extract-cd 363 | 364 | puts "Creating iso..." 365 | mkisofs -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -V "BT4" -cache-inodes -r -J -l -o ${outname} . 366 | puts "Done. \n" 367 | 368 | cd $origdir 369 | 370 | eqo 371 | eqo 372 | puts "~^~._.~^~._.~^~._.~^~._.~^~._.~^~._.~^~._.~^~._.~^~._.~^~ [*]\n" 373 | puts "Your modified iso is at ${outname}\n" 374 | puts "~^~._.~^~._.~^~._.~^~._.~^~._.~^~._.~^~._.~^~._.~^~._.~^~ [*]\n\n" 375 | 376 | exit 0 377 | -------------------------------------------------------------------------------- /useful_scripts/checkbashisms.pl: -------------------------------------------------------------------------------- 1 | #! /usr/bin/perl -w 2 | # 3 | # checkbashisms.perl 4 | # 5 | # Version: 2.0.0.2 6 | # Date: 30th January 2011 7 | # 8 | # (C) Copyright 1998-2003 Richard Braakman, Josip Rodin and Julian Gilbey 9 | # Additional programming by Mark Hobley 10 | # 11 | # This script is based on source code taken from the lintian project 12 | # 13 | # This program can be redistributed under the terms of version 2 of the 14 | # GNU General Public Licence as published by the Free Software Foundation 15 | # 16 | 17 | use strict; 18 | use Getopt::Long; 19 | 20 | sub init_hashes; 21 | 22 | (my $progname = $0) =~ s|.*/||; 23 | 24 | my $usage = <<"EOF"; 25 | Usage: $progname [-n] [-f] [-x] script ... 26 | or: $progname --help 27 | or: $progname --version 28 | This script performs basic checks for the presence of bashisms 29 | in /bin/sh scripts. 30 | EOF 31 | 32 | my $version = <<"EOF"; 33 | This is $progname version 2.0.0.1 34 | (C) Copyright 1998-2003 Richard Braakman, Josip Rodin and Julian Gilbey 35 | Additional programming by Mark Hobley 36 | EOF 37 | 38 | my ($opt_echo, $opt_force, $opt_extra, $opt_posix); 39 | my ($opt_help, $opt_version); 40 | 41 | ## 42 | ## handle command-line options 43 | ## 44 | $opt_help = 1 if int(@ARGV) == 0; 45 | 46 | GetOptions("help|h" => \$opt_help, 47 | "version|v" => \$opt_version, 48 | "newline|n" => \$opt_echo, 49 | "force|f" => \$opt_force, 50 | "extra|x" => \$opt_extra, 51 | "posix|p" => \$opt_posix, 52 | ) 53 | or die "Usage: $progname [options] filelist\nRun $progname --help for more details\n"; 54 | 55 | if ($opt_help) { print $usage; exit 0; } 56 | if ($opt_version) { print $version; exit 0; } 57 | 58 | $opt_echo = 1 if $opt_posix; 59 | 60 | my $status = 0; 61 | my $makefile = 0; 62 | my (%bashisms, %string_bashisms, %singlequote_bashisms); 63 | my $LEADIN = qr'(?:(?:^|[`&;(|{])\s*|(?:if|then|do|while|shell)\s+)'; 64 | 65 | init_hashes; 66 | 67 | foreach my $filename (@ARGV) { 68 | my $check_lines_count = -1; 69 | 70 | if (!$opt_force) { 71 | $check_lines_count = script_is_evil_and_wrong($filename); 72 | } 73 | 74 | if ($check_lines_count == 0 or $check_lines_count == 1) { 75 | warn "script $filename does not appear to be a /bin/sh script; skipping\n"; 76 | next; 77 | } 78 | 79 | if ($check_lines_count != -1) { 80 | warn "script $filename appears to be a shell wrapper; only checking the first " 81 | . "$check_lines_count lines\n"; 82 | } 83 | 84 | unless (open C, '<', "$filename") { 85 | warn "cannot open script $filename for reading: $!\n"; 86 | $status |= 2; 87 | next; 88 | } 89 | 90 | my $cat_string = ""; 91 | my $cat_indented = 0; 92 | my $quote_string = ""; 93 | my $last_continued = 0; 94 | my $continued = 0; 95 | my $found_rules = 0; 96 | my $buffered_orig_line = ""; 97 | my $buffered_line = ""; 98 | while () { 99 | next unless ($check_lines_count == -1 or $. <= $check_lines_count); 100 | 101 | if ($. == 1) { # This should be an interpreter line 102 | if (m,^\#!\s*(\S+),) { 103 | my $interpreter = $1; 104 | 105 | if ($interpreter =~ m,/make$,) { 106 | init_hashes if !$makefile++; 107 | $makefile = 1; 108 | } else { 109 | init_hashes if $makefile--; 110 | $makefile = 0; 111 | } 112 | next if $opt_force; 113 | 114 | if ($interpreter !~ m,/(sh|ash|hsh|posh)$,) { 115 | warn "script $filename does not appear to be a /bin/sh script\n"; 116 | } 117 | } else { 118 | warn "script $filename does not appear to have a \#! interpreter line\n"; 119 | } 120 | } 121 | 122 | chomp; 123 | my $orig_line = $_; 124 | 125 | # We want to remove end-of-line comments, so need to skip 126 | # comments that appear inside balanced pairs 127 | # of single or double quotes 128 | 129 | # Remove comments in the "quoted" part of a line that starts 130 | # in a quoted block? The problem is that we have no idea 131 | # whether the program interpreting the block treats the 132 | # quote character as part of the comment or as a quote 133 | # terminator. We err on the side of caution and assume it 134 | # will be treated as part of the comment. 135 | # s/^(?:.*?[^\\])?$quote_string(.*)$/$1/ if $quote_string ne ""; 136 | 137 | # skip comment lines 138 | if (m,^\s*\#, && $quote_string eq '' && $buffered_line eq '' && $cat_string eq '') { 139 | next; 140 | } 141 | 142 | # Remove quoted strings so we can more easily ignore comments 143 | # inside them 144 | s/(^|[^\\](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1''/g; 145 | s/(^|[^\\](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g; 146 | 147 | # If the remaining string contains what looks like a comment, 148 | # eat it. In either case, swap the unmodified script line 149 | # back in for processing. 150 | if (m/(?:^|[^[\\])[\s\&;\(\)](\#.*$)/) { 151 | $_ = $orig_line; 152 | s/\Q$1\E//; # eat comments 153 | } else { 154 | $_ = $orig_line; 155 | } 156 | 157 | # Handle line continuation 158 | if (!$makefile && $cat_string eq '' && m/\\$/) { 159 | chop; 160 | $buffered_line .= $_; 161 | $buffered_orig_line .= $orig_line . "\n"; 162 | next; 163 | } 164 | 165 | if ($buffered_line ne '') { 166 | $_ = $buffered_line . $_; 167 | $orig_line = $buffered_orig_line . $orig_line; 168 | $buffered_line =''; 169 | $buffered_orig_line =''; 170 | } 171 | 172 | if ($makefile) { 173 | $last_continued = $continued; 174 | if (/[^\\]\\$/) { 175 | $continued = 1; 176 | } else { 177 | $continued = 0; 178 | } 179 | 180 | # Don't match lines that look like a rule if we're in a 181 | # continuation line before the start of the rules 182 | if (/^[\w%-]+:+\s.*?;?(.*)$/ and !($last_continued and !$found_rules)) { 183 | $found_rules = 1; 184 | $_ = $1 if $1; 185 | } 186 | 187 | # Fixes for makefiles by Raphael Geissert 188 | last if m%^\s*(override\s|export\s)?\s*SHELL\s*:?=\s*(/bin/)?bash\s*%; 189 | # Remove "simple" target names 190 | s/^[\w%.-]+(?:\s+[\w%.-]+)*::?//; 191 | s/^\t//; 192 | s/(?|<|;|\Z)/ 290 | and m/$LEADIN(\.\s+[^\s;\`:]+\s+([^\s;]+))/) { 291 | if ($2 =~ /^(\&|\||\d?>|<)/) { 292 | # everything is ok 293 | ; 294 | } else { 295 | $found = 1; 296 | $match = $1; 297 | $explanation = "sourced script with arguments"; 298 | output_explanation($filename, $orig_line, $explanation); 299 | } 300 | } 301 | 302 | # Remove "quoted quotes". They're likely to be inside 303 | # another pair of quotes; we're not interested in 304 | # them for their own sake and removing them makes finding 305 | # the limits of the outer pair far easier. 306 | $line =~ s/(^|[^\\\'\"])\"\'\"/$1/g; 307 | $line =~ s/(^|[^\\\'\"])\'\"\'/$1/g; 308 | 309 | while (my ($re,$expl) = each %singlequote_bashisms) { 310 | if ($line =~ m/($re)/) { 311 | $found = 1; 312 | $match = $1; 313 | $explanation = $expl; 314 | output_explanation($filename, $orig_line, $explanation); 315 | } 316 | } 317 | 318 | my $re='(?); 323 | } 324 | } 325 | 326 | # $cat_line contains the version of the line we'll check 327 | # for heredoc delimiters later. Initially, remove any 328 | # spaces between << and the delimiter to make the following 329 | # updates to $cat_line easier. 330 | my $cat_line = $line; 331 | $cat_line =~ s/(<\<-?)\s+/$1/g; 332 | 333 | # Ignore anything inside single quotes; it could be an 334 | # argument to grep or the like. 335 | $line =~ s/(^|[^\\\"](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1''/g; 336 | 337 | # As above, with the exception that we don't remove the string 338 | # if the quote is immediately preceeded by a < or a -, so we 339 | # can match "foo <<-?'xyz'" as a heredoc later 340 | # The check is a little more greedy than we'd like, but the 341 | # heredoc test itself will weed out any false positives 342 | $cat_line =~ s/(^|[^<\\\"-](?:\\\\)*)\'(?:\\.|[^\\\'])+\'/$1''/g; 343 | 344 | $re='(?); 349 | } 350 | } 351 | 352 | while (my ($re,$expl) = each %string_bashisms) { 353 | if ($line =~ m/($re)/) { 354 | $found = 1; 355 | $match = $1; 356 | $explanation = $expl; 357 | output_explanation($filename, $orig_line, $explanation); 358 | } 359 | } 360 | 361 | # We've checked for all the things we still want to notice in 362 | # double-quoted strings, so now remove those strings as well. 363 | $line =~ s/(^|[^\\\'](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g; 364 | $cat_line =~ s/(^|[^<\\\'-](?:\\\\)*)\"(?:\\.|[^\\\"])+\"/$1""/g; 365 | 366 | while (my ($re,$expl) = each %bashisms) { 367 | if ($line =~ m/($re)/) { 368 | $found = 1; 369 | $match = $1; 370 | $explanation = $expl; 371 | output_explanation($filename, $orig_line, $explanation); 372 | } 373 | } 374 | 375 | # Only look for the beginning of a heredoc here, after we've 376 | # stripped out quoted material, to avoid false positives. 377 | if ($cat_line =~ m/(?:^|[^<])\<\<(\-?)\s*(?:[\\]?(\w+)|[\'\"](.*?)[\'\"])/) { 378 | $cat_indented = ($1 && $1 eq '-')? 1 : 0; 379 | $cat_string = $2; 380 | $cat_string = $3 if not defined $cat_string; 381 | } 382 | } 383 | } 384 | warn "error: $filename: Unterminated heredoc found, EOF reached. Wanted: <$cat_string>\n" 385 | if ($cat_string ne ''); 386 | warn "error: $filename: Unterminated quoted string found, EOF reached. Wanted: <$quote_string>\n" 387 | if ($quote_string ne ''); 388 | warn "error: $filename: EOF reached while on line continuation.\n" 389 | if ($buffered_line ne ''); 390 | 391 | close C; 392 | } 393 | 394 | exit $status; 395 | 396 | sub output_explanation { 397 | my ($filename, $line, $explanation) = @_; 398 | 399 | warn "possible bashism in $filename line $. ($explanation):\n$line\n"; 400 | $status |= 1; 401 | } 402 | 403 | # Returns non-zero if the given file is not actually a shell script, 404 | # just looks like one. 405 | sub script_is_evil_and_wrong { 406 | my ($filename) = @_; 407 | my $ret = -1; 408 | # lintian's version of this function aborts if the file 409 | # can't be opened, but we simply return as the next 410 | # test in the calling code handles reporting the error 411 | # itself 412 | open (IN, '<', $filename) or return $ret; 413 | my $i = 0; 414 | my $var = "0"; 415 | my $backgrounded = 0; 416 | local $_; 417 | while () { 418 | chomp; 419 | next if /^#/o; 420 | next if /^$/o; 421 | last if (++$i > 55); 422 | if (m~ 423 | # the exec should either be "eval"ed or a new statement 424 | (^\s*|\beval\s*[\'\"]|(;|&&|\b(then|else))\s*) 425 | 426 | # eat anything between the exec and $0 427 | exec\s*.+\s* 428 | 429 | # optionally quoted executable name (via $0) 430 | .?\$$var.?\s* 431 | 432 | # optional "end of options" indicator 433 | (--\s*)? 434 | 435 | # Match expressions of the form '${1+$@}', '${1:+"$@"', 436 | # '"${1+$@', "$@", etc where the quotes (before the dollar 437 | # sign(s)) are optional and the second (or only if the $1 438 | # clause is omitted) parameter may be $@ or $*. 439 | # 440 | # Finally the whole subexpression may be omitted for scripts 441 | # which do not pass on their parameters (i.e. after re-execing 442 | # they take their parameters (and potentially data) from stdin 443 | .?(\${1:?\+.?)?(\$(\@|\*))?~x) { 444 | $ret = $. - 1; 445 | last; 446 | } elsif (/^\s*(\w+)=\$0;/) { 447 | $var = $1; 448 | } elsif (m~ 449 | # Match scripts which use "foo $0 $@ &\nexec true\n" 450 | # Program name 451 | \S+\s+ 452 | 453 | # As above 454 | .?\$$var.?\s* 455 | (--\s*)? 456 | .?(\${1:?\+.?)?(\$(\@|\*))?.?\s*\&~x) { 457 | 458 | $backgrounded = 1; 459 | } elsif ($backgrounded and m~ 460 | # the exec should either be "eval"ed or a new statement 461 | (^\s*|\beval\s*[\'\"]|(;|&&|\b(then|else))\s*) 462 | exec\s+true(\s|\Z)~x) { 463 | 464 | $ret = $. - 1; 465 | last; 466 | } elsif (m~\@DPATCH\@~) { 467 | $ret = $. - 1; 468 | last; 469 | } 470 | 471 | } 472 | close IN; 473 | return $ret; 474 | } 475 | 476 | sub init_hashes { 477 | my $LEADIN = qr'(?:(^|[`&;(|{])\s*|(if|then|do|while|shell)\s+)'; 478 | 479 | %bashisms = ( 480 | qr'(?:^|\s+)function \w+(\s|\(|\Z)' => q<'function' is useless>, 481 | $LEADIN . qr'select\s+\w+' => q<'select' is not portable>, 482 | qr'(test|-o|-a)\s*[^\s]+\s+==\s' => q, 483 | qr'\[\s+[^\]]+\s+==\s' => q, 484 | qr'\s\|\&' => q, 485 | qr'[^\\\$]\{([^\s\\\}]*?,)+[^\\\}\s]*\}' => q, 486 | qr'\{\d+\.\.\d+\}' => q, 487 | qr'(?:^|\s+)\w+\[\d+\]=' => q, 488 | $LEADIN . qr'read\s+(?:-[a-qs-zA-Z\d-]+)' => q, 489 | $LEADIN . qr'read\s*(?:-\w+\s*)*(?:\".*?\"|[\'].*?[\'])?\s*(?:;|$)' 490 | => q, 491 | $LEADIN . qr'echo\s+(-n\s+)?-n?en?\s' => q, 492 | $LEADIN . qr'exec\s+-[acl]' => q, 493 | $LEADIN . qr'let\s' => q, 494 | qr'(? q<'((' should be '$(('>, 495 | qr'(?:^|\s+)(\[|test)\s+-a' => q, 496 | qr'\&>' => qword 2\>&1>, 497 | qr'(<\&|>\&)\s*((-|\d+)[^\s;|)}`&\\\\]|[^-\d\s]+(? 498 | qword 2\>&1>, 499 | $LEADIN . qr'kill\s+-[^sl]\w*' => q, 500 | $LEADIN . qr'trap\s+["\']?.*["\']?\s+.*[1-9]' => q, 501 | $LEADIN . qr'trap\s+["\']?.*["\']?\s+.*ERR' => q, 502 | qr'\[\[(?!:)' => q, 503 | qr'/dev/(tcp|udp)' => q, 504 | $LEADIN . qr'alias\s' => q, 505 | $LEADIN . qr'unalias\s' => q, 506 | $LEADIN . qr'builtin\s' => q, 507 | $LEADIN . qr'caller\s' => q, 508 | $LEADIN . qr'complete\s' => q, 509 | $LEADIN . qr'compgen\s' => q, 510 | $LEADIN . qr'declare\s' => q, 511 | $LEADIN . qr'dirs(\s|\Z)' => q, 512 | $LEADIN . qr'disown\s' => q, 513 | $LEADIN . qr'enable\s' => q, 514 | $LEADIN . qr'export\s+-[^p]' => q, 515 | $LEADIN . qr'export\s+.+=' => q, 516 | $LEADIN . qr'mapfile\s' => q, 517 | $LEADIN . qr'readarray\s' => q, 518 | $LEADIN . qr'readonly\s+-[af]' => q, 519 | $LEADIN . qr'(push|pop)d(\s|\Z)' => q<(push|pop)d>, 520 | $LEADIN . qr'set\s+-[BHT]+' => q, 521 | $LEADIN . qr'shopt(\s|\Z)' => q, 522 | $LEADIN . qr'suspend\s' => q, 523 | $LEADIN . qr'time\s' => q