From 0c3de086568d6ced2687b56e4a5282cd9951025f Mon Sep 17 00:00:00 2001 From: g0tmi1k Date: Fri, 21 Apr 2017 11:48:37 +0100 Subject: [PATCH] Add brew update support --- searchsploit | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/searchsploit b/searchsploit index 10d5f03e4..cba8a864c 100755 --- a/searchsploit +++ b/searchsploit @@ -1,6 +1,6 @@ #!/bin/bash # Name: SearchSploit - Exploit-DB's CLI search tool -# Version: 3.7.4 (Release date: 2017-03-17) +# Version: 3.7.5 (Release date: 2017-04-21) # Written by: Offensive Security, Unix-Ninja, and g0tmi1k # Homepage: https://github.com/offensive-security/exploit-database # Manual: https://www.exploit-db.com/searchsploit/ @@ -106,31 +106,52 @@ function usage() ## Update database check function update() { + # Update from the repos (e.g. Kali) dpkg -l exploitdb 2>/dev/null >/dev/null if [[ "$?" == "0" ]]; then - # Update from the repos (e.g. Kali) updatedeb - else - # Update via git - updategit + exit 6 fi + + # Update from homebrew (e.g. OSX) + brew install exploitdb 2>/dev/null >/dev/null + if [[ "$?" == "0" ]]; then + # This only really updates searchsploit + updatedbrew + fi + + # Update via git + updategit + + # Done + exit 6 } ## Update database (via .deb/apt) function updatedeb() { - echo -e '[i] Updating via package management. Expect weekly-ish updates.\n' + echo -e '[i] Updating via APT package management. Expect weekly-ish updates.\n' sudo apt update \ - || echo -e '\n[-] Issue with apt update (Please check network connectivity & APT SourcesList values)' 1>&2 + || echo -e '\n[-] Issue with apt update (Please check network connectivity & APT SourcesList values).' 1>&2 sudo apt -y install exploitdb \ - || echo -e '\n[-] Issue with apt install' 1>&2 + || echo -e '\n[-] Issue with apt upgrade.' 1>&2 - echo -e "\n[*] Update finished." - exit 6 + echo -e "\n[*] APT update finished." } +## Update database (via homebrew) +function updatedbrew() +{ + echo -e '[i] Updating via brew package management.\n' + + brew update \ + || echo -e '\n[-] Issue with brew update (Please check network connectivity).' 1>&2 + brew upgrade exploitdb 2>/dev/null >/dev/null + + echo -e "\n[*] Brew update finished." +} ## Update database (via GIT) function updategit() @@ -138,7 +159,8 @@ function updategit() echo -e '[i] Updating via git. Expect daily updates.\n' ## Make sure we are in the correct folder - mkdir -p "${gitpath}/" + mkdir -p "${gitpath}/" \ + || sudo mkdir -p "${gitpath}/" cd "${gitpath}/" ## Are we in a git repo? @@ -169,7 +191,7 @@ function updategit() git pull origin master fi - echo -e "\n[*] Update finished." + echo -e "\n[*] Git update finished." exit 6 }