Merge branch 'g0tmi1k-title'

This commit is contained in:
Offensive Security 2015-07-08 20:36:33 +00:00
commit bdb8acbc33

View file

@ -1,11 +1,12 @@
#!/bin/bash #!/bin/bash
# Name: searchsploit - Exploit-DB's CLI search tool # 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 # Written by: Offensive Security, Unix-Ninja & g0tmi1k
# Homepage: https://github.com/offensive-security/exploit-database # Homepage: https://github.com/offensive-security/exploit-database
## NOTE: ## NOTE:
# Exit code '0' means finished normally # Exit code '0' means finished normally
# Exit code '1' means finished help screen
# Exit code '6' means updated from GitHub # Exit code '6' means updated from GitHub
@ -20,12 +21,11 @@ progname="$( basename "$0" )"
## Default options ## Default options
TAGS="" TAGS=""
SCASE="tolower" SCASE="tolower"
UPDATE=0
VERBOSE=0 VERBOSE=0
WEBLINK=0 WEBLINK=0
EDBID=0 EDBID=0
COLOUR='true' COLOUR='true'
FILEPATH=0 FILEPATH=1
## If files.csv is in the searchsploit path, use that instead ## If files.csv is in the searchsploit path, use that instead
@ -46,8 +46,8 @@ function usage()
echo " Options " echo " Options "
echo "=========" echo "========="
echo " -c, --case Perform a case-sensitive search (Default is insensitive)." 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 " -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 " -u, --update Update exploit database from git."
echo " -v, --verbose Verbose output. Title lines are allowed to overflow their columns." 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." echo " -w, --www Show URLs to Exploit-DB.com rather than local path."
@ -67,72 +67,9 @@ function usage()
exit 1 exit 1
} }
## Update database (via GIT)
## Printing dotted lines in the correct manner function update()
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}" == "--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}/" cd "${gitpath}/"
# Make sure a git repo is init before updating # Make sure a git repo is init before updating
@ -159,11 +96,74 @@ if [[ "${UPDATE}" -eq 1 ]]; then
git pull origin master git pull origin master
fi fi
echo "Update finished." echo "[*] Update finished."
exit 6 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 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 ## Dynamically set column widths
if [[ "${WEBLINK}" -eq '1' ]]; then if [[ "${WEBLINK}" -eq '1' ]]; then
COL2=45 COL2=45
@ -262,4 +262,3 @@ drawline
## Done ## Done
exit 0 exit 0