Add support for updating edb from git
This commit is contained in:
parent
35d1967763
commit
82f8f5e744
1 changed files with 44 additions and 7 deletions
43
searchsploit
43
searchsploit
|
@ -1,14 +1,21 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# exploitdb CLI search tool
|
# exploitdb CLI search tool
|
||||||
# Version 2
|
# Version 3
|
||||||
# Written by Unix-Ninja
|
# Written by Unix-Ninja
|
||||||
|
|
||||||
csvpath=/usr/share/exploitdb/files.csv
|
gitremote=https://github.com/offensive-security/exploit-database.git
|
||||||
|
gitpath=/usr/share/exploitdb
|
||||||
|
csvpath=${gitpath}/files.csv
|
||||||
progname=`basename $0`
|
progname=`basename $0`
|
||||||
TAGS=
|
TAGS=
|
||||||
SCASE='-i'
|
SCASE='-i'
|
||||||
|
UPDATE=0
|
||||||
VERBOSE=0
|
VERBOSE=0
|
||||||
|
|
||||||
|
# NOTE:
|
||||||
|
# Exit code 0 means finished normally
|
||||||
|
# Exit code 6 means updated from github
|
||||||
|
|
||||||
# if files.csv is in the searchsploit path, use that
|
# if files.csv is in the searchsploit path, use that
|
||||||
if [ -f "$( dirname $0 )/files.csv" ]; then
|
if [ -f "$( dirname $0 )/files.csv" ]; then
|
||||||
csvpath="$( dirname $0 )/files.csv"
|
csvpath="$( dirname $0 )/files.csv"
|
||||||
|
@ -27,6 +34,7 @@ function usage()
|
||||||
echo " -c Perform case-sensitive searches; by default, searches will"
|
echo " -c Perform case-sensitive searches; by default, searches will"
|
||||||
echo " try to be greedy"
|
echo " try to be greedy"
|
||||||
echo " -h, --help Show help screen"
|
echo " -h, --help Show help screen"
|
||||||
|
echo " -u Update db from git"
|
||||||
echo " -v By setting verbose output, description lines are allowed to"
|
echo " -v By setting verbose output, description lines are allowed to"
|
||||||
echo " overflow their columns"
|
echo " overflow their columns"
|
||||||
echo
|
echo
|
||||||
|
@ -61,18 +69,47 @@ for param in $@; do
|
||||||
done
|
done
|
||||||
|
|
||||||
# parse short arguments
|
# parse short arguments
|
||||||
while getopts "chv" arg $ARGS; do
|
while getopts "chuv" arg $ARGS; do
|
||||||
if [ "$arg" = "?" ]; then
|
if [ "$arg" = "?" ]; then
|
||||||
usage >&2;
|
usage >&2;
|
||||||
fi
|
fi
|
||||||
case $arg in
|
case $arg in
|
||||||
c) SCASE='';;
|
c) SCASE='';;
|
||||||
h) usage >&2;;
|
h) usage >&2;;
|
||||||
|
u) UPDATE=1;;
|
||||||
v) VERBOSE=1;;
|
v) VERBOSE=1;;
|
||||||
esac
|
esac
|
||||||
shift $((OPTIND-1))
|
shift $((OPTIND-1))
|
||||||
done
|
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 github
|
||||||
|
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
|
||||||
|
|
||||||
# print header
|
# print header
|
||||||
printf "%-${COL1}s %s" " Description"
|
printf "%-${COL1}s %s" " Description"
|
||||||
echo " Path"
|
echo " Path"
|
||||||
|
|
Loading…
Add table
Reference in a new issue