From a1d19de19a619b6cec7fcec6b48fbd09e9e0cd9a Mon Sep 17 00:00:00 2001 From: thomhastings Date: Mon, 29 Jan 2018 20:42:54 -0800 Subject: [PATCH 1/8] add install --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e09a164..32b3081 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,12 @@ A *battery* of Metasplot Resource Scripts This repository is a collection of Metasploit resource scripts that perform a *battery* of tests for "low hanging fruit". Installation ------------- -First, you need to get [Metasploit][msf on github] up and running. Make sure you have the [database configured][msf database setup]. +First, you need to get [Metasploit][msf on github] up and running. Make sure you have the [database configured][msf database setup] (e.g. `service postgresql start && msfdb init`). -To 'install' battery, just copy the *battery* folder, along with *battery.rc* to the resource folder in your Metasploit user's scripts directory (it is usually something like */home/yourname/.msf4/scripts/resouce*). You should have something like: +To 'install' battery, run the install script: + * `./install.sh` +Alternatively, just copy the *battery* folder, along with *battery.rc* to the resource folder in your Metasploit user's scripts directory (it is usually something like */home/yourname/.msf4/scripts/resouce*). You should have something like: * ~/.msf4/scripts/resource/battery/ * ~/.msf4/scripts/resource/battery.rc From 2a651ee766a9b11c42f19bc996addaad78e3b44c Mon Sep 17 00:00:00 2001 From: thomhastings Date: Mon, 29 Jan 2018 20:46:03 -0800 Subject: [PATCH 2/8] small correction --- battery/ms17_010_check.rc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/battery/ms17_010_check.rc b/battery/ms17_010_check.rc index 7e72411..2e0450a 100644 --- a/battery/ms17_010_check.rc +++ b/battery/ms17_010_check.rc @@ -20,7 +20,7 @@ =end # Print Header -print_status "Using check from auxiliary/scanner/smb/smb_ms17_010" +print_status "Using auxiliary/scanner/smb/smb_ms17_010" # Get a list of target services targets = [] From a3b94335f3c8fa6b495b810034468515e7cc904f Mon Sep 17 00:00:00 2001 From: thomhastings Date: Mon, 29 Jan 2018 20:48:43 -0800 Subject: [PATCH 3/8] add install --- install.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 install.sh diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..fda6530 --- /dev/null +++ b/install.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# install battery msf scripts +# (c) Thom Hastings 2018 GNU GPLv3 +# h/t: @TrentonIvey aka kn0 +# https://github.com/kn0/battery +# +# plz run as root on kali linux +# +# mk dirs +if [ ! -e "~/.msf4/scripts/" ] + then mkdir ~/.msf4/scripts/ +fi +if [ ! -e "~/.msf4/scripts/resource/" ] + then mkdir ~/.msf4/scripts/resource/ +fi +# copy battery directory +cp -R battery ~/.msf4/scripts/resource/battery +# copy battery script +cp battery.rc ~/.msf4/scripts/resource/ +# let the user know it worked +echo "battery installed to ~/.msf4/scripts/resource" \ No newline at end of file From e35bc02868c73faebac52de54d1bbc8eed80d297 Mon Sep 17 00:00:00 2001 From: thomhastings Date: Mon, 29 Jan 2018 20:49:49 -0800 Subject: [PATCH 4/8] readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 32b3081..afcae77 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,9 @@ Installation First, you need to get [Metasploit][msf on github] up and running. Make sure you have the [database configured][msf database setup] (e.g. `service postgresql start && msfdb init`). -To 'install' battery, run the install script: +To 'install' battery, simplt run the install script: * `./install.sh` + Alternatively, just copy the *battery* folder, along with *battery.rc* to the resource folder in your Metasploit user's scripts directory (it is usually something like */home/yourname/.msf4/scripts/resouce*). You should have something like: * ~/.msf4/scripts/resource/battery/ * ~/.msf4/scripts/resource/battery.rc From 0a16e33baec9b2e566056056d4870c1b6d009b0c Mon Sep 17 00:00:00 2001 From: thomhastings Date: Mon, 29 Jan 2018 20:51:00 -0800 Subject: [PATCH 5/8] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index afcae77..39593f7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Installation First, you need to get [Metasploit][msf on github] up and running. Make sure you have the [database configured][msf database setup] (e.g. `service postgresql start && msfdb init`). -To 'install' battery, simplt run the install script: +To 'install' battery, simply run the install script: * `./install.sh` Alternatively, just copy the *battery* folder, along with *battery.rc* to the resource folder in your Metasploit user's scripts directory (it is usually something like */home/yourname/.msf4/scripts/resouce*). You should have something like: From c4491169da9511a20c0bbf71e8669a92c95cbd81 Mon Sep 17 00:00:00 2001 From: thomhastings Date: Mon, 29 Jan 2018 21:01:43 -0800 Subject: [PATCH 6/8] fix install --- battery/ms17_010_check.rc | 3 ++- install.sh | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/battery/ms17_010_check.rc b/battery/ms17_010_check.rc index 2e0450a..f326595 100644 --- a/battery/ms17_010_check.rc +++ b/battery/ms17_010_check.rc @@ -47,6 +47,7 @@ else # Run the module once for each discovered target port (with the associated hosts) targets = targets.join(' ') print_status "Target List: #{targets}" - self.run_single("run '#{targets}'") + self.run_single("set RHOSTS #{targets.join(' ')}") + self.run_single("run") end diff --git a/install.sh b/install.sh index fda6530..6d37f35 100755 --- a/install.sh +++ b/install.sh @@ -9,9 +9,11 @@ # mk dirs if [ ! -e "~/.msf4/scripts/" ] then mkdir ~/.msf4/scripts/ + else : fi if [ ! -e "~/.msf4/scripts/resource/" ] then mkdir ~/.msf4/scripts/resource/ + else : fi # copy battery directory cp -R battery ~/.msf4/scripts/resource/battery From a349b751739314375ddbc537084d7facf5b4c1cd Mon Sep 17 00:00:00 2001 From: thomhastings Date: Mon, 29 Jan 2018 21:12:24 -0800 Subject: [PATCH 7/8] fix install --- install.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index 6d37f35..53669eb 100755 --- a/install.sh +++ b/install.sh @@ -7,14 +7,8 @@ # plz run as root on kali linux # # mk dirs -if [ ! -e "~/.msf4/scripts/" ] - then mkdir ~/.msf4/scripts/ - else : -fi -if [ ! -e "~/.msf4/scripts/resource/" ] - then mkdir ~/.msf4/scripts/resource/ - else : -fi +mkdir -p ~/.msf4/scripts/resource/ +echo "installing..." # copy battery directory cp -R battery ~/.msf4/scripts/resource/battery # copy battery script From 2b3b61cde6cd1a7ebe96e26bdeb0615335455315 Mon Sep 17 00:00:00 2001 From: thomhastings Date: Mon, 29 Jan 2018 21:56:46 -0800 Subject: [PATCH 8/8] various bugfixes --- README.md | 2 +- battery.rc | 1 + battery/ms17_010_check.rc | 5 ++--- install.sh | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 39593f7..988af9b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Alternatively, just copy the *battery* folder, along with *battery.rc* to the re Usage ------ -Battery selects targets based off of services included in the Metasploit database. You can use nmap within Metasploit to find hosts and services and add them to the database: `db_nmap -A -v some_host_or_range` +Battery selects targets based off of services included in the Metasploit database. You can use nmap within Metasploit to find hosts and services and add them to the database: `db_nmap -A -v some_host_or_range` Note: Battery scripts reqire service and OS data, so it is recommended that you run nmap with at least the `-S` and `-O` flags. Just call the battery.rc resource script within msfconsole to start: `resource battery.rc` diff --git a/battery.rc b/battery.rc index cc6ea4b..2e853ba 100644 --- a/battery.rc +++ b/battery.rc @@ -52,3 +52,4 @@ end unset all popm +back diff --git a/battery/ms17_010_check.rc b/battery/ms17_010_check.rc index f326595..5c9cb6c 100644 --- a/battery/ms17_010_check.rc +++ b/battery/ms17_010_check.rc @@ -42,11 +42,10 @@ if targets.empty? else # Setup the module self.run_single("use auxiliary/scanner/smb/smb_ms17_010") + self.run_single("set ShowProgress false") self.run_single("set VERBOSE true") - # Run the module once for each discovered target port (with the associated hosts) - targets = targets.join(' ') - print_status "Target List: #{targets}" + # Run the module against all hosts self.run_single("set RHOSTS #{targets.join(' ')}") self.run_single("run") end diff --git a/install.sh b/install.sh index 53669eb..8114dfe 100755 --- a/install.sh +++ b/install.sh @@ -6,12 +6,12 @@ # # plz run as root on kali linux # +echo "Installing..." # mk dirs mkdir -p ~/.msf4/scripts/resource/ -echo "installing..." -# copy battery directory -cp -R battery ~/.msf4/scripts/resource/battery # copy battery script -cp battery.rc ~/.msf4/scripts/resource/ +cp -rf battery.rc ~/.msf4/scripts/resource/ +# copy battery directory +cp -R -rf battery ~/.msf4/scripts/resource/battery # let the user know it worked -echo "battery installed to ~/.msf4/scripts/resource" \ No newline at end of file +echo "battery installed to ~/.msf4/scripts/resource"