Browse Source

Initialized new dotfiles repo

master
Tovi Jaeschke-Rogers 5 years ago
commit
832182fe94
28 changed files with 1462 additions and 0 deletions
  1. +109
    -0
      .bashrc
  2. +26
    -0
      .config/aliasrc
  3. +204
    -0
      .config/nvim/init.vim
  4. +6
    -0
      .gitignore_global
  5. +608
    -0
      .iterm2_shell_integration.bash
  6. +5
    -0
      .local/bin/c
  7. +98
    -0
      .local/bin/dmenu-bangs
  8. +15
    -0
      .local/bin/dmenu-scripts/dmenu-emoji
  9. +3
    -0
      .local/bin/dmenu-scripts/dmenu-locate
  10. +3
    -0
      .local/bin/dmenu-scripts/dmenu-man
  11. +28
    -0
      .local/bin/dmenu-scripts/dmenu-mount
  12. +24
    -0
      .local/bin/dmenu-scripts/dmenu-shutdown
  13. +12
    -0
      .local/bin/new-repo
  14. +9
    -0
      .local/bin/nt
  15. +10
    -0
      .local/bin/pentest/bytetoword
  16. +163
    -0
      .local/bin/pentest/leak-lookup
  17. +7
    -0
      .local/bin/shellcode-gen
  18. +26
    -0
      .local/bin/vg
  19. +28
    -0
      .local/bin/workflow/cabl
  20. +4
    -0
      .local/bin/workflow/change_wp
  21. +8
    -0
      .local/bin/workflow/compile
  22. +9
    -0
      .local/bin/workflow/extern_monitor
  23. +25
    -0
      .local/bin/workflow/extract
  24. BIN
      .local/bin/workflow/greenclip
  25. +10
    -0
      .local/bin/workflow/lock_toggle
  26. +4
    -0
      .local/bin/workflow/voldown
  27. +4
    -0
      .local/bin/workflow/volup
  28. +14
    -0
      .local/bin/workflow/vpn

+ 109
- 0
.bashrc View File

@ -0,0 +1,109 @@
#!/bin/bash
set -o vi
bind -m vi-insert "\C-l":clear-screen
shopt -s extglob
HISTSIZE=
HISTFILESIZE=
export EDITOR='nvim'
export GIT_AUTHOR_NAME="Tovi Jaeschke-Rogers"
export GIT_AUTHOR_EMAIL="tovi@tovijaeschke.xyz"
export GIT_COMMITTER_NAME="Tovi Jaeschke-Rogers"
export GIT_COMMITTER_EMAIL="tovi@tovijaeschke.xyz"
export LESS='-R'
export LESSOPEN='|~/.lessfilter %s'
alias ls="ls --color=auto" \
vb='nvim ~/.bashrc && source ~/.bashrc' \
va='nvim ~/.config/aliasrc && source ~/.bashrc'
if [[ $(uname) != "Linux" ]]; then
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash" || true
export HOMEBREW_NO_INSTALL_CLEANUP=1
export GIT_AUTHOR_EMAIL="tovi.jaeschke-rogers@thirty4.com"
export GIT_COMMITTER_EMAIL="tovi.jaeschke-rogers@thirty4.com"
alias ls="ls -G" \
vb='nvim ~/.bash_profile && source ~/.bash_profile' \
va='nvim ~/.config/aliasrc && source ~/.bash_profile'
mount-hdd() {
if [ -z $1 ]; then
sudo umount /dev/disk2s1 && sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Volumes/NTFS -olocal -oallow_other
else
sudo umount /dev/$1 && sudo /usr/local/bin/ntfs-3g /dev/$1 /Volumes/NTFS -olocal -oallow_other
fi
}
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$PATH:$(du "$HOME/.local/bin/" | cut -f2 | tr '\n' ':')"
fi
source ~/.config/aliasrc
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1=" \[\033[0;36m\]\t \[\033[0;35m\]\u\[\033[0;32m\]@\[\033[0;34m\]\h \[\033[32m\]\W\[\033[33m\]\$(parse_git_branch)\[\033[31m\] \n$\[\033[00m\] "
mkcd() {
if [ ! -d "$1" ]; then
mkdir -p "$1" && cd "$1"
elif [ -d "$1" ]; then
cd "$1"
else
echo "Error"
fi
}
# Go up directory structures
up() {
cd $(printf "%0.0s../" $(seq 1 $1));
}
git() {
if [[ $@ == "mergetool" ]]; then
command git mergetool --no-gui
else
command git $@
fi
}
# git branch -vv | grep 'gone\]' | awk ' { print $1 }' | xargs -p git branch -d
git-prune() {
if [[ $@ == "--apply" ]]; then
command git branch --merged develop | grep -vEw "develop$|master$" | xargs git branch -d
else
echo "Run \"git prune --apply\" to delete the following branches:"
command git branch --merged develop | grep -vEw "develop$|master$"
fi
}
color-diff() {
if [ -z ${1+x} ] || [ -z ${2+x} ]; then
echo "Usage: color-diff dir1/ dir2/"
return
fi
diff -bur $1 $2 | colordiff | less
}
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"

+ 26
- 0
.config/aliasrc View File

@ -0,0 +1,26 @@
#!/bin/sh
alias q='exit' \
dd='sudo dd status=progress' \
h="history | grep" \
back='cd -' \
b='cd -' \
py='python3' \
py2='python2' \
v='nvim' \
vim='nvim' \
ka='killall' \
grep='grep --color=auto' \
egrep='grep --color=auto -E' \
sshtj='ssh tovi@tovijaeschke.xyz' \
extip='curl -s www.icanhazip.com' \
ns='sudo nmap -p- -sV' \
cc='rm -rf cache/* && php symfony cc' \
pdu='php symfony propel:diff && php symfony propel:up' \
foursync='php symfony four:sync' \
ddate='date +%d-%m-%Y' \
gitup='git push origin $(git rev-parse --abbrev-ref HEAD)' \
gco='git checkout' \
vv='nvim ~/.config/nvim/init.vim' \
delorig='find . -name "*.orig" -exec rm {} \;' \
delbak='find . -name "*.bak" -exec rm {} \;' \
site-clone='wget --mirror --convert-links --adjust-extension --page-requisites --no-parent'

+ 204
- 0
.config/nvim/init.vim View File

@ -0,0 +1,204 @@
let mapleader =","
if ! filereadable(expand('~/.config/nvim/autoload/plug.vim'))
echo "Downloading junegunn/vim-plug to manage plugins..."
silent !mkdir -p ~/.config/nvim/autoload/
silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim
autocmd VimEnter * PlugInstall
endif
call plug#begin('~/.config/nvim/plugged')
Plug 'morhetz/gruvbox'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
"Plug 'vim-scripts/jcommenter.vim'
"Plug 'SirVer/ultisnips'
"Plug 'phux/vim-snippets'
"Plug 'tobyS/vmustache'
"Plug 'tobyS/pdv'
Plug 'Rican7/php-doc-modded'
Plug 'jreybert/vimagit'
Plug 'bling/vim-airline'
Plug 'tpope/vim-commentary'
Plug 'tpope/vim-fugitive'
Plug 'rbong/vim-flog'
Plug 'ap/vim-css-color'
call plug#end()
" Some basics:
set go=a
set mouse=a
set nohlsearch
set clipboard+=unnamedplus
set incsearch
set smartcase
set noswapfile
set nobackup
set undodir=~/.config/nvim/undodir
set undofile
colorscheme gruvbox
set background=dark
nnoremap c "_c
set nocompatible
filetype plugin on
syntax on
set encoding=utf-8
set number relativenumber
" Indent marks
"set listchars=tab:\|_
"set list
" Tab 2 spaces
filetype plugin indent on
set tabstop=2 softtabstop=2 expandtab shiftwidth=2 smarttab
" Disables automatic commenting on newline:
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" coc
inoremap <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
nmap <leader>gd <Plug>(coc-definition)
nmap <leader>gr <Plug>(coc-references)
inoremap <expr> <C-j> pumvisible() ? "\<Down>" : "\<C-j>"
inoremap <expr> <C-k> pumvisible() ? "\<Up>" : "\<C-k>"
" fzf remaps
"nnoremap <C-p> :GFiles<CR>
nnoremap <C-q> :GFiles<CR>
nnoremap <C-a> :Files<CR>
" php-doc-modded
nnoremap <C-c> :call PhpDocSingle()<CR>i
"nnoremap <C-P> :call PhpDocSingle()<CR>
"vnoremap <C-P> :call PhpDocRange()<CR>
let g:pdv_cfg_autoEndClass = 0
let g:pdv_cfg_autoEndFunction = 0
" Spell-check set to <leader>o, 'o' for 'orthography':
map <leader>o :setlocal spell! spelllang=en_au<CR>
" Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
set splitbelow splitright
" Shortcutting split navigation, saving a keypress:
" nnoremap <C-h> <C-w>h
" nnoremap <C-j> <C-w>j
" nnoremap <C-k> <C-w>k
" nnoremap <C-l> <C-w>l
" Check file in shellcheck:
map <leader>s :!clear && shellcheck %<CR>
" Replace all is aliased to S.
nnoremap S :%s//g<Left><Left>
" Ensure files are read as what I want:
let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
let g:vimwiki_list = [{'path': '~/vimwiki', 'syntax': 'markdown', 'ext': '.md'}]
autocmd BufRead,BufNewFile *.ms,*.me,*.mom,*.man set filetype=groff
autocmd BufRead,BufNewFile *.tex set filetype=tex
" Automatically deletes all trailing whitespace on save.
autocmd BufWritePre * %s/\s\+$//e
" Rebind $ to <leader>d
nnoremap <leader>d $
" Navigating with guides
inoremap <leader><leader> <Esc>/<++><Enter>"_c4l
vnoremap <leader><leader> <Esc>/<++><Enter>"_c4l
map <leader><leader> <Esc>/<++><Enter>"_c4l
" Remember last cursor position
autocmd BufReadPost * if @% !~# '\.git[\/\\]COMMIT_EDITMSG$' && line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" Update CHANGELOG message
inoremap <leader>C Update CHANGELOG<esc>:wq<cr>
"""HTML
autocmd FileType html inoremap <leader>b <b></b><Space><++><Esc>FbT>i
autocmd FileType html inoremap <leader>it <em></em><Space><++><Esc>FeT>i
autocmd FileType html inoremap <leader>1 <h1></h1><Enter><Enter><++><Esc>2kf<i
autocmd FileType html inoremap <leader>2 <h2></h2><Enter><Enter><++><Esc>2kf<i
autocmd FileType html inoremap <leader>3 <h3></h3><Enter><Enter><++><Esc>2kf<i
autocmd FileType html inoremap <leader>p <p></p><Enter><Enter><++><Esc>02kf>a
autocmd FileType html inoremap <leader>a <a<Space>href=""><++></a><Space><++><Esc>14hi
autocmd FileType html inoremap <leader>e <a<Space>target="_blank"<Space>href=""><++></a><Space><++><Esc>14hi
autocmd FileType html inoremap <leader>ul <ul><Enter><li></li><Enter></ul><Enter><Enter><++><Esc>03kf<i
autocmd FileType html inoremap <leader>li <Esc>o<li></li><Esc>F>a
autocmd FileType html inoremap <leader>ol <ol><Enter><li></li><Enter></ol><Enter><Enter><++><Esc>03kf<i
autocmd FileType html inoremap <leader>im <img src="" alt="<++>"><++><esc>Fcf"a
autocmd FileType html inoremap <leader>td <td></td><++><Esc>Fdcit
autocmd FileType html inoremap <leader>tr <tr></tr><Enter><++><Esc>kf<i
autocmd FileType html inoremap <leader>th <th></th><++><Esc>Fhcit
autocmd FileType html inoremap <leader>tab <table><Enter></table><Esc>O
autocmd FileType html inoremap <leader>gr <font color="green"></font><Esc>F>a
autocmd FileType html inoremap <leader>rd <font color="red"></font><Esc>F>a
autocmd FileType html inoremap <leader>yl <font color="yellow"></font><Esc>F>a
autocmd FileType html inoremap <leader>dt <dt></dt><Enter><dd><++></dd><Enter><++><esc>2kcit
autocmd FileType html inoremap <leader>dl <dl><Enter><Enter></dl><enter><enter><++><esc>3kcc
autocmd FileType html inoremap &<space> &amp;<space>
autocmd FileType html inoremap á &aacute;
autocmd FileType html inoremap é &eacute;
autocmd FileType html inoremap í &iacute;
autocmd FileType html inoremap ó &oacute;
autocmd FileType html inoremap ú &uacute;
autocmd FileType html inoremap ä &auml;
autocmd FileType html inoremap ë &euml;
autocmd FileType html inoremap ï &iuml;
autocmd FileType html inoremap ö &ouml;
autocmd FileType html inoremap ü &uuml;
autocmd FileType html inoremap ã &atilde;
autocmd FileType html inoremap &etilde;
autocmd FileType html inoremap ĩ &itilde;
autocmd FileType html inoremap õ &otilde;
autocmd FileType html inoremap ũ &utilde;
autocmd FileType html inoremap ñ &ntilde;
autocmd FileType html inoremap à &agrave;
autocmd FileType html inoremap è &egrave;
autocmd FileType html inoremap ì &igrave;
autocmd FileType html inoremap ò &ograve;
autocmd FileType html inoremap ù &ugrave;
""MARKDOWN
" autocmd Filetype markdown,rmd map <leader>w yiWi[<esc>Ea](<esc>pa)
" autocmd Filetype markdown,rmd inoremap <leader>n ---<Enter><Enter>
" autocmd Filetype markdown,rmd inoremap <leader>b ****<++><Esc>F*hi
" autocmd Filetype markdown,rmd inoremap <leader>s ~~~~<++><Esc>F~hi
" autocmd Filetype markdown,rmd inoremap <leader>e **<++><Esc>F*i
" autocmd Filetype markdown,rmd inoremap <leader>h ====<Space><++><Esc>F=hi
" autocmd Filetype markdown,rmd inoremap <leader>i ![](<++>)<++><Esc>F[a
" autocmd Filetype markdown,rmd inoremap <leader>a [](<++>)<++><Esc>F[a
" autocmd Filetype markdown,rmd inoremap <leader>1 #<Space><Enter><++><Esc>kA
" autocmd Filetype markdown,rmd inoremap <leader>2 ##<Space><Enter><++><Esc>kA
" autocmd Filetype markdown,rmd inoremap <leader>3 ###<Space><Enter><++><Esc>kA
" autocmd Filetype markdown,rmd inoremap <leader>l --------<Enter>
" autocmd Filetype rmd inoremap <leader>r ```{r}<CR>```<CR><CR><esc>2kO
" autocmd Filetype rmd inoremap <leader>p ```{python}<CR>```<CR><CR><esc>2kO
" autocmd Filetype rmd inoremap <leader>c ```<cr>```<cr><cr><esc>2kO
""".php
autocmd FileType php inoremap <leader>f public function <Enter>{<Enter><Tab><++><Enter>}<Esc>kkk$i
autocmd FileType php inoremap <leader>t $this
autocmd FileType php inoremap <leader>u use Thirty4\Theme\Form\\<++>;<Esc>5hi
autocmd FileType php inoremap <leader>s 'url' => [ 'select', [ 'name' => '' ]],<Esc>4hi
autocmd FileType php inoremap <leader>v var_dump();<CR>die();<Esc>k$hi

+ 6
- 0
.gitignore_global View File

@ -0,0 +1,6 @@
.idea
lib/filter/base
lib/form/base
zz_release_ticket.php
ZzDummyTask.class.php
lib/task/ZzDummyTask.class.php

+ 608
- 0
.iterm2_shell_integration.bash View File

@ -0,0 +1,608 @@
#!/bin/bash
# The iTerm2 customizations fall under the following license:
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# -- BEGIN ITERM2 CUSTOMIZATIONS --
if [[ "$ITERM_ENABLE_SHELL_INTEGRATION_WITH_TMUX""$TERM" != screen && "$ITERM_SHELL_INTEGRATION_INSTALLED" = "" && "$-" == *i* && "$TERM" != linux && "$TERM" != dumb ]]; then
if shopt extdebug | grep on > /dev/null; then
echo "iTerm2 Shell Integration not installed."
echo ""
echo "Your shell has 'extdebug' turned on."
echo "This is incompatible with shell integration."
echo "Find 'shopt -s extdebug' in bash's rc scripts and remove it."
return 0
fi
ITERM_SHELL_INTEGRATION_INSTALLED=Yes
# Saved copy of your PS1. This is used to detect if the user changes PS1
# directly. ITERM_PREV_PS1 will hold the last value that this script set PS1 to
# (including various custom escape sequences).
ITERM_PREV_PS1="$PS1"
# The following chunk of code, bash-preexec.sh, is licensed like this:
# The MIT License
#
# Copyright (c) 2015 Ryan Caloras and contributors (see https://github.com/rcaloras/bash-preexec)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Wrap bash-preexec.sh in a function so that, if it exits early due to having
# been sourced elsewhere, it doesn't exit our entire script.
_install_bash_preexec () {
# -- BEGIN BASH-PREEXEC.SH --
#!/bin/bash
#
# bash-preexec.sh -- Bash support for ZSH-like 'preexec' and 'precmd' functions.
# https://github.com/rcaloras/bash-preexec
#
#
# 'preexec' functions are executed before each interactive command is
# executed, with the interactive command as its argument. The 'precmd'
# function is executed before each prompt is displayed.
#
# Author: Ryan Caloras (ryan@bashhub.com)
# Forked from Original Author: Glyph Lefkowitz
#
# V0.3.7
#
# -- END ITERM2 CUSTOMIZATIONS --
# bash-preexec.sh -- Bash support for ZSH-like 'preexec' and 'precmd' functions.
# https://github.com/rcaloras/bash-preexec
#
#
# 'preexec' functions are executed before each interactive command is
# executed, with the interactive command as its argument. The 'precmd'
# function is executed before each prompt is displayed.
#
# Author: Ryan Caloras (ryan@bashhub.com)
# Forked from Original Author: Glyph Lefkowitz
#
# V0.3.7
#
# General Usage:
#
# 1. Source this file at the end of your bash profile so as not to interfere
# with anything else that's using PROMPT_COMMAND.
#
# 2. Add any precmd or preexec functions by appending them to their arrays:
# e.g.
# precmd_functions+=(my_precmd_function)
# precmd_functions+=(some_other_precmd_function)
#
# preexec_functions+=(my_preexec_function)
#
# 3. Consider changing anything using the DEBUG trap or PROMPT_COMMAND
# to use preexec and precmd instead. Preexisting usages will be
# preserved, but doing so manually may be less surprising.
#
# Note: This module requires two Bash features which you must not otherwise be
# using: the "DEBUG" trap, and the "PROMPT_COMMAND" variable. If you override
# either of these after bash-preexec has been installed it will most likely break.
# Avoid duplicate inclusion
if [[ "${__bp_imported:-}" == "defined" ]]; then
return 0
fi
__bp_imported="defined"
# Should be available to each precmd and preexec
# functions, should they want it. $? and $_ are available as $? and $_, but
# $PIPESTATUS is available only in a copy, $BP_PIPESTATUS.
# TODO: Figure out how to restore PIPESTATUS before each precmd or preexec
# function.
__bp_last_ret_value="$?"
BP_PIPESTATUS=("${PIPESTATUS[@]}")
__bp_last_argument_prev_command="$_"
__bp_inside_precmd=0
__bp_inside_preexec=0
# Fails if any of the given variables are readonly
# Reference https://stackoverflow.com/a/4441178
__bp_require_not_readonly() {
local var
for var; do
if ! ( unset "$var" 2> /dev/null ); then
echo "iTerm2 Shell Integration:bash-preexec requires write access to ${var}" >&2
return 1
fi
done
}
# Remove ignorespace and or replace ignoreboth from HISTCONTROL
# so we can accurately invoke preexec with a command from our
# history even if it starts with a space.
__bp_adjust_histcontrol() {
local histcontrol
histcontrol="${HISTCONTROL//ignorespace}"
# Replace ignoreboth with ignoredups
if [[ "$histcontrol" == *"ignoreboth"* ]]; then
histcontrol="ignoredups:${histcontrol//ignoreboth}"
fi;
export HISTCONTROL="$histcontrol"
}
# This variable describes whether we are currently in "interactive mode";
# i.e. whether this shell has just executed a prompt and is waiting for user
# input. It documents whether the current command invoked by the trace hook is
# run interactively by the user; it's set immediately after the prompt hook,
# and unset as soon as the trace hook is run.
__bp_preexec_interactive_mode=""
__bp_trim_whitespace() {
local var=$@
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
# This function is installed as part of the PROMPT_COMMAND;
# It sets a variable to indicate that the prompt was just displayed,
# to allow the DEBUG trap to know that the next command is likely interactive.
__bp_interactive_mode() {
__bp_preexec_interactive_mode="on";
}
# This function is installed as part of the PROMPT_COMMAND.
# It will invoke any functions defined in the precmd_functions array.
__bp_precmd_invoke_cmd() {
# Save the returned value from our last command, and from each process in
# its pipeline. Note: this MUST be the first thing done in this function.
__bp_last_ret_value="$?" BP_PIPESTATUS=("${PIPESTATUS[@]}")
# Don't invoke precmds if we are inside an execution of an "original
# prompt command" by another precmd execution loop. This avoids infinite
# recursion.
if (( __bp_inside_precmd > 0 )); then
return
fi
local __bp_inside_precmd=1
# Invoke every function defined in our function array.
local precmd_function
for precmd_function in "${precmd_functions[@]}"; do
# Only execute this function if it actually exists.
# Test existence of functions with: declare -[Ff]
if type -t "$precmd_function" 1>/dev/null; then
__bp_set_ret_value "$__bp_last_ret_value" "$__bp_last_argument_prev_command"
# Quote our function invocation to prevent issues with IFS
"$precmd_function"
fi
done
}
# Sets a return value in $?. We may want to get access to the $? variable in our
# precmd functions. This is available for instance in zsh. We can simulate it in bash
# by setting the value here.
__bp_set_ret_value() {
return ${1:-}
}
__bp_in_prompt_command() {
local prompt_command_array
IFS=';' read -ra prompt_command_array <<< "$PROMPT_COMMAND"
local trimmed_arg
trimmed_arg=$(__bp_trim_whitespace "${1:-}")
local command
for command in "${prompt_command_array[@]:-}"; do
local trimmed_command
trimmed_command=$(__bp_trim_whitespace "$command")
# Only execute each function if it actually exists.
if [[ "$trimmed_command" == "$trimmed_arg" ]]; then
return 0
fi
done
return 1
}
# This function is installed as the DEBUG trap. It is invoked before each
# interactive prompt display. Its purpose is to inspect the current
# environment to attempt to detect if the current command is being invoked
# interactively, and invoke 'preexec' if so.
__bp_preexec_invoke_exec() {
# Save the contents of $_ so that it can be restored later on.
# https://stackoverflow.com/questions/40944532/bash-preserve-in-a-debug-trap#40944702
__bp_last_argument_prev_command="${1:-}"
# Don't invoke preexecs if we are inside of another preexec.
if (( __bp_inside_preexec > 0 )); then
return
fi
local __bp_inside_preexec=1
# Checks if the file descriptor is not standard out (i.e. '1')
# __bp_delay_install checks if we're in test. Needed for bats to run.
# Prevents preexec from being invoked for functions in PS1
if [[ ! -t 1 && -z "${__bp_delay_install:-}" ]]; then
return
fi
if [[ -n "${COMP_LINE:-}" ]]; then
# We're in the middle of a completer. This obviously can't be
# an interactively issued command.
return
fi
if [[ -z "${__bp_preexec_interactive_mode:-}" ]]; then
# We're doing something related to displaying the prompt. Let the
# prompt set the title instead of me.
return
else
# If we're in a subshell, then the prompt won't be re-displayed to put
# us back into interactive mode, so let's not set the variable back.
# In other words, if you have a subshell like
# (sleep 1; sleep 2)
# You want to see the 'sleep 2' as a set_command_title as well.
if [[ 0 -eq "${BASH_SUBSHELL:-}" ]]; then
__bp_preexec_interactive_mode=""
fi
fi
if __bp_in_prompt_command "${BASH_COMMAND:-}"; then
# If we're executing something inside our prompt_command then we don't
# want to call preexec. Bash prior to 3.1 can't detect this at all :/
__bp_preexec_interactive_mode=""
return
fi
local this_command
this_command=$(
export LC_ALL=C
HISTTIMEFORMAT= builtin history 1 | sed '1 s/^ *[0-9][0-9]*[* ] //'
)
# Sanity check to make sure we have something to invoke our function with.
if [[ -z "$this_command" ]]; then
return
fi
# If none of the previous checks have returned out of this function, then
# the command is in fact interactive and we should invoke the user's
# preexec functions.
# Invoke every function defined in our function array.
local preexec_function
local preexec_function_ret_value
local preexec_ret_value=0
for preexec_function in "${preexec_functions[@]:-}"; do
# Only execute each function if it actually exists.
# Test existence of function with: declare -[fF]
if type -t "$preexec_function" 1>/dev/null; then
__bp_set_ret_value ${__bp_last_ret_value:-}
# Quote our function invocation to prevent issues with IFS
"$preexec_function" "$this_command"
preexec_function_ret_value="$?"
if [[ "$preexec_function_ret_value" != 0 ]]; then
preexec_ret_value="$preexec_function_ret_value"
fi
fi
done
# Restore the last argument of the last executed command, and set the return
# value of the DEBUG trap to be the return code of the last preexec function
# to return an error.
# If `extdebug` is enabled a non-zero return value from any preexec function
# will cause the user's command not to execute.
# Run `shopt -s extdebug` to enable
__bp_set_ret_value "$preexec_ret_value" "$__bp_last_argument_prev_command"
}
__bp_install() {
# Exit if we already have this installed.
if [[ "${PROMPT_COMMAND:-}" == *"__bp_precmd_invoke_cmd"* ]]; then
return 1;
fi
trap '__bp_preexec_invoke_exec "$_"' DEBUG
# Preserve any prior DEBUG trap as a preexec function
local prior_trap=$(sed "s/[^']*'\(.*\)'[^']*/\1/" <<<"${__bp_trap_string:-}")
unset __bp_trap_string
if [[ -n "$prior_trap" ]]; then
eval '__bp_original_debug_trap() {
'"$prior_trap"'
}'
preexec_functions+=(__bp_original_debug_trap)
fi
# Adjust our HISTCONTROL Variable if needed.
__bp_adjust_histcontrol
# Issue #25. Setting debug trap for subshells causes sessions to exit for
# backgrounded subshell commands (e.g. (pwd)& ). Believe this is a bug in Bash.
#
# Disabling this by default. It can be enabled by setting this variable.
if [[ -n "${__bp_enable_subshells:-}" ]]; then
# Set so debug trap will work be invoked in subshells.
set -o functrace > /dev/null 2>&1
shopt -s extdebug > /dev/null 2>&1
fi;
# Install our hooks in PROMPT_COMMAND to allow our trap to know when we've
# actually entered something.
PROMPT_COMMAND="__bp_precmd_invoke_cmd; __bp_interactive_mode"
# Add two functions to our arrays for convenience
# of definition.
precmd_functions+=(precmd)
preexec_functions+=(preexec)
# Since this function is invoked via PROMPT_COMMAND, re-execute PC now that it's properly set
eval "$PROMPT_COMMAND"
}
# Sets our trap and __bp_install as part of our PROMPT_COMMAND to install
# after our session has started. This allows bash-preexec to be included
# at any point in our bash profile. Ideally we could set our trap inside
# __bp_install, but if a trap already exists it'll only set locally to
# the function.
__bp_install_after_session_init() {
# Make sure this is bash that's running this and return otherwise.
if [[ -z "${BASH_VERSION:-}" ]]; then
return 1;
fi
# bash-preexec needs to modify these variables in order to work correctly
# if it can't, just stop the installation
__bp_require_not_readonly PROMPT_COMMAND HISTCONTROL HISTTIMEFORMAT || return
# If there's an existing PROMPT_COMMAND capture it and convert it into a function
# So it is preserved and invoked during precmd.
if [[ -n "$PROMPT_COMMAND" ]]; then
eval '__bp_original_prompt_command() {
'"$PROMPT_COMMAND"'
}'
precmd_functions+=(__bp_original_prompt_command)
fi
# Installation is finalized in PROMPT_COMMAND, which allows us to override the DEBUG
# trap. __bp_install sets PROMPT_COMMAND to its final value, so these are only
# invoked once.
# It's necessary to clear any existing DEBUG trap in order to set it from the install function.
# Using \n as it's the most universal delimiter of bash commands
PROMPT_COMMAND=$'\n__bp_trap_string="$(trap -p DEBUG)"\ntrap DEBUG\n__bp_install\n'
}
# Run our install so long as we're not delaying it.
if [[ -z "$__bp_delay_install" ]]; then
__bp_install_after_session_init
fi;
# -- END BASH-PREEXEC.SH --
}
_install_bash_preexec
unset -f _install_bash_preexec
# -- BEGIN ITERM2 CUSTOMIZATIONS --
# We don't care about whitespace, but users care about not changing their histcontrol variables.
# We overwrite the upstream __bp_adjust_histcontrol function whcih gets called from the next
# PROMPT_COMMAND invocation.
function __bp_adjust_histcontrol() {
true
}
function iterm2_begin_osc {
printf "\033]"
}
function iterm2_end_osc {
printf "\007"
}
function iterm2_print_state_data() {
iterm2_begin_osc
printf "1337;RemoteHost=%s@%s" "$USER" "$iterm2_hostname"
iterm2_end_osc
iterm2_begin_osc
printf "1337;CurrentDir=%s" "$PWD"
iterm2_end_osc
iterm2_print_user_vars
}
# Usage: iterm2_set_user_var key value
function iterm2_set_user_var() {
iterm2_begin_osc
printf "1337;SetUserVar=%s=%s" "$1" $(printf "%s" "$2" | base64 | tr -d '\n')
iterm2_end_osc
}
if [ -z "$(type -t iterm2_print_user_vars)" ] || [ "$(type -t iterm2_print_user_vars)" != function ]; then
# iterm2_print_user_vars is not already defined. Provide a no-op default version.
#
# Users can write their own version of this function. It should call
# iterm2_set_user_var but not produce any other output.
function iterm2_print_user_vars() {
true
}
fi
function iterm2_prompt_prefix() {
iterm2_begin_osc
printf "133;D;\$?"
iterm2_end_osc
}
function iterm2_prompt_mark() {
iterm2_begin_osc
printf "133;A"
iterm2_end_osc
}
function iterm2_prompt_suffix() {
iterm2_begin_osc
printf "133;B"
iterm2_end_osc
}
function iterm2_print_version_number() {
iterm2_begin_osc
printf "1337;ShellIntegrationVersion=14;shell=bash"
iterm2_end_osc
}
# If hostname -f is slow on your system, set iterm2_hostname before sourcing this script.
if [ -z "${iterm2_hostname:-}" ]; then
iterm2_hostname=$(hostname -f 2>/dev/null)
# some flavors of BSD (i.e. NetBSD and OpenBSD) don't have the -f option
if [ $? -ne 0 ]; then
iterm2_hostname=$(hostname)
fi
fi
# Runs after interactively edited command but before execution
__iterm2_preexec() {
# Save the returned value from our last command
__iterm2_last_ret_value="$?"
iterm2_begin_osc
printf "133;C;"
iterm2_end_osc
# If PS1 still has the value we set it to in iterm2_preexec_invoke_cmd then
# restore it to its original value. It might have changed if you have
# another PROMPT_COMMAND (like liquidprompt) that modifies PS1.
if [ -n "${ITERM_ORIG_PS1+xxx}" -a "$PS1" = "$ITERM_PREV_PS1" ]
then
export PS1="$ITERM_ORIG_PS1"
fi
iterm2_ran_preexec="yes"
__bp_set_ret_value "$__iterm2_last_ret_value" "$__bp_last_argument_prev_command"
}
function __iterm2_precmd () {
__iterm2_last_ret_value="$?"
# Work around a bug in CentOS 7.2 where preexec doesn't run if you press
# ^C while entering a command.
if [[ -z "${iterm2_ran_preexec:-}" ]]
then
__iterm2_preexec ""
fi
iterm2_ran_preexec=""
# This is an iTerm2 addition to try to work around a problem in the
# original preexec.bash.
# When the PS1 has command substitutions, this gets invoked for each
# substitution and each command that's run within the substitution, which
# really adds up. It would be great if we could do something like this at
# the end of this script:
# PS1="$(iterm2_prompt_prefix)$PS1($iterm2_prompt_suffix)"
# and have iterm2_prompt_prefix set a global variable that tells precmd not to
# output anything and have iterm2_prompt_suffix reset that variable.
# Unfortunately, command substitutions run in subshells and can't
# communicate to the outside world.
# Instead, we have this workaround. We save the original value of PS1 in
# $ITERM_ORIG_PS1. Then each time this function is run (it's called from
# PROMPT_COMMAND just before the prompt is shown) it will change PS1 to a
# string without any command substitutions by doing eval on ITERM_ORIG_PS1. At
# this point ITERM_PREEXEC_INTERACTIVE_MODE is still the empty string, so preexec
# won't produce output for command substitutions.
# The first time this is called ITERM_ORIG_PS1 is unset. This tests if the variable
# is undefined (not just empty) and initializes it. We can't initialize this at the
# top of the script because it breaks with liquidprompt. liquidprompt wants to
# set PS1 from a PROMPT_COMMAND that runs just before us. Setting ITERM_ORIG_PS1
# at the top of the script will overwrite liquidprompt's PS1, whose value would
# never make it into ITERM_ORIG_PS1. Issue 4532. It's important to check
# if it's undefined before checking if it's empty because some users have
# bash set to error out on referencing an undefined variable.
if [ -z "${ITERM_ORIG_PS1+xxx}" ]
then
# ITERM_ORIG_PS1 always holds the last user-set value of PS1.
# You only get here on the first time iterm2_preexec_invoke_cmd is called.
export ITERM_ORIG_PS1="$PS1"
fi
# If you want to generate PS1 dynamically from PROMPT_COMMAND, the best way
# to do it is to define a function named iterm2_generate_ps1 that sets PS1.
# Issue 5964. Other shells don't have this issue because they don't need
# such extremes to get precmd and preexec.
if [ -n "$(type -t iterm2_generate_ps1)" ] && [ "$(type -t iterm2_generate_ps1)" = function ]; then
iterm2_generate_ps1
fi
if [[ "$PS1" != "$ITERM_PREV_PS1" ]]
then
export ITERM_ORIG_PS1="$PS1"
fi
# Get the value of the prompt prefix, which will change $?
\local iterm2_prompt_prefix_value="$(iterm2_prompt_prefix)"
# Add the mark unless the prompt includes '$(iterm2_prompt_mark)' as a substring.
if [[ $ITERM_ORIG_PS1 != *'$(iterm2_prompt_mark)'* && x$ITERM2_SQUELCH_MARK = x ]]
then
iterm2_prompt_prefix_value="$iterm2_prompt_prefix_value$(iterm2_prompt_mark)"
fi
# Send escape sequences with current directory and hostname.
iterm2_print_state_data
# Reset $? to its saved value, which might be used in $ITERM_ORIG_PS1.
__bp_set_ret_value "$__iterm2_last_ret_value" "$__bp_last_argument_prev_command"
# Set PS1 to various escape sequences, the user's preferred prompt, and more escape sequences.
export PS1="\[$iterm2_prompt_prefix_value\]$ITERM_ORIG_PS1\[$(iterm2_prompt_suffix)\]"
# Save the value we just set PS1 to so if the user changes PS1 we'll know and we can update ITERM_ORIG_PS1.
export ITERM_PREV_PS1="$PS1"
__bp_set_ret_value "$__iterm2_last_ret_value" "$__bp_last_argument_prev_command"
}
# Install my functions
preexec_functions+=(__iterm2_preexec)
precmd_functions+=(__iterm2_precmd)
iterm2_print_state_data
iterm2_print_version_number
fi
# -- END ITERM2 CUSTOMIZATIONS --

+ 5
- 0
.local/bin/c View File

@ -0,0 +1,5 @@
#!/bin/bash
F=$(fzf)
[ -z "$F" ] || nvim "$F"

+ 98
- 0
.local/bin/dmenu-bangs View File

@ -0,0 +1,98 @@
#!/usr/bin/env bash
# author: unknown
# sentby: MoreChannelNoise (https://www.youtube.com/user/MoreChannelNoise)
# editby: gotbletu (https://www.youtube.com/user/gotbletu)
# demo: https://www.youtube.com/watch?v=kxJClZIXSnM
# info: this is a script to launch other rofi scripts,
# saves us the trouble of binding multiple hotkeys for each script,
# when we can just use one hotkey for everything.
declare -A LABELS
declare -A COMMANDS
###
# List of defined 'bangs'
# launch programs
COMMANDS["apps"]="dmenu_run -i -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee'"
LABELS["apps"]=""
# clipboard
COMMANDS["clipboard"]="greenclip print | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'clipboard: ' | xclip -selection clipboard"
LABELS["clipboard"]=""
# search local files
COMMANDS["emoji"]="~/.local/bin/dmenu-scripts/dmenu-emoji"
LABELS["emoji"]=""
# mount drives
COMMANDS["mount"]="sudo ~/.local/bin/dmenu-scripts/dmenu-mount"
LABELS["mount"]=""
# umount drives
COMMANDS["unmount"]="sudo ~/.local/bin/dmenu-scripts/dmenu-mount unmount"
LABELS["unmount"]=""
# shutdown
COMMANDS["shutdown"]="sudo ~/.local/bin/dmenu-scripts/dmenu-shutdown"
LABELS["shutdown"]=""
# PDF man pages
COMMANDS["man"]="~/.local/bin/dmenu-scripts/dmenu-man"
LABELS["man"]=""
# locate files
COMMANDS["locate"]="~/.local/bin/dmenu-scripts/dmenu-locate"
LABELS["locate"]=""
################################################################################
# do not edit below
################################################################################
##
# Generate menu
##
function print_menu()
{
for key in ${!LABELS[@]}
do
echo "$key ${LABELS}"
# echo "$key ${LABELS[$key]}"
# my top version just shows the first field in labels row, not two words side by side
done
}
##
# Show rofi.
##
function start()
{
print_menu | sort | dmenu -i -m 0 -fn "Inconsolata:size=10" -nb "#222222" -nf "#bbbbbb" -sb "#005577" -sf "#eeeeee" -p "dmenu bangs: "
}
# Run it
value="$(start)"
# Split input.
# grab upto first space.
choice=${value%%\ *}
# graph remainder, minus space.
input=${value:$((${#choice}+1))}
##
# Cancelled? bail out
##
if test -z ${choice}
then
exit
fi
# check if choice exists
if test ${COMMANDS[$choice]+isset}
then
# Execute the choice
eval ${COMMANDS[$choice]}
else
eval $choice | dmenu
fi

+ 15
- 0
.local/bin/dmenu-scripts/dmenu-emoji View File

@ -0,0 +1,15 @@
#!/bin/bash
#cat ~/.emoji | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Emoji: '
chosen=$(grep -v "#" ~/.emoji | dmenu -i -l 20 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'emoji: ')
[ "$chosen" != "" ] || exit
c=$(echo "$chosen" | sed "s/ .*//")
echo "$c" | tr -d '\n' | xclip -selection clipboard
notify-send "'$c' copied to clipboard." &
s=$(echo "$chosen" | sed "s/.*; //" | awk '{print $1}')
echo "$s" | tr -d '\n' | xclip
notify-send "'$s' copied to primary." &

+ 3
- 0
.local/bin/dmenu-scripts/dmenu-locate View File

@ -0,0 +1,3 @@
#!/bin/bash
xdg-open $(locate home media | dmenu -l 20 -i -m 0 -fn "Inconsolata:size=10" -nb "#000000" -nf "#bbbbbb" -sb "#0099cc" -sf "#000000" -p "Locate: ")

+ 3
- 0
.local/bin/dmenu-scripts/dmenu-man View File

@ -0,0 +1,3 @@
#!/bin/bash
man -k . | dmenu -i -m 0 -fn "Inconsolata:size=10" -nb "#000000" -nf "#bbbbbb" -sb "#0099cc" -sf "#000000" -l 20 -p "Man: " | awk '{print $1}' | xargs -r man -Tpdf | zathura -

+ 28
- 0
.local/bin/dmenu-scripts/dmenu-mount View File

@ -0,0 +1,28 @@
#!/bin/bash
COLS="name,type,size,mountpoint"
if [[ "$1" == "unmount" ]]
then
drives="$(lsblk -rpo "$COLS" | awk '$2=="part"&&$4!=""{printf "%s (%s)\n",$1,$3}')"
[ -z "$drives" ] && exit 1
chosen="$(echo "$drives" | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Drive to unmount: ' | awk '{print $1}')"
[ -z "$chosen" ] && exit 1
umount $chosen && notify-send "$chosen umounted" || notfiy-send "Error unmounting $chosen"
else
drives="$(lsblk -rpo "$COLS" | awk '$2=="part"&&$4==""{printf "%s (%s)\n",$1,$3}')"
[ -z "$drives" ] && exit 1
chosen="$(echo "$drives" | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Drive to mount: ' | awk '{print $1}')"
[ -z "$chosen" ] && exit 1
mount "$chosen" && exit 0
mp="$(find /mnt /media /mount /home -type d -maxdepth 1 2>/dev/null | dmenu -i -l 10 -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Mount point: ' | awk '{print $1}')"
[ "$mp" = "" ] && exit 1
if [ ! -d "$mp" ]; then
mkdiryn=$(printf "No\\nYes" | dmenu -i -m 0 -fn 'Inconsolata:size=10' -nb '#222222' -nf '#bbbbbb' -sb '#005577' -sf '#eeeeee' -p 'Mount point does not exist, create it?')
[ "$mkdiryn" = "Yes" ] && sudo -A mkdir -p "$mp"
fi
echo $mp
mount "$chosen" "$mp" && notify-send "$chosen mounted to $mp." || notify-send "Error mounting $chosen to $mp"
fi

+ 24
- 0
.local/bin/dmenu-scripts/dmenu-shutdown View File

@ -0,0 +1,24 @@
#!/bin/bash
option=$(echo -e "Lock the screen\nReboot\nShutdown\nHibernate" | dmenu -i -m 0 -fn "Inconsolata:size=10" -nb "#000000" -nf "#bbbbbb" -sb "#0099cc" -sf "#000000" -p "Power menu: ")
answer=$(echo -e "No\nYes" | dmenu -i -m 0 -fn "Inconsolata:size=10" -nb "#000000" -nf "#bbbbbb" -sb "#0099cc" -sf "#000000" -p "Would you like to ${option} now? ")
if [[ ${answer} == "Yes" ]]
then
if [[ ${option} == "Lock the screen" ]]
then
slock
elif [[ ${option} == "Reboot" ]]
then
systemctl reboot
elif [[ ${option} == "Shutdown" ]]
then
systemctl poweroff
elif [[ ${option} == "Hibernate" ]]
then
systemctl hibernate
fi
fi

+ 12
- 0
.local/bin/new-repo View File

@ -0,0 +1,12 @@
#!/bin/sh
read -p "Enter the name/url for repo: " url
read -p "Enter the description for repo:" desc
url_parsed=${url// /_}
url_path="/var/www/git/${url_parsed}.git"
ssh git@tovijaeschke.xyz "mkdir -p ${url_path} && git init --bare ${url_path} && echo -e \"\nrepo.url=${url_parsed}\nrepo.path=${url_path}\nrepo.desc=${desc}\n\" >> /etc/cgitrepos"
git remote add origin git@git.tovijaeschke.xyz:${url_path}

+ 9
- 0
.local/bin/nt View File

@ -0,0 +1,9 @@
#!/bin/bash
F=$(ls ~/notes/ | fzf)
if [ ${F: -4} == ".enc" ]; then
fenc -e $(realpath ~/notes/${F})
else
nvim $(realpath ~/notes/${F})
fi

+ 10
- 0
.local/bin/pentest/bytetoword View File

@ -0,0 +1,10 @@
#!/usr/bin/python3
import sys
def a(one):
if one[:2] == "0x":
one = one[2:]
print(bytearray.fromhex(one).decode())
a(sys.argv[1])

+ 163
- 0
.local/bin/pentest/leak-lookup View File

@ -0,0 +1,163 @@
#!/usr/bin/env python3
class Colours:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
try:
import os
import re
import sys
import getopt
import requests
from clint.textui import progress
from bs4 import BeautifulSoup
except Exception as err:
print(Colours.FAIL + "Error: {}".format(err) + Colours.ENDC)
def Usage():
use_msg = '''
---------- Usage ----------
leak-lookup [options] [search term]
---------------------------
Options:
-h: Prints this help message
-p: Searches haveibeenpwned.com
-d: Searches for leaked database
---------------------------
'''
print(use_msg)
def DownloadDatabase(url, name):
try:
r = requests.get(url, stream=True)
with open(name, 'wb') as f:
total_length = int(r.headers.get('content-length'))
for chunk in progress.bar(r.iter_content(chunk_size=1024), expected_size=(total_length/1024) + 1):
if chunk:
f.write(chunk)
f.flush()
except (KeyboardInterrupt, SystemExit, EOFError):
print(Colours.FAIL + "An error occurred, cleaning up" + Colours.ENDC)
os.remove(name)
def DatabaseQuery(database):
r = requests.get("https://www.databases.today/search-nojs.php?for=" + database)
if r.reason != "OK":
print(Colours.FAIL + "Error code: {}".format(r.status_code) + Colours.ENDC)
sys.exit(1)
soup = BeautifulSoup(r.text, "html.parser")
dbs = soup.find(id="myTable").find_all("tr")
entries = []
for table in dbs:
entry = table.find_all("td")
if len(entry) != 0:
entries.append([entry[0].text, entry[4].a.get("href")])
print("Which file would you like to download?")
for index, dllink in enumerate(entries):
print("{}) {}".format(index + 1, dllink[0]))
print("a) All")
print("q) Quit")
download_choice = input(">> ")
if download_choice == "q":
sys.exit(0)
elif download_choice == "a":
for x in dllink:
DownloadDatabase(x[1], x[0])
else:
try:
download_choice = int(download_choice) - 1
DownloadDatabase(dllink[1], dllink[0].split(" (")[0])
except:
print(Colours.FAIL + "Error: Invalid selection" + Colours.ENDC)
sys.exit(1)
def QueryHaveIBeenPwned(email):
r = requests.post("https://haveibeenpwned.com/", data={"Account": email})
if r.reason != "OK":
print(Colours.FAIL + "Error code: {}".format(r.status_code) + Colours.ENDC)
sys.exit(1)
soup = BeautifulSoup(r.text, "html.parser")
pwnCount = re.match("Pwned on \d+", soup.find(id="pwnCount").text)
if pwnCount == None:
print(Colours.OKGREEN + "{} has no public leaks".format(email) + Colours.ENDC)
return
print(Colours.FAIL + "{} has {} public leaks avalible".format(email, pwnCount.group().split(" ")[-1]) + Colours.ENDC)
leaks = []
for leak in soup.find_all(class_="pwnedWebsite"):
leak_name = None
leak_status = None
compromised_data = None
leak_name_html = leak.find(class_="pwnedCompanyTitle")
if leak_name_html:
if "(" in leak_name_html.text:
leak_name = leak_name_html.text.split(" (")[0]
leak_status = leak_name_html.text.split(" (")[1][:-2]
else:
leak_name = leak_name_html.text[:-1]
leak_status = None
compromised_data_html = leak.find(class_="dataClasses")
if compromised_data_html:
compromised_data = compromised_data_html.text
if leak_name:
leaks.append([leak_name, leak_status, compromised_data])
print("\nDownload databases:")
for index, leak in enumerate(leaks):
if leak[1] == None:
print("{}) {}: {}".format(index + 1, leak[0], leak[2]))
else:
print("{}) {} ({}): {}".format(index + 1, leak[0], leak[1], leak[2]))
print("a) Download all")
print("q) Quit")
download_choice = input(">> ")
if download_choice == "q":
sys.exit(0)
elif download_choice == "a":
for leak in leaks:
DatabaseQuery(leak[0])
try:
download_choice = int(download_choice) - 1
DatabaseQuery(leaks[download_choice][0])
except:
print(Colours.FAIL + "Error: Invalid selection" + Colours.ENDC)
sys.exit(1)
def main():
if len(sys.argv[1:]) == 0:
Usage()
sys.exit(1)
try:
options, remainder = getopt.getopt(sys.argv[1:],'hpd',['h', 'p','d',])
except getopt.GetoptError as err:
print(Colours.FAIL + "Error: {}".format(err) + Colours.ENDC)
sys.exit(1)
for opt, arg in options:
if opt == "-h":
Usage()
sys.exit(0)
elif opt == "-p":
if len(remainder) == 0:
Usage()
sys.exit(1)
QueryHaveIBeenPwned(" ".join(remainder))
elif opt == "-d":
if len(remainder) == 0:
Usage()
sys.exit(1)
DatabaseQuery(" ".join(remainder))
if __name__ == "__main__":
try:
main()
except (KeyboardInterrupt, SystemExit, EOFError):
sys.exit(0)

+ 7
- 0
.local/bin/shellcode-gen View File

@ -0,0 +1,7 @@
#!/bin/bash
for i in $(objdump -d $1 | tr '\t' ' ' | tr ' ' '\n' | egrep '^[0-9a-f]{2}$' )
do
echo -n "\x$i"
done
echo -e "\n"

+ 26
- 0
.local/bin/vg View File

@ -0,0 +1,26 @@
#!/bin/sh
VAGRANT=`which vagrant`
### User vagrant global-status to get the global ID
GLOBAL_ID='e2d06a8'
GLOBAL_DIR='/opt/vhosts/tools-deployment'
CWD=`pwd`
pushd $GLOBAL_DIR
if [[ $1 == "up" ]]
then
$VAGRANT up $GLOBAL_ID
ntfy -l INFO -t 'VAGRANT' send 'VM has finished booting'
elif [[ $1 == "halt" ]]
then
$VAGRANT halt $GLOBAL_ID
ntfy -l INFO -t 'VAGRANT' send 'VM has halted'
elif [[ $1 == "sup" ]]
then
$VAGRANT up $GLOBAL_ID
ntfy -l INFO -t 'VAGRANT' send 'VM has started, ssh-ing into it'
echo 'Shelling into machine...'
$VAGRANT ssh
else
$VAGRANT "$@"
fi
popd

+ 28
- 0
.local/bin/workflow/cabl View File

@ -0,0 +1,28 @@
#!/bin/bash
# Dependencies are xclip and xorg-xprop.
# qrencode required for qrcode generation.
# groff/zathura required for man pages.
prim="$(xclip -o)"; [ -z "$prim" ] && exit
PID=$(xprop -id "$(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')" | grep -m 1 PID | cut -d " " -f 3)
PID=$(echo "$(pstree -lpA "$PID" | tail -n 1)" | awk -F'---' '{print $NF}' | sed -re 's/[^0-9]//g')
cd "$(readlink /proc/"$PID"/cwd)"
[[ "${prim}" == *"~"* ]] && prim=$(echo "~/go/src/gitlab.com/tovijaeschke/website" | sed 's@~@'"$HOME"'@g')
[ -f "$prim" ] && xdg-open "$prim" && exit
[ -d "$prim" ] && st -c "$prim" && exit
websearch() { "$BROWSER" "https://duckduckgo.com/?q=$@" ;}
wikipedia() { "$BROWSER" "https://en.wikipedia.org/wiki/$@" ;}
wiktionary() { "$BROWSER" "https://en.wiktionary.org/wiki/$@" ;}
piratebay() { "$BROWSER" "https://piratebays.fi/s/?q=$@" ;}
maps() { "$BROWSER" "https://www.openstreetmap.org/search?query=$@" ;}
ebay() { "$BROWSER" "https://www.ebay.com/sch/$@" ;}
echo "$prim" | grep "^.*\.[A-Za-z]\+.*" >/dev/null && gotourl() { "$BROWSER" "$@" ;}
echo "$prim" | grep "^.*@.*\.[A-Za-z]\+$" >/dev/null && email() { xdg-email "$@" ;}
command -v qrencode >/dev/null && qrcode() { qrencode "$@" -s 10 -o /tmp/qr.png && xdg-open /tmp/qr.png ;}
man -k "^$prim$" >/dev/null && manual() { man -Tpdf "$prim" | zathura - ;}
func="$(declare -F | awk '{print $3}' | dmenu -p "Plumb $prim to?" -i -l 15)"
[ -z "$func" ] || "$func" "$prim"

+ 4
- 0
.local/bin/workflow/change_wp View File

@ -0,0 +1,4 @@
#!/bin/bash
notify-send "Changing wallpaper"
feh --bg-fill ~/pix/cyberpunk/$(ls ~/pix/cyberpunk | shuf -n 1)

+ 8
- 0
.local/bin/workflow/compile View File

@ -0,0 +1,8 @@
#!/bin/bash
case "$1" in
*.asm) nasm -f elf64 "$1" && ld "${1%.*}".o -o "${1%.*}"; rm "${1%.*}".o ;;
*.c) gcc "$1" -o "${1%.*}" ;;
*.go) go build "$1" ;;
Makefile) make ;;
esac

+ 9
- 0
.local/bin/workflow/extern_monitor View File

@ -0,0 +1,9 @@
#!/bin/bash
intern=LVDS-1
extern=VGA-1
if xrandr | grep "$extern connected"; then
xrandr --output ${extern} --auto --right-of ${intern}
else
xrandr --output ${extern} --off --output ${intern} --auto
fi

+ 25
- 0
.local/bin/workflow/extract View File

@ -0,0 +1,25 @@
#!/bin/bash
if [ -f $1 ] ; then
# NAME=${1%.*}
# mkdir $NAME && cd $NAME
case $1 in
*.tar.bz2) tar xvjf ../$1 ;;
*.tar.gz) tar xvzf ../$1 ;;
*.tar.xz) tar xvJf ../$1 ;;
*.lzma) unlzma ../$1 ;;
*.bz2) bunzip2 ../$1 ;;
*.rar) unrar x -ad ../$1 ;;
*.gz) gunzip ../$1 ;;
*.tar) tar xvf ../$1 ;;
*.tbz2) tar xvjf ../$1 ;;
*.tgz) tar xvzf ../$1 ;;
*.zip) unzip ../$1 ;;
*.Z) uncompress ../$1 ;;
*.7z) 7z x ../$1 ;;
*.xz) unxz ../$1 ;;
*.exe) cabextract ../$1 ;;
*) echo "extract: '$1' - unknown archive method" ;;
esac
else
echo "$1 - file does not exist"
fi

BIN
.local/bin/workflow/greenclip View File


+ 10
- 0
.local/bin/workflow/lock_toggle View File

@ -0,0 +1,10 @@
#!/bin/bash
if [ $(pgrep xautolock) ]
then
killall xautolock
notify-send "🔓 Turning off xautolock"
else
xautolock -time 10 -locker slock &
notify-send "🔒 Turning on xautolock"
fi

+ 4
- 0
.local/bin/workflow/voldown View File

@ -0,0 +1,4 @@
#!/bin/bash
pactl set-sink-volume @DEFAULT_SINK@ -5%
vol=$(amixer sget Master | grep 'Right:' | awk -F'[][]' '{ print $2 }')
notify-send -t 500 "Volume: ${vol}"

+ 4
- 0
.local/bin/workflow/volup View File

@ -0,0 +1,4 @@
#!/bin/bash
pactl set-sink-volume @DEFAULT_SINK@ +5%
vol=$(amixer sget Master | grep 'Right:' | awk -F'[][]' '{ print $2 }')
notify-send -t 500 "Volume: ${vol}"

+ 14
- 0
.local/bin/workflow/vpn View File

@ -0,0 +1,14 @@
#!/bin/bash
listandReturn() {
printf "Listing contents of %s.\\n" "$1"
ls -rc "$1" | awk -F '/' '{print $NF}' | nl
read -erp "Pick an entry by number to $2, or press ctrl-c to cancel. " number
chosen="$(ls -rc "$1" | nl | grep -w "$number" | awk '{print $2}')"
basefile="$(basename "$chosen")" && base="${basefile%.*}"
}
listandReturn ~/.openvpn/UDP\ 1194\ Normal/
sudo openvpn --config ~/.openvpn/UDP\ 1194\ Normal/${basefile}

Loading…
Cancel
Save