forked from offensive-security/exploitdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearchsploit
executable file
·107 lines (96 loc) · 2.37 KB
/
searchsploit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
# exploitdb CLI search tool
# Version 2
# Written by Unix-Ninja
csvpath=/usr/share/exploitdb/files.csv
progname=`basename $0`
TAGS=
SCASE='-i'
VERBOSE=0
# if files.csv is in the searchsploit path, use that
if [ -f "$( dirname $0 )/files.csv" ]; then
csvpath="$( dirname $0 )/files.csv"
fi
# usage info
function usage()
{
echo "Usage: $progname [options] term1 [term2] ... [termN]"
echo "Example: $progname oracle windows local"
echo
echo "======="
echo "Options"
echo "======="
echo
echo " -c Perform case-sensitive searches; by default, searches will"
echo " try to be greedy"
echo " -h, --help Show help screen"
echo " -v By setting verbose output, description lines are allowed to"
echo " overflow their columns"
echo
echo "*NOTES*"
echo "Use any number of search terms you would like (minimum of one)."
echo "Search terms are not case sensitive, and order is irrelevant."
exit 1
}
# dynamically set column widths
COL2=35
COL1=$(( `tput cols` - $COL2 - 1 ))
# 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
else
if [ "${param:0:1}" == "-" ]; then
ARGS=$ARGS${param:1}
shift
continue
fi
TAGS="$TAGS $param"
fi
done
# parse short arguments
while getopts "chv" arg $ARGS; do
if [ "$arg" = "?" ]; then
usage >&2;
fi
case $arg in
c) SCASE='';;
h) usage >&2;;
v) VERBOSE=1;;
esac
shift $((OPTIND-1))
done
# print header
printf "%-${COL1}s %s" " Description"
echo " Path"
printf "%0.s-" `eval echo {1..$(( $COL1 + 1 ))}`
echo -n " "
printf "%0.s-" `eval echo {1..$(( $COL2 - 1 ))}`
echo
# create search command
SEARCH=
for tag in $TAGS; do
if [ "$SEARCH" ]; then
SEARCH="$SEARCH |"
fi
SEARCH="$SEARCH fgrep $SCASE \"$tag\""
done
# set LANG variable to avoid illegal byte sequence errors in sed
LANG=C
# search, format, and print results
if [ "$VERBOSE" -eq 0 ]; then
FORMAT=$COL1'.'$COL1
else
FORMAT=$COL1
fi
cat $csvpath \
| eval $SEARCH \
| awk -F "\"*,\"*" '{ printf "%-'$FORMAT's | %s\n", $3, $2}' \
| sed " s/| platforms/| /" \
| eval $SEARCH
exit 0