Giter Club home page Giter Club logo

pyvas's Introduction

pyvas: OMPv7 for Python

Build Status Coverage

An OpenVAS Managment Protocol (OMP) v7+ client for Python.

Installation

To install pyvas, simply run:

$ pip install pyvas

Usage

>>> from pyvas import Client
>>> with Client(hostname, username='username', password='password') as cli:
>>>     r = cli.list_tasks()
>>>     r.ok
True
>>>     r.data
[{u'@id': '...', ...}, {u'@id': '...', ...}]
>>>     r = cli.get_task(task[0]["@id"])
>>>     r.ok
True
>>>     r.data
{u'@id': '...', ...}

Documentation

Documentation is currently a work in progress, please check back soon.

How to Contribute

  1. Look for open issues or report an issue
  2. Checkout a new branch from master and work away
  3. Remember to include tests
  4. Submit a pull request!

pyvas's People

Contributors

adpham95 avatar an9er avatar csanders-git avatar mpicard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pyvas's Issues

TLS connection warnings

library works great so far!
I'm receiving warnings in my log on each connection though, something to consider.

md   main:WARNING:2017-09-05 19h17.15 UTC:1639: read_from_client_tls: failed to read from client: The TLS connection was non-properly terminated.

create schedule: format first_time

Hello,

I'm trying to create a new schedule using the following syntax:

first_time = datetime.now() + timedelta(hours=random.randrange(1, 23, 1), days=1)
with Client('X.X.X.X', username='XXXXXX, password='XXXXXXXXXX') as cli:
    r = cli.create_schedule(name,
                            first_time=first_time.strftime("%Y-%m-%dT%H:%M:%S+02:00"),
                            duration=1,
                            duration_unit='day',
                            period=1,
                            period_unit='day',
                            timezone='Europe/Rome')
    r.ok

but it seems to use the current time.

>>> with Client('X.X.X.X', username='XXXXXX', password='XXXXXXXXx') as cli:
...   r = cli.list_schedules()
...   r.ok
... 
True
>>> print(r.data)
[{'timezone': 'Europe/Rome', 'comment': None, 'first_time': '2019-05-13T13:23:00+02:00', 'duration': '86400', 'period': '86400', 'simple_duration': {'unit': 'day', '#text': '1'}, 'period_months': '0', 'timezone_abbrev': 'CEST', 'owner': {'name': 'admin'}, 'permissions': {'permission': {'name': 'Everything'}}, 'in_use': '1', '@id': '662769bf-549b-49bb-9036-b61fa6156a65', 'writable': '1', 'simple_period': {'unit': 'day', '#text': '1'}, 'name': 'cnaf_192.135.24.10', 'modification_time': '2019-05-13T11:23:19Z', 'next_time': '2019-05-14T13:23:00+02:00', 'creation_time': '2019-05-13T11:23:19Z', 'user_tags': {'count': '0'}}]
>>> 

which format should I use in order to define the right first_time parameter

thanks

cli.create_task(name) missing 2 required possitional arguments

Hello.I have the following function that I want to use to create a task


def foo(name):
  with Client(host,username,password) as cli:
    cli.create_task(name)

However when calling this function I get the following:

cli.create_task(name) missing 2 required possitional arguments config_uuid and target_uuid`

Any ideas how to fix that

Improper Python source encoding definitions.

https://www.python.org/dev/peps/pep-0263/

Noticed the use of encoding definitions in each file is a bit varied and doesn't have uniformity across the project and in some cases violates the standard.

Usage:
# coding: utf-8 or # -*- coding: utf-8 -*-

A minor thing, but something that jumped out to me. Great project by the way, was about to build this myself then stumbled across this Python3-friendly repo. Just wish it was more active :)

Client error 400 target is in use

Hello.I face a situation in which I have to delete a target however I get the error "Target is in use".

Any ideas why this is happening?

why do I have to use with

I noticed that in your examples I have to do with Client() as cli.However I tried to do the following:


cli = Client(host="localhost",username="foo",password="bar")
cli.list_tasks()

This however throws an error telling me TypeError: File or filename expected, got 'NoneType'.

Any ideas why this is happening?

Usage doesn't work

from pyvas import client
with client(hostname, username='username', password='password') as cli:
r = cli.list_tasks()
r.ok

TypeError: 'module' object is not callable

It should be :

from pyvas import *
with Client(hostname, username='username', password='password') as cli:

OR:

import pyvas
with pyvas.Client("127.0.0.1", username='admin', password='123123') as cli:

Running tests

I'm having trouble running the tests. I've got it to the point where I can run pytest on it, but it fails. I have a working OpenVAS instance and the host I'm trying to run the tests on can talk to it successfully with omp. I wonder if you have any advice on getting this to run successfully please?

This is what I get when I run it with python3 -m pytest from a fresh clone of your repo.
results.txt

Thanks!

Anna

TypeError: File or filename expected, got 'NoneType'

Getting the following error on r.start_task('9cd5fe25-756a-41e5-8b28-735cd799cd8e')

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pyvas/client.py", line 261, in delete_task
    return self._delete("task", uuid=uuid)
  File "/usr/local/lib/python2.7/dist-packages/pyvas/client.py", line 426, in _delete
    return self._command(request)
  File "/usr/local/lib/python2.7/dist-packages/pyvas/client.py", line 367, in _command
    resp = self._send_request(request)
  File "/usr/local/lib/python2.7/dist-packages/pyvas/client.py", line 435, in _send_request
    root.write(self.socket, encoding="utf-8")
  File "src/lxml/lxml.etree.pyx", line 2033, in lxml.etree._ElementTree.write (src/lxml/lxml.etree.c:67992)
  File "src/lxml/serializer.pxi", line 512, in lxml.etree._tofilelike (src/lxml/lxml.etree.c:144286)
  File "src/lxml/serializer.pxi", line 571, in lxml.etree._create_output_buffer (src/lxml/lxml.etree.c:145007)
  File "src/lxml/serializer.pxi", line 566, in lxml.etree._create_output_buffer (src/lxml/lxml.etree.c:144948)
TypeError: File or filename expected, got 'NoneType'

download pdf report

Hi

I tried to download a report in pdf format
I get a string.

with Client('10.1.100.1', username='User', password='password') as cli:
...   t = cli.download_report('114d74d8-55d6-4f9e-959b-529a5209f753', format_uuid='c402cc3e-b531-11e1-9163-406186ea4fc5')

 type(t)
<class 'str'>

what can I do with that string ?

thanks in advance

Ale

how to get all the vulnerabilities from the pyvas report

I am able to read a report using PyVAS, the reports = cli.list_reports() returns all the available reports, I'm traversing through each one of them reports.data[i]['report']['results']['result'] and I see only 10 of the vulnerabilities, how do I get all of them using PyVAS?

Connect to omp client running on a different host on the network

Hello.I am in an office in which we have a vm running OpenVas.
My question is whether I can connect to the omp client running in that vm from a different machine.

I tried to use the following code

HOST='an ip address'
with Client(host=HOST,username='username',password='password') as cli:
    cli.list_tasks()

however I get a Connection timedout error(Errno 110).

Any ideas if that's possible?
If it is I would appreciate a code snippet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.