OpenVAS: XMLStarlet Command Line XML Toolkit

XMLStarlet is a set of command line utilities, which can be used to transform, query, validate ans edit XML documents. Further informations can be found at http://xmlstar.sourceforge.net/

By combining omp and xmlstarlet, configuration information can be queried by OpenVAS Manager and used in a bash.

Debian:

apt-get install xmlstarlet

Read the UUID of a task

Command:

omp -h sv-openvas.joed.local -u joed -w 1q2w3e4r --xml "" | \
xmlstarlet sel -t -c "/get_tasks_response/task[name='HomeLan']" | \
xmlstarlet sel -t -v "/task/@id"

Result:

9ef3499d-82e4-45d6-a882-3c44d344039

Read the UUID of a target

Command:

omp -h sv-openvas.joed.local -u joed -w 1q2w3e4r --xml "" | \
xmlstarlet sel -t -c "/get_tasks_response/task[name='HomeLan']" | \
xmlstarlet sel -t -v "/task/target/@id"

Result:

d32ea2f7-8dbf-418e-a567-f491ecfcc06b

Read the hosts of a target

Command:

omp -h sv-openvas.joed.local -u joed -w 1q2w3e4r --xml "" | \
xmlstarlet sel -t -c "/get_targets_response/target[name='HomeLan']" | \
xmlstarlet sel -t -v "target/hosts"

Result:

192.168.1.105, 192.168.1.101, 192.168.1.106, 192.168.1.107, 192.168.1.104, 192.168.1.114, 192.168.1.115, 192.168.1.117, 192.168.1.100

Watch out: When working with nested xmlstarlet call you must make sure that always a root element is present.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s