Merge pull request #69 from g0tmi1k/searchsploit
Fixes for #64, #66 & #67 (Take 2)
This commit is contained in:
commit
1d549a3241
1 changed files with 42 additions and 30 deletions
72
searchsploit
72
searchsploit
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Name: SearchSploit - Exploit-DB's CLI search tool
|
# Name: SearchSploit - Exploit-DB's CLI search tool
|
||||||
# Version: 3.7.2 (Release date: 2016-12-08)
|
# Version: 3.7.3 (Release date: 2016-12-20)
|
||||||
# Written by: Offensive Security, Unix-Ninja, and g0tmi1k
|
# Written by: Offensive Security, Unix-Ninja, and g0tmi1k
|
||||||
# Homepage: https://github.com/offensive-security/exploit-database
|
# Homepage: https://github.com/offensive-security/exploit-database
|
||||||
#
|
#
|
||||||
|
@ -238,7 +238,7 @@ function searchsploitout()
|
||||||
if [[ "${lines}" -gt 100 ]]; then
|
if [[ "${lines}" -gt 100 ]]; then
|
||||||
echo -e "[-] Skipping output: ${tmp} (Too many results. Please re-search manually: $0 ${arg} ${tmp})\n" 1>&2
|
echo -e "[-] Skipping output: ${tmp} (Too many results. Please re-search manually: $0 ${arg} ${tmp})\n" 1>&2
|
||||||
## Are there any result?
|
## Are there any result?
|
||||||
elif [[ "${lines}" -gt 6 ]]; then
|
elif [[ "${lines}" -gt 5 ]]; then
|
||||||
echo -e "${out}\n\n"
|
echo -e "${out}\n\n"
|
||||||
## If there's no results
|
## If there's no results
|
||||||
else
|
else
|
||||||
|
@ -262,7 +262,7 @@ function searchsploitout()
|
||||||
if [[ "${lines}" -gt 100 ]]; then
|
if [[ "${lines}" -gt 100 ]]; then
|
||||||
echo -e "[-] Skipping output: ${software} (Too many results. Please re-search manually: $0 ${arg} ${software})\n" 1>&2
|
echo -e "[-] Skipping output: ${software} (Too many results. Please re-search manually: $0 ${arg} ${software})\n" 1>&2
|
||||||
## Are there any result?
|
## Are there any result?
|
||||||
elif [[ "${lines}" -gt 6 ]]; then
|
elif [[ "${lines}" -gt 5 ]]; then
|
||||||
echo -e "${out}\n\n"
|
echo -e "${out}\n\n"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -273,7 +273,7 @@ function searchsploitout()
|
||||||
function nmapxml()
|
function nmapxml()
|
||||||
{
|
{
|
||||||
## Remove any old traces
|
## Remove any old traces
|
||||||
rm -f /tmp/searchsploitout
|
rm -f /tmp/searchsploit.{tmp,out}
|
||||||
|
|
||||||
## Feedback to the end user
|
## Feedback to the end user
|
||||||
echo -e "[i] Reading: '${FILE}'\n"
|
echo -e "[i] Reading: '${FILE}'\n"
|
||||||
|
@ -286,28 +286,37 @@ function nmapxml()
|
||||||
type=$( echo "${line}" | cut -d" " -f 1 )
|
type=$( echo "${line}" | cut -d" " -f 1 )
|
||||||
input=$( echo "${line}" | cut -d" " -f 2- )
|
input=$( echo "${line}" | cut -d" " -f 2- )
|
||||||
|
|
||||||
case "${type}" in
|
case "${type}" in
|
||||||
"[IP]")
|
"[IP]")
|
||||||
#[[ "${VERBOSE}" -eq 1 ]] && echo -e "\n\n\e[32m[*] IP: ${input}\e[39m" 1>&2
|
#[[ "${VERBOSE}" -eq 1 ]] && echo -e "\n\n\e[32m[*] IP: ${input}\e[39m" 1>&2
|
||||||
;;
|
;;
|
||||||
"[NAME]")
|
"[NAME]")
|
||||||
#searchsploitout
|
## If we have already looped around and got something, save it before moving onto the current value
|
||||||
echo "${software}" >> /tmp/searchsploitout
|
if [[ "${software}" ]]; then
|
||||||
software="${input}"
|
#searchsploitout
|
||||||
;;
|
echo "${software}" >> /tmp/searchsploit.out
|
||||||
"[PRODUCT]")
|
fi
|
||||||
software="${input}"
|
## Something is better than nothing. Will just go on the default service that matches the port. e.g. domain
|
||||||
;;
|
software="${input}"
|
||||||
"[VERSION]")
|
## Might not get any more than this, if -sV failed
|
||||||
software="${software} ${input}"
|
echo "${software}" > /tmp/searchsploit.tmp
|
||||||
;;
|
;;
|
||||||
|
"[PRODUCT]")
|
||||||
|
## We have a name, but no version (yet?) e.g. dnsmasq
|
||||||
|
software="${input}"
|
||||||
|
echo "${software}" > /tmp/searchsploit.tmp
|
||||||
|
;;
|
||||||
|
"[VERSION]")
|
||||||
|
software="${software} ${input}"
|
||||||
|
## Name & version. There isn't any more information to get, game over. e.g. dnsmasq 2.72
|
||||||
|
echo "${software}" >> /tmp/searchsploit.out
|
||||||
|
echo "" > /tmp/searchsploit.tmp
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
#searchsploitout
|
|
||||||
echo "${software}" >> /tmp/searchsploitout
|
|
||||||
|
|
||||||
## Read in from file (so there are no duplicates - ...but unable to print out IPs)
|
## Read in from file (so there are no duplicates - ...but unable to print out IPs)
|
||||||
cat /tmp/searchsploitout | tr '[:upper:]' '[:lower:]' | awk '!x[$0]++' | while read software; do
|
cat /tmp/searchsploit.tmp /tmp/searchsploit.out 2>/dev/null | tr '[:upper:]' '[:lower:]' | awk '!x[$0]++' | while read software; do
|
||||||
searchsploitout
|
searchsploitout
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -615,37 +624,40 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
## Strip un-wanted values
|
||||||
|
SEARCH="${SEARCH} | sed 's/\"//g'"
|
||||||
|
|
||||||
|
|
||||||
## Magic search Fu
|
## Magic search Fu
|
||||||
## Web link format ("--www")?
|
## Web link format ("--www")?
|
||||||
if [[ "${WEBLINK}" -eq 1 ]]; then
|
if [[ "${WEBLINK}" -eq 1 ]]; then
|
||||||
OUTPUT="$( eval ${SEARCH} \
|
OUTPUT="$( eval ${SEARCH} \
|
||||||
| awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, "https://www.exploit-db.com/exploits/"$1"/"}' )"
|
| awk -F ',' '{ printf "%-'${FORMAT}'s | %s\n", $3, "https://www.exploit-db.com/exploits/"$1"/"}' )"
|
||||||
## Just the EDB-ID ("--id")?
|
## Just the EDB-ID ("--id")?
|
||||||
elif [[ "${EDBID}" -eq 1 ]]; then
|
elif [[ "${EDBID}" -eq 1 ]]; then
|
||||||
OUTPUT="$( eval ${SEARCH} \
|
OUTPUT="$( eval ${SEARCH} \
|
||||||
| awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, $1 }' )"
|
| awk -F ',' '{ printf "%-'${FORMAT}'s | %s\n", $3, $1 }' )"
|
||||||
## Print JSON format (full options) ("--json")?
|
## Print JSON format (full options) ("--json")?
|
||||||
elif [[ "${JSON}" -eq 1 ]]; then
|
elif [[ "${JSON}" -eq 1 ]]; then
|
||||||
OUTPUT="$( eval ${SEARCH} \
|
OUTPUT="$( eval ${SEARCH} \
|
||||||
| awk -F "\"*,\"*" '{ printf "\r\t\t'{'\"Exploit\":\"%s,\"Path\":\"'${gitpath}/'%s\",\"EDB-ID\":%s},\n", $3, $2, $1 }' \
|
| awk -F ',' '{ printf "\r\t\t'{'\"Exploit\":\"%s\",\"Path\":\"'${gitpath}/'%s\",\"EDB-ID\":%s},\n", $3, $2, $1 }' \
|
||||||
| sed '$ s/,$//g' )"
|
| sed '$ s/,$//g' )"
|
||||||
## Default view
|
## Default view
|
||||||
else
|
else
|
||||||
OUTPUT="$( eval ${SEARCH} \
|
OUTPUT="$( eval ${SEARCH} \
|
||||||
| awk -F "\"*,\"*" '{ printf "%-'${FORMAT}'s | %s\n", $3, $2 }' \
|
| awk -F ',' '{ printf "%-'${FORMAT}'s | %s\n", $3, $2 }' \
|
||||||
| sed "s/| platforms/| /" )"
|
| sed 's/| platforms/| /' )"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
## Display colour highlights ("--colour")?
|
## Display colour highlights ("--colour")?
|
||||||
if [[ "${COLOUR_TAG}" ]] && [[ "${JSON}" -eq 0 ]]; then
|
if [[ "${COLOUR_TAG}" ]] && [[ "${JSON}" -eq 0 ]]; then
|
||||||
OUTPUT=$( echo -e "${OUTPUT}" | eval ${COLOUR_TAG} )
|
[[ "${OUTPUT}" ]] && OUTPUT=$( echo -e "${OUTPUT}" | eval ${COLOUR_TAG} )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
## Show content
|
## Show content
|
||||||
echo "${OUTPUT}"
|
[[ "${OUTPUT}" ]] && echo "${OUTPUT}"
|
||||||
|
|
||||||
|
|
||||||
## Print footer if NOT in JSON ("--json")
|
## Print footer if NOT in JSON ("--json")
|
||||||
if [[ "${JSON}" -eq 0 ]]; then
|
if [[ "${JSON}" -eq 0 ]]; then
|
||||||
|
|
Loading…
Add table
Reference in a new issue