diff --git a/searchsploit b/searchsploit index 8af805c06..685c056d9 100755 --- a/searchsploit +++ b/searchsploit @@ -590,14 +590,20 @@ if [[ "${JSON}" -eq 0 ]]; then ## Print JSON header else echo "{" - echo " \"SEARCH\": \"${TAGS}\"," - echo " \"RESULTS\": [" + printf "\t\"SEARCH\": \"${TAGS}\",\n" + printf "\t\"DB_PATH\": \"${gitpath}\",\n" + printf "\t\"RESULTS\": [\n" fi -## Read in id, title and path, separated between commas (as these are the only visible fields) -SEARCH="awk -F '[,]' '{print \$1\",\"\$2\",\"\$3}' \"${csvpath}\"" - +## JSON require full options +if [[ "${JSON}" -eq 1 ]]; then + ## Read in id, title, path, type, date, plateform separated between commas + SEARCH="awk -F '[,]' '{print \$1\",\"\$2\",\"\$3\",\"\$4\",\"\$6\",\"\$7}' \"${csvpath}\"" +else + ## Read in id, title and path, separated between commas (as these are the only visible fields) + SEARCH="awk -F '[,]' '{print \$1\",\"\$2\",\"\$3}' \"${csvpath}\"" +fi ## EXACT search command ("-e")? if [[ "${EXACT}" -eq 1 ]]; then @@ -647,7 +653,7 @@ elif [[ "${EDBID}" -eq 1 ]]; then ## 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 }' \ + | awk -F ',' '{ printf "\r\t\t'{'\"Exploit\":\"%s\",\"Platform\":\"%s\",\"Type\":\"%s\",\"Date\":\"%s\",\"Path\":\"'${gitpath}/'%s\",\"EDB-ID\":%s},\n", $3, $5, $6, $4, $2, $1 }' \ | sed '$ s/,$//g' )" ## Default view else @@ -671,10 +677,10 @@ if [[ "${JSON}" -eq 0 ]]; then drawline ## Print JSON footer else - echo " ]" + printf "\t]\n" echo "}" fi ## Done -exit 0 +exit 0 \ No newline at end of file