Created
February 24, 2020 21:19
-
-
Save k-o-d-r/a8ad5c38498fd97a65d9c6c5d1e1c0c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
aliases="$HOME/.bash_aliases" | |
function _say() { | |
clear; | |
echo '' | |
echo $1 | |
echo '====================================' | |
echo '' | |
} | |
# GENERIC | |
alias als="less $aliases" | |
alias als.re=". $aliases && _say 'Aliases Refreshed'" | |
alias als.edit="nano $aliases" | |
alias ll='ls -la' | |
# FIREFOX | |
function ffProxyToggle() { | |
flag=$1 | |
regex='"network\.proxy\.type", [0-1]' | |
replace="\"network.proxy.type\", $flag" | |
file="$HOME/.mozilla/firefox/ai0ajjk1.default-esr/user.js" | |
sed -i "s|$regex|$replace|g" $file | |
pkill -f firefox | |
firefox & | |
_say "Firefox Proxy Set to: $flag" | |
} | |
alias ff.proxyOn='ffProxyToggle 1' | |
alias ff.proxyOff='ffProxyToggle 0' | |
# DOCKER | |
alias docker.up="sudo service docker start && _say 'Docker Service Started'" | |
alias docker.down="sudo service docker stop && _say 'Docker Service Stopped'" | |
# BOXES | |
boxDockerNameGoat='' | |
boxDockerNameDVWA='' | |
alias box.up=boxUp | |
alias box.down=boxDown | |
function boxUp() { | |
prefix="docker run --rm -d" | |
case $1 in | |
goat) | |
boxDockerNameGoat=$(eval $"$prefix -p 8080:8080 -p 9090:9090 -e TZ=Europe/Amsterdam webgoat/goatandwolf") | |
_say "WebGoat and WebWolf started with ID: $boxDockerNameGoat. Go http://127.0.0.1:8080/WebGoat and to http://127.0.0.1:9090/WebWolf respectively" | |
docker ps | |
;; | |
dv) | |
boxDockerNameDVWA=$(eval $"$prefix -it -p 80:80 vulnerables/web-dvwa") | |
_say "Damn Vulnerable Web Applicaiton started with ID: $boxDockerNameDVWA. Go to http://127.0.0.1:80" | |
docker ps | |
connect="docker exec -it $boxDockerNameDVWA" | |
cfgFile='/var/www/html/config/config.inc.php' | |
_dvwmWriteCaptchaKey "$connect" 'recaptcha_public_key' 'PUBLIC KEY HERE' "$cfgFile" | |
_dvwmWriteCaptchaKey "$connect" 'recaptcha_private_key' 'PRIVATE KEY HERE' "$cfgFile" | |
eval "$connect sed -i 's|allow_url_include = Off|allow_url_include = On|g' /etc/php/7.0/apache2/php.ini" | |
eval $"$connect apt update" | |
eval $"$connect apt install nano" | |
;; | |
*) | |
_say "ERROR: Unknown box: $1" | |
return | |
;; | |
esac | |
} | |
function _dvwmWriteCaptchaKey() { | |
eval $"$1 sed -i \"s|'$2' \]\s*\=\s*''|'$2' \] \= '$3'|g\" $4" | |
} | |
function boxDown() { | |
targetBox='' | |
case $1 in | |
goat) | |
targetBox=$boxDockerNameGoat | |
;; | |
dv) | |
targetBox=$boxDockerNameDVWA | |
;; | |
esac | |
if [ -z "$targetBox" ] | |
then | |
_say "ERROR: Unknown box: $1" | |
return | |
fi | |
docker stop $targetBox | |
_say "Stopped box $1 ($targetBox)" | |
docker ps | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment