From e0390992638f5fb7ffa2e5c8b853fc268d7a1169 Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Tue, 24 Oct 2023 14:33:32 -0600 Subject: [PATCH] Changed how arguments are passed to `magellan.sh` script --- bin/magellan.sh | 54 ++++++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/bin/magellan.sh b/bin/magellan.sh index 3482337..98b3a37 100755 --- a/bin/magellan.sh +++ b/bin/magellan.sh @@ -11,6 +11,8 @@ THREADS="1" TIMEOUT="30" ARGS="" FORCE_UPDATE=false +SCAN_PARAMS="" +COLLECT_PARAMS="" function build(){ @@ -19,11 +21,11 @@ function build(){ function scan() { # ./magellan scan --subnet 172.16.0.0 --port 443 - ${EXE} scan \ - --subnet ${SUBNETS} \ - --port ${PORTS} \ - --timeout ${TIMEOUT} \ - --threads ${THREADS} + ${EXE} scan ${SCAN_PARAMS} + # --subnet ${SUBNETS} \ + # --port ${PORTS} \ + # --timeout ${TIMEOUT} \ + # --threads ${THREADS} } function list(){ @@ -33,20 +35,30 @@ function list(){ function collect() { # ./magellan collect --user admin --pass password - ${EXE} collect \ - --user ${USER} \ - --pass ${PASS} \ - --timeout ${TIMEOUT} \ - --threads ${THREADS} \ - --host ${SMD_HOST} \ - --port ${SMD_PORT} \ - --force-update ${FORCE_UPDATE} + ${EXE} collect ${COLLECT_PARAMS} + # --user ${USER} \ + # --pass ${PASS} \ + # --timeout ${TIMEOUT} \ + # --threads ${THREADS} \ + # --host ${SMD_HOST} \ + # --port ${SMD_PORT} \ + # --force-update ${FORCE_UPDATE} } # parse incoming arguments to set variables while [[ $# -gt 0 ]]; do case $1 in + --scan) + SCAN_PARAMS="$2" + shift + shift + ;; + --collect) + COLLECT_PARAMS="$2" + shift + shift + ;; --subnet) SUBNETS="$2" shift # past argument @@ -100,19 +112,15 @@ done set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters -echo "SMD host = ${SMD_HOST}" -echo "SMD port = ${SMD_PORT}" -echo "subnets = ${SUBNETS}" -echo "ports = ${PORTS}" -echo "user = ${USER}" -echo "threads = ${THREADS}" -echo "timeout = ${TIMEOUT}" -echo "pass = ..." - if [[ -n $1 ]]; then echo "Last line of file specified as non-opt/last argument:" tail -1 "$1" fi scan -collect \ No newline at end of file +collect + +# run with docker +# docker run magellan:latest magellan.sh \ +# --scan "--subnet 127.16.0.0 --port 443" \ +# --collect "--user admin --pass password --timeout 300 --threads 1 --smd-host host --smd-port port" \ No newline at end of file