diff --git a/searchsploit b/searchsploit index 3d0a937c8..6ca7ea34a 100755 --- a/searchsploit +++ b/searchsploit @@ -1,11 +1,12 @@ #!/bin/bash # Name: searchsploit - Exploit-DB's CLI search tool -# Version: 3.1 (Release date: 2015-06-11) +# Version: 3.1 (Release date: 2015-07-08) # Written by: Offensive Security, Unix-Ninja & g0tmi1k # Homepage: https://github.com/offensive-security/exploit-database ## NOTE: # Exit code '0' means finished normally +# Exit code '1' means finished help screen # Exit code '6' means updated from GitHub @@ -20,12 +21,11 @@ progname="$( basename "$0" )" ## Default options TAGS="" SCASE="tolower" -UPDATE=0 VERBOSE=0 WEBLINK=0 EDBID=0 COLOUR='true' -FILEPATH=0 +FILEPATH=1 ## If files.csv is in the searchsploit path, use that instead @@ -46,8 +46,8 @@ function usage() echo " Options " echo "=========" echo " -c, --case Perform a case-sensitive search (Default is insensitive)." - echo " -f, --file Include file's path when searching (Default is just the exploit title)." echo " -h, --help Show this help screen." + echo " -t, --title Search just the exploit title (Default is title AND the file's path)." echo " -u, --update Update exploit database from git." echo " -v, --verbose Verbose output. Title lines are allowed to overflow their columns." echo " -w, --www Show URLs to Exploit-DB.com rather than local path." @@ -67,72 +67,9 @@ function usage() exit 1 } - -## Printing dotted lines in the correct manner -function drawline() +## Update database (via GIT) +function update() { - printf "%0.s-" $( eval echo {1..$(( COL1 + 1 ))} ) - echo -n " " - printf "%0.s-" $( eval echo {1..$(( COL2 - 1 ))} ) - echo -} - - -## Check for empty args -if [[ $# -eq 0 ]]; then - usage >&2 -fi - - -## Parse long arguments -ARGS="-" -for param in "$@"; do - if [[ "${param}" == "--help" ]]; then - usage >&2 - elif [[ "${param}" == "--web" ]]; then - WEBLINK=1 - elif [[ "${param}" == "--case" ]]; then - SCASE='' - elif [[ "${param}" == "--update" ]]; then - UPDATE=1 - elif [[ "${param}" == "--verbose" ]]; then - VERBOSE=1 - elif [[ "${param}" == "--id" ]]; then - EDBID=1 - elif [[ "${param}" == "--file" ]]; then - FILEPATH=1 - elif [[ "${param}" == "--colour" ]] || [[ "${param}" == "--color" ]]; then - COLOUR='' - else - if [[ "${param:0:1}" == "-" ]]; then - ARGS=${ARGS}${param:1} - shift - continue - fi - TAGS="${TAGS} ${param}" - fi -done - - -## Parse short arguments -while getopts "uchvwf" arg "${ARGS}"; do - if [[ "${arg}" = "?" ]]; then - usage >&2; - fi - case ${arg} in - c) SCASE='';; - h) usage >&2;; - u) UPDATE=1;; - v) VERBOSE=1;; - w) WEBLINK=1;; - f) FILEPATH=1;; - esac - shift $(( OPTIND - 1 )) -done - - -## Was an update requested? -if [[ "${UPDATE}" -eq 1 ]]; then cd "${gitpath}/" # Make sure a git repo is init before updating @@ -142,7 +79,7 @@ if [[ "${UPDATE}" -eq 1 ]]; then git clone "${gitremote}" . else # If not empty, init and add remote - git init > /dev/null + git init >/dev/null git remote add origin "${gitremote}" fi fi @@ -159,11 +96,74 @@ if [[ "${UPDATE}" -eq 1 ]]; then git pull origin master fi - echo "Update finished." + echo "[*] Update finished." exit 6 +} + + +## Printing dotted lines in the correct manner +function drawline() +{ + printf "%0.s-" $( eval echo {1..$(( COL1 + 1 ))} ) + echo -n " " + printf "%0.s-" $( eval echo {1..$(( COL2 - 1 ))} ) + echo "" +} + + +## Check for empty args +if [[ $# -eq 0 ]]; then + usage >&2 fi +## Parse long arguments +ARGS="-" +for param in "$@"; do + if [[ "${param}" == "--case" ]]; then + SCASE='' + elif [[ "${param}" == "--help" ]]; then + usage >&2 + elif [[ "${param}" == "--title" ]]; then + FILEPATH=0 + elif [[ "${param}" == "--update" ]]; then + update + elif [[ "${param}" == "--www" ]]; then + WEBLINK=1 + elif [[ "${param}" == "--verbose" ]]; then + VERBOSE=1 + elif [[ "${param}" == "--colour" ]] || [[ "${param}" == "--color" ]]; then + COLOUR='' + elif [[ "${param}" == "--id" ]]; then + EDBID=1 + else + if [[ "${param:0:1}" == "-" ]]; then + ARGS=${ARGS}${param:1} + shift + continue + fi + TAGS="${TAGS} ${param}" + fi +done + + +## Parse short arguments +while getopts "chtuvw" arg "${ARGS}"; do + if [[ "${arg}" = "?" ]]; then + usage >&2; + fi + case ${arg} in + c) SCASE='';; + h) usage >&2;; + t) FILEPATH=0;; + u) update;; + v) VERBOSE=1;; + w) WEBLINK=1;; + esac + shift $(( OPTIND - 1 )) +done + + ## Dynamically set column widths if [[ "${WEBLINK}" -eq '1' ]]; then COL2=45 @@ -262,4 +262,3 @@ drawline ## Done exit 0 -