[Openvas-discuss] Modifying task targets with omp [PUBLIC]

Rémi Liquete remi.l034 at gmail.com
Thu Aug 31 16:59:49 CEST 2017


You're welcome.

If you are doing this in python, here is my code for doing what you want :

else: # If tasks exists, we modify it to change ports list and target
                # First, creation of temp task
                createTempTarget =
'<create_target><name>TEMP</name><hosts>127.0.0.1</hosts></create_target>'
                tempTargetID = exec_task('-X', createTempTarget)
                time.sleep(1)

                # Modification of task to attribute temp one
                modifyTask = '<modify_task task_id="%s"><target
id="%s"/></modify_task>' % (taskID, tempTargetID)
                exec_task('-X', modifyTask, 'modif')
                time.sleep(1)

                # We delete target and ports list to modify it
                deleteTarget = '<get_targets filter="name=%s"/>' %
targetName
                targetID = exec_task('-X', deleteTarget, 'delete target')
                time.sleep(1)
                deletePort = '<get_port_lists filter="name=%s"/>' % portName
                portID = exec_task('-X', deletePort, 'delete port')
                time.sleep(1)

                # Creation of new ports list and target
                portID = create_ports_list(portName, portList, groupID)
                targetID = create_target(targetName, IPs, portID, groupID)

                # Modification of the task to associate the new target
                modifyTask = '<modify_task task_id="%s"><target
id="%s"/></modify_task>' % (taskID, targetID)
                exec_task('-X', modifyTask, 'modif')
                time.sleep(1)

                # Finally, we delete the temp target
                deleteTempTarget = '<delete_target target_id="%s"/>' %
tempTargetID
                exec_task('-X', deleteTempTarget, 'delete')

The exec_task is a command to execute the command, I just pass arguments to
this command.
So, I'm just editing the XML forms to execute my needs.
The time sleeps are needed because sometimes Greenbone didn't finish an
command completely before starting the new one.

Regards,
Rémi.

2017-08-31 16:48 GMT+02:00 CAMPBELL Jeremy <jcampbell at scorvelogica.com>:

> Thanks for sharing.  I’ll give this a try.  I’ve written python scripts to
> pull the system inventory from our cloud provider and create target groups
> based on tags assigned to the assets.  This is the last part I’m looking
> for to complete the automation.
>
>
>
> Best,
>
> Jeremy
>
>
>
> This message was classified *PUBLIC *by CAMPBELL Jeremy on Thursday,
> August 31, 2017 at 10:48:41 AM.
>
>
>
> *From:* Rémi Liquete [mailto:remi.l034 at gmail.com]
> *Sent:* Thursday, August 31, 2017 10:42 AM
> *To:* Thijs Stuurman <Thijs.Stuurman at internedservices.nl>
> *Cc:* CAMPBELL Jeremy <jcampbell at scorvelogica.com>; openvas-discuss at wald.
> intevation.org
> *Subject:* Re: [Openvas-discuss] Modifying task targets with omp [PUBLIC]
>
>
>
> Hi Jeremy,
>
> I've done this last month.
>
> The only way to do what you want with OMP is to create a temporary target
> and affects it to the task.
>
> Then modify your target, and affects it back to your target.
>
> The command to do this is : omp -u User -w Password -X '<modify_task
> task_id="HERE IS YOUR TASK ID"><target id="HERE IS YOUR TARGET ID TO AFFECT
> TO THE TASK"/></modify_task>'
>
>
>
> I have full automate my scans in python scripts with that to modify my
> task and its target.
>
> Regards,
>
> Rémi.
>
>
>
> 2017-08-31 16:27 GMT+02:00 Thijs Stuurman <Thijs.Stuurman@
> internedservices.nl>:
>
> I checked GVM Tools which contains functions such as:
>
>
>
> def create_target(self, name, make_unique, **kwargs)
>
> def delete_target(self, target_id, ultimate=0)
>
> def modify_target(self, target_id, **kwargs)
>
> def modify_task(self):
>
>
>
> but found:
>
>
>
> “””
>
> def modify_task(self):
>
>         # TODO: Multiple values are required to modify a task. Is this
> correct?
>
>         raise NotImplementedError
>
> “””
>
>
>
> So.. I guess not yet.
>
> The “old” command line OMP has the option:
>
>
>
> -M, --modify-task                Modify a task.
>
>
>
> But I never used it, not sure how it works.
>
>
>
> Thijs Stuurman
>
> Security Operations Center | KPN Internedservices
>
> thijs.stuurman at internedservices.nl | thijs.stuurman at kpn.com
>
> T: +31(0)299476185 <+31%20299%20476%20185> | M: +31(0)624366778
> <+31%206%2024366778>
>
> PGP Key-ID: 0x16ADC048 (https://pgp.surfnet.nl/)
>
> Fingerprint: 2EDB 9B42 D6E8 7D4B 6E02 8BE5 6D46 8007 16AD C048
>
>
>
> W: https://www.internedservices.nl | L: http://nl.linkedin.com/in/
> thijsstuurman
>
>
>
> *Van:* Openvas-discuss [mailto:openvas-discuss-bounces at wald.intevation.org]
> *Namens *CAMPBELL Jeremy
> *Verzonden:* donderdag 31 augustus 2017 16:13
> *Aan:* openvas-discuss at wald.intevation.org
> *Onderwerp:* [Openvas-discuss] Modifying task targets with omp [PUBLIC]
>
>
>
> Hi all,
>
>
>
> I have some systems in a dynamic cloud environment, and I’m trying to
> automate the maintenance of targets in OpenVAS.  In the past, I’ve used
> alterable tasks, periodically created an updated target group, and modified
> the task’s configuration to use that group.  I can programmatically create
> targets, but I don’t see a way to change the target group used by an
> alterable task.  Is it possible to change targets on a alterable task from
> the command line?  I’m open to doing something outside of omp if necessary.
>
>
>
> Thanks,
>
> JeremyThis message was classified *PUBLIC *by CAMPBELL Jeremy on
> Thursday, August 31, 2017 at 10:12:47 AM.
>
>
> ------------------------------
>
>
> This message, including attachments, is intended for the above-mentioned
> addressees only. It may contain confidential information the review,
> dissemination or disclosure of which is strictly prohibited. Should you
> receive this message in error, please delete it and notify the sender to
> the e-mail address indicated above.
> ------------------------------
>
>
>
> ---------- Message transféré ----------
> From: Jan-Oliver Wagner <Jan-Oliver.Wagner at greenbone.net>
> To: OpenVAS Announcement List <openvas-announce at wald.intevation.org>
> Cc:
> Bcc:
> Date: Thu, 10 Aug 2017 08:23:26 +0000
> Subject: [Openvas-announce] GVM-Tools
> Dear OpenVAS / Greenbone Users,
>
> we are happy to announce the availability of GVM-Tools. This is a
> collection of tools for remote controlling a OpenVAS / Greenbone
> setup and is intended to replace the "openvas-cli" module with
> its "omp" and "check_omp" command line tools.
>
> The new approach is comprised of interactive and non-interactive clients as
> well as supporting libraries. The programming language Python is supported
> directly for interactive scripting and library use. But it is also possible
> to issue remote GMP/OMP/OSP commands without programming in Python.
>
> The tools are compatible with the connection methods TLS, file socket
> and with the SSH GMP connection of Greenbone OS version 4. In other
> words, it can be used for any supported Greenbone OS version and for
> any supported OpenVAS version.
>
> The source code downloads are available from the usual place:
>
>   http://www.openvas.org/install-source.html
>
> We have prepared standalone binaris for Windows, including the
> Python environment making it unnecessary to install anything else.
> The latest versions are available as (*)
>
>   http://download.greenbone.net/tools/gvm-cli.exe
>   http://download.greenbone.net/tools/gvm-pyshell.exe
>
>
> GVM-Tools is Open Source under the GNU General Public License.
> The source code is currently managed at bitbucket where you can also
> find some examples how to use the tools in practice:
>
>   https://bitbucket.org/greenbone/gvm-tools
>
>
> (*) Checksums of version 1.2.0:
> SHA256 (gvm-cli.exe) =
> ca19227ba49a732f69717a395db14f08c3b2cc4c73fd00a4d81ab71c4ba4d04d
> SHA256 (gvm-pyshell.exe) =
> 1d487c9a4d449ea1e4a15ff2a9e2af4020b7f378101d5960b1709fbd50d459de
>
>
> Best regards
>
> --
> Dr. Jan-Oliver Wagner |  +49-541-760278-0  |  http://www.greenbone.net/
> Greenbone Networks GmbH, Neumarkt 12, 49074 Osnabrück | AG Osnabrück, HR B
> 202460
> Geschäftsführer: Lukas Grunwald, Dr. Jan-Oliver Wagner
> _______________________________________________
> Openvas-announce mailing list
> Openvas-announce at wald.intevation.org
> https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/
> openvas-announce
>
> _______________________________________________
> Openvas-discuss mailing list
> Openvas-discuss at wald.intevation.org
> https://lists.wald.intevation.org/cgi-bin/mailman/listinfo/openvas-discuss
>
>
> ------------------------------
>
> This message, including attachments, is intended for the above-mentioned
> addressees only. It may contain confidential information the review,
> dissemination or disclosure of which is strictly prohibited. Should you
> receive this message in error, please delete it and notify the sender to
> the e-mail address indicated above.
>
> ------------------------------
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wald.intevation.org/pipermail/openvas-discuss/attachments/20170831/a70ee8fe/attachment.html>


More information about the Openvas-discuss mailing list