From 55bbc4f1531ca13129539f8cc386d1c7d369bd03 Mon Sep 17 00:00:00 2001 From: g0tmi1k Date: Mon, 7 Nov 2016 12:24:58 +0000 Subject: [PATCH] Code cleanup - adds comments & formatting --- searchsploit | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/searchsploit b/searchsploit index 362cb74b7..1993feb29 100755 --- a/searchsploit +++ b/searchsploit @@ -1,6 +1,6 @@ #!/bin/bash # Name: SearchSploit - Exploit-DB's CLI search tool -# Version: 3.7 (Release date: 2016-10-26) +# Version: 3.7.1 (Release date: 2016-11-07) # Written by: Offensive Security, Unix-Ninja & g0tmi1k # Homepage: https://github.com/offensive-security/exploit-database # @@ -306,7 +306,7 @@ function nmapxml() #searchsploitout echo "${software}" >> /tmp/searchsploitout - ## Read in from file (so there isn't any duplicates but unable to print out IPs) + ## Read in from file (so there are no duplicates - ...but unable to print out IPs) cat /tmp/searchsploitout | tr '[:upper:]' '[:lower:]' | awk '!x[$0]++' | while read software; do searchsploitout done @@ -448,7 +448,7 @@ if [[ "${XML}" -eq 1 ]]; then if ! hash xmllint 2>/dev/null; then echo -e '\n[!] Please install xmllint' 1>&2 - echo -e '[i] Kali Linux -> apt install -y libxml2-utils' 1>&2 + echo -e '[i] Kali Linux -> apt install -y libxml2-utils' 1>&2 exit 1 fi @@ -533,7 +533,7 @@ if [[ "${GETPATH}" -eq 1 ]]; then fi -## If we are doing an exact match, do not check folder path (Implies "-t"). +## If we are doing an exact match ("-e")? If so, do NOT check folder path (Implies "-t"). if [[ "${EXACT}" -eq 1 ]]; then FILEPATH=0 fi @@ -558,7 +558,7 @@ COL1=$(( $( tput cols ) - COL2 - 1 )) ## Remove leading space TAGS="$(echo ${TAGS} | sed -e 's/^[[:space:]]//')" -## Print header if not in JSON +## Print header if NOT in JSON ("--json") if [[ "${JSON}" -eq 0 ]]; then drawline printf "%-${COL1}s %s" " Exploit Title" @@ -596,13 +596,13 @@ else fi -## If we are not to use the path name +## If we are NOT to use the path name ("-t"/"-e") if [[ "${FILEPATH}" -eq 0 ]]; then SEARCH="${SEARCH} | awk -F '[,]' '${CASE_TAG_FGREP}(\$3) ~ /${AWK_SEARCH}/ {print}'" fi -## If we are to use colour, add the value here +## If we are to use colour ("--colour"), add the value here if [[ "${COLOUR_TAG}" ]] && [[ "${JSON}" -eq 0 ]]; then COLOUR_TAG="grep --color=always -iE \"${COLOUR_TAG}|$\"" fi @@ -617,15 +617,15 @@ fi ## Magic search Fu -## Web link format? +## Web link format ("--www")? if [[ "${WEBLINK}" -eq 1 ]]; then -## Just the EDB-ID? OUTPUT="$( eval ${SEARCH} \ | awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, "https://www.exploit-db.com/exploits/"$1"/"}' )" +## Just the EDB-ID ("--id")? elif [[ "${EDBID}" -eq 1 ]]; then -## Print JSON format (full options) OUTPUT="$( eval ${SEARCH} \ | awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, $1 }' )" +## Print JSON format (full options) ("--json")? elif [[ "${JSON}" -eq 1 ]]; then OUTPUT="$( eval ${SEARCH} \ | awk -F "\"*,\"*" '{ printf "\r\t\t'{'\"Exploit\":\"%s\",\"Path\":\"'${gitpath}/'%s\",\"EDB-ID\":%s},\n", $3, $2, $1 }' \ @@ -643,9 +643,12 @@ if [[ "${COLOUR_TAG}" ]] && [[ "${JSON}" -eq 0 ]]; then OUTPUT=$( echo -e "${OUTPUT}" | eval ${COLOUR_TAG} ) fi + +## Show content echo "${OUTPUT}" -## Print footer if not in JSON + +## Print footer if NOT in JSON ("--json") if [[ "${JSON}" -eq 0 ]]; then drawline ## Print JSON footer @@ -654,5 +657,6 @@ else echo "}" fi + ## Done exit 0