From 32edeb43421c517ccfcdad07f2fa062170f83f10 Mon Sep 17 00:00:00 2001 From: g0tmi1k Date: Wed, 8 Jul 2015 21:24:00 +0100 Subject: [PATCH 1/2] Switching -f with -t (--file to --title) Search just the exploit title (Default is title AND the file's path) --- searchsploit | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/searchsploit b/searchsploit index 3d0a937c8..ffe0ffc55 100755 --- a/searchsploit +++ b/searchsploit @@ -25,7 +25,7 @@ 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." @@ -87,22 +87,22 @@ 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 + if [[ "${param}" == "--case" ]]; then SCASE='' + elif [[ "${param}" == "--help" ]]; then + usage >&2 + elif [[ "${param}" == "--title" ]]; then + FILEPATH=0 elif [[ "${param}" == "--update" ]]; then UPDATE=1 + elif [[ "${param}" == "--www" ]]; then + WEBLINK=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='' + elif [[ "${param}" == "--id" ]]; then + EDBID=1 else if [[ "${param:0:1}" == "-" ]]; then ARGS=${ARGS}${param:1} @@ -122,10 +122,10 @@ while getopts "uchvwf" arg "${ARGS}"; do case ${arg} in c) SCASE='';; h) usage >&2;; + t) FILEPATH=0;; u) UPDATE=1;; v) VERBOSE=1;; - w) WEBLINK=1;; - f) FILEPATH=1;; + w) WEBLINK=1;;y esac shift $(( OPTIND - 1 )) done @@ -159,7 +159,7 @@ if [[ "${UPDATE}" -eq 1 ]]; then git pull origin master fi - echo "Update finished." + echo "[*] Update finished." exit 6 fi From 60391041b955da7827487113d22a8e9963b2badd Mon Sep 17 00:00:00 2001 From: g0tmi1k Date: Wed, 8 Jul 2015 21:38:52 +0100 Subject: [PATCH 2/2] Switch update to function --- searchsploit | 81 ++++++++++++++++++++++++++-------------------------- 1 file changed, 40 insertions(+), 41 deletions(-) diff --git a/searchsploit b/searchsploit index ffe0ffc55..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,7 +21,6 @@ progname="$( basename "$0" )" ## Default options TAGS="" SCASE="tolower" -UPDATE=0 VERBOSE=0 WEBLINK=0 EDBID=0 @@ -67,6 +67,39 @@ function usage() exit 1 } +## Update database (via GIT) +function update() +{ + cd "${gitpath}/" + + # Make sure a git repo is init before updating + if [[ "$( git rev-parse --is-inside-work-tree )" != "true" ]]; then + if [[ "$( ls )" = "" ]]; then + # If directory is empty, just clone + git clone "${gitremote}" . + else + # If not empty, init and add remote + git init >/dev/null + git remote add origin "${gitremote}" + fi + fi + + # Make sure to prep checkout first + git checkout -- . + + # Update from git + git pull origin master + + # If conflicts, clean and try again + if [[ "$?" -ne 0 ]]; then + git clean -d -fx "" + git pull origin master + fi + + echo "[*] Update finished." + exit 6 +} + ## Printing dotted lines in the correct manner function drawline() @@ -74,7 +107,7 @@ function drawline() printf "%0.s-" $( eval echo {1..$(( COL1 + 1 ))} ) echo -n " " printf "%0.s-" $( eval echo {1..$(( COL2 - 1 ))} ) - echo + echo "" } @@ -94,7 +127,7 @@ for param in "$@"; do elif [[ "${param}" == "--title" ]]; then FILEPATH=0 elif [[ "${param}" == "--update" ]]; then - UPDATE=1 + update elif [[ "${param}" == "--www" ]]; then WEBLINK=1 elif [[ "${param}" == "--verbose" ]]; then @@ -115,7 +148,7 @@ done ## Parse short arguments -while getopts "uchvwf" arg "${ARGS}"; do +while getopts "chtuvw" arg "${ARGS}"; do if [[ "${arg}" = "?" ]]; then usage >&2; fi @@ -123,47 +156,14 @@ while getopts "uchvwf" arg "${ARGS}"; do c) SCASE='';; h) usage >&2;; t) FILEPATH=0;; - u) UPDATE=1;; + u) update;; v) VERBOSE=1;; - w) WEBLINK=1;;y + w) WEBLINK=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 - if [[ "$( git rev-parse --is-inside-work-tree )" != "true" ]]; then - if [[ "$( ls )" = "" ]]; then - # If directory is empty, just clone - git clone "${gitremote}" . - else - # If not empty, init and add remote - git init > /dev/null - git remote add origin "${gitremote}" - fi - fi - - # Make sure to prep checkout first - git checkout -- . - - # Update from git - git pull origin master - - # If conflicts, clean and try again - if [[ "$?" -ne 0 ]]; then - git clean -d -fx "" - git pull origin master - fi - - echo "[*] Update finished." - exit 6 -fi - - ## Dynamically set column widths if [[ "${WEBLINK}" -eq '1' ]]; then COL2=45 @@ -262,4 +262,3 @@ drawline ## Done exit 0 -