Omp-script

Aus xinux wiki
Version vom 16. Januar 2020, 10:16 Uhr von Niklas.guenauer (Diskussion | Beiträge) (Scan Scipt)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

Before to do

   create a target
   create a scan

Scan Scipt

#!/bin/bash
TARGET=$1
FORMAT="c402cc3e-b531-11e1-9163-406186ea4fc5"
MAIL="technik@xxx.de"
INFO="$TARGET scan pdf $(date)"
TASKID=$(omp -G | grep $TARGET | cut -c1-37)
X=0

if ! [ -d "/tmp/openvas-reports" ]
then
        mkdir /tmp/openvas-reports
fi

#starte scan
REPORTID=$(omp -S $TASKID)

echo start
while [ "$X" -lt "1" ]
do
        if [ "$PROGRESS" == "Done" ]
        then
         cd /tmp/openvas-reports
         X=$((X+1))
         omp -R $REPORTID -f $FORMAT > $TARGET.pdf && echo $INFO| mutt -s "$INFO" $MAIL -a $TARGET.pdf
        else
                PROGRESS=$(omp -G | grep $TARGET | cut -c39-42)
                sleep 60
        fi
done

cronjob

target-import-script

  • /usr/local/sbin/create-target /root/target.list
  • vi /usr/local/sbin/create-target
#!/bin/bash
while read LINE
do
NAME=$(echo $LINE | cut -f 1 -d :)
IP=$(echo $LINE | cut -f 2 -d :)
cat<<HERE | omp -X -
<create_target>
<name>$NAME</name>
<hosts>$IP</hosts>
<port_list id="33d0cd82-57c6-11e1-8ed1-406186ea4fc5"/>
</create_target>'
HERE
done < $1
  • vi /root/target.list
example-target:10.0.0.0/8