#!/bin/bash

xml=msf-workspace.xml
modules_file=msf-modules.txt

if ! test -f $xml; then
    echo XML file $xml not found
    exit 1
elif ! test -f $modules_file; then
    echo no modules file found
    exit 2
fi

while read m; do
    NAME="$(date +%s)-$(basename $0)"
    echo "Run msfrpc plugin.."
    ./plugin/msfrpc.py --output $(realpath $2$NAME.xml) \
                       --log $(realpath $3$NAME.log) \
                       --xml $xml \
                       --resource autoexploit.rc \
                       --options MODE=check:MODULE=$m
done <$modules_file
