#!/bin/sh

# A shell script to use as plugin that includes several pentesting helpers, such as:
# * Wordlists
# * Env. Variables
# * aliases

# base variables
WORDLIST_PATH="$HOME/documents/tools/lists"
PROJ_FILE=$HOME/.pentest_proj
IP_FILE=$HOME/.pentest_target

function pentest {
    echo "Pentest Shortuts Plugins"
    echo "[*] Aliases: "
    echo "    pentest     : display help for the commands and shortcuts"
    echo ""
    echo "[*] Env. Variables: "
    echo "    ROCKYOU     : $ROCKYOU"
    echo "    WLIST_DIRS  : $WLIST_DIRS"
    echo "    WLIST_FILES : $WLIST_FILES"
    echo ""
    echo "[*] Functions:"
    echo "    set_ip <ip> : set global env variable \$IP to <ip>"
    echo "    get_ip      : prints \$ip"
    echo "    set_proj    : set global env variable \$P to the current path"
    echo "    get_proj    : prints \$P"
    echo ""
    echo "[*] Set Configuration:"
    echo "    \$Target    : $IP"
    echo "    \$Proj. Path: $P"
}

function set_ip {
    if [ "$1" != "" ]; then
        echo "[*] Setting IP to $1"
        echo "$1" > $IP_FILE
        # export the scope IP as global variable
        export IP=$(cat $IP_FILE)
    fi
}

function set_proj {
    echo "[*] Setting Project Path to $(pwd)"
    echo "$(pwd)" > $PROJ_FILE
    # export the scope IP as global variable
    export P=$(cat $PROJ_FILE)
}

function get_proj {
    echo $P
}

function get_ip {
    # print the ip, for using this function
    echo $IP
}

function init {
    # autoload target IP into $IP
    if [ -f $IP_FILE ]; then
        export IP=$(cat $IP_FILE)
    fi

    # autoload project path into $P
    if [ -f $PROJ_FILE ]; then
        export P=$(cat $PROJ_FILE)
    fi
    # Wordlist bindings
    export ROCKYOU=$WORDLIST_PATH/common-wordlists/passwords/rockyou.txt
    export WLIST_DIRS=$WORDLIST_PATH/common-wordlists/web/raft-large-directories.txt
    export WLIST_FILES=$WORDLIST_PATH/common-wordlists/web/raft-large-files.txt
}


# call init() function
init