diff --git a/searchsploit b/searchsploit index 482557c4e..2ae67c98a 100755 --- a/searchsploit +++ b/searchsploit @@ -11,8 +11,8 @@ # Exit code '6' means updated from GitHub -## OS settings -gitpath="${0%/*}" +## OS settings (get the path of where the script is stored + database file) +gitpath="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" csvpath="${gitpath}/files.csv" @@ -42,7 +42,7 @@ SEARCH="" LANG=C -## If we cannot find files.csv in ${gitpath} +## If we cannot find files.csv if [[ ! -f "${csvpath}" ]]; then echo '[!] Could not find: ' ${csvpath} exit 1 @@ -363,25 +363,25 @@ fi ## Magic search Fu ## Web link format? if [[ "${WEBLINK}" -eq 1 ]]; then - OUTPUT="$(awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, "https://www.exploit-db.com/exploits/"$1"/"}' "${csvpath}" \ - | eval "${SEARCH}")" + OUTPUT="$( awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, "https://www.exploit-db.com/exploits/"$1"/"}' "${csvpath}" \ + | eval "${SEARCH}" )" ## Just the EDB-ID? elif [[ "${EDBID}" -eq 1 ]]; then - OUTPUT="$(awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, $1}' "${csvpath}" \ + OUTPUT="$( awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, $1}' "${csvpath}" \ | eval "${SEARCH}" )" ## Print JSON format (full options) elif [[ "${JSON}" -eq 1 ]]; then - OUTPUT="$(awk -F "\"*,\"*" '{ printf "\r\t\t'{'\"Exploit\":\"%s\",\"Path\":\"'${gitpath}/'%s\",\"EDB-ID\":%s},\n", $3, $2, $1}' "${csvpath}" \ + OUTPUT="$( awk -F "\"*,\"*" '{ printf "\r\t\t'{'\"Exploit\":\"%s\",\"Path\":\"'${gitpath}/'%s\",\"EDB-ID\":%s},\n", $3, $2, $1}' "${csvpath}" \ | eval "${SEARCH}" \ | sed '$ s/,$//g' )" ## Default view else - OUTPUT=$OUTPUT"$(awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, $2}' "${csvpath}" \ + OUTPUT="$( awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, $2}' "${csvpath}" \ | eval "${SEARCH}" \ | sed "s/| platforms/| ./" )" fi -echo $OUTPUT +echo "${OUTPUT}" ## Print footer if not in JSON if [[ "${JSON}" -eq 0 ]]; then