From 62241c3543ee2fe48cede2dd4589c9a4d9e4bd97 Mon Sep 17 00:00:00 2001 From: g0tmi1k Date: Wed, 14 Jun 2017 15:58:12 +0100 Subject: [PATCH] Code clean up --- searchsploit | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/searchsploit b/searchsploit index 491161e30..613078b9e 100755 --- a/searchsploit +++ b/searchsploit @@ -9,7 +9,7 @@ # Exit code '0' means finished normally # Exit code '1' means something went wrong # Exit code '2' means help screen -# Exit code '6' means updated exploitdb package (deb or git) +# Exit code '6' means updated exploitdb package (APT or Git) ## OS settings (get the path of where the script is stored + database file) @@ -60,16 +60,16 @@ LANG=C function usage() { echo " Usage: ${progname} [options] term1 [term2] ... [termN]" - echo + echo "" echo "==========" echo " Examples " echo "==========" echo " ${progname} afd windows local" echo " ${progname} -t oracle windows" echo " ${progname} -p 39446" - echo + echo "" echo " For more examples, see the manual: https://www.exploit-db.com/searchsploit/" - echo + echo "" echo "=========" echo " Options " echo "=========" @@ -87,7 +87,8 @@ function usage() echo " --colour Disable colour highlighting in search results." echo " --id Display the EDB-ID value rather than local path." echo " --nmap [file.xml] Checks all results in Nmap's XML output with service version (e.g.: nmap -sV -oX file.xml)." - echo " Use \"-v\" (verbose) to try even more combinations" + echo " Use \"-v\" (verbose) to try even more combinations" + echo "" echo "=======" echo " Notes " echo "=======" @@ -97,7 +98,7 @@ function usage() echo " * And/Or '-e' if you wish to filter results by using an exact match." echo " * Use '-t' to exclude the file's path to filter the search results." echo " * Remove false positives (especially when searching using numbers - i.e. versions)." - echo " * When updating from git or displaying help, search terms will be ignored." + echo " * When updating or displaying help, search terms will be ignored." echo "" exit 2 } @@ -120,7 +121,7 @@ function update() updatedbrew fi - # Update via git + # Update via Git updategit # Done @@ -131,7 +132,7 @@ function update() ## Update database (via .deb/apt) function updatedeb() { - echo -e '[i] Updating via APT package management. Expect weekly-ish updates.\n' + echo -e '[i] Updating via APT package management (Expect weekly-ish updates).\n' sudo apt update \ || echo -e '\n[-] Issue with apt update (Please check network connectivity & APT SourcesList values).' 1>&2 @@ -153,17 +154,17 @@ function updatedbrew() echo -e "\n[*] Brew update finished." } -## Update database (via GIT) +## Update database (via Git) function updategit() { - echo -e '[i] Updating via git. Expect daily updates.\n' + echo -e '[i] Updating via Git (Expect daily updates).\n' ## Make sure we are in the correct folder mkdir -p "${gitpath}/" \ || sudo mkdir -p "${gitpath}/" cd "${gitpath}/" - ## Are we in a git repo? + ## Are we in a Git repo? if [[ "$( git rev-parse --is-inside-work-tree )" != "true" ]]; then if [[ "$( ls )" = "" ]]; then # If directory is empty, just clone @@ -172,9 +173,9 @@ function updategit() fi fi - # Is our git remote added? (aka homebrew) + # Is our Git remote added? (aka homebrew) if [[ "$( git remote -v )" != *"${gitremote}"* ]]; then - echo -e '\n[i] Missing git remote:' "${gitremote}" + echo -e '\n[i] Missing Git remote:' "${gitremote}" git init >/dev/null git remote add origin "${gitremote}" 2>/dev/null fi @@ -478,7 +479,7 @@ fi ## Read in XML if [[ "${XML}" -eq 1 ]]; then ## Trim white spaces - FILE=$(echo ${TAGS} | xargs) + FILE=$( echo ${TAGS} | xargs ) ## Is there a file? if [[ ! -f "${FILE}" ]]; then @@ -488,7 +489,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 -y install libxml2-utils' 1>&2 exit 1 fi @@ -506,13 +507,13 @@ fi ## Print the full path. If pbcopy/xclip is available then copy to the clipboard if [[ "${GETPATH}" -eq 1 ]]; then - for exploit in $(echo ${TAGS}); do + for exploit in $( echo ${TAGS} ); do ## Get EDB-ID from input edbdb="$( echo ${exploit} | rev | cut -d '/' -f1 | rev | cut -d'.' -f1 | tr -dc '0-9' )" ## Check files.csv - location=$( cut -d, -f2 "${csvpath}" | grep -m 1 -E "/${edbdb}(\..*)?$" ) - title=$( grep -m 1 "${location}" "${csvpath}" | cut -d, -f3 | sed 's/"//g' ) + location=$( cut -d ',' -f 2 "${csvpath}" | grep -m 1 -E "/${edbdb}(\..*)?$" ) + title=$( grep -m 1 "${location}" "${csvpath}" | cut -d ',' -f 3 | sed 's/"//g' ) ## Join paths location="${gitpath}/${location}" @@ -557,8 +558,8 @@ if [[ "${GETPATH}" -eq 1 ]]; then fi if [[ "${MIRROR}" -eq 1 ]]; then - cp -i "${location}" "$(pwd)/" - echo "Copied to '$(pwd)/'" + cp -i "${location}" "$( pwd )/" + echo "Copied to '$( pwd )/'" echo -e "\n" fi else @@ -596,7 +597,7 @@ fi COL1=$(( $( tput cols ) - COL2 - 1 )) ## Remove leading space -TAGS="$(echo ${TAGS} | sed -e 's/^[[:space:]]//')" +TAGS="$( echo ${TAGS} | sed -e 's/^[[:space:]]//' )" ## Print header if NOT in JSON ("--json") if [[ "${JSON}" -eq 0 ]]; then