OSP v1#

Module for communication to a daemon speaking Open Scanner Protocol version 1

class gvm.protocols.ospv1.Osp#
__init__(connection, *, transform=None)#
connect()#

Initiates a protocol connection

Normally connect is not called directly. Either it is called automatically when sending a protocol command or when using a with statement.

delete_scan(scan_id=None)#

Delete a finished scan.

Parameters:

scan_id (str) – UUID identifier for a finished scan.

Returns:

Response from server.

Return type:

str

disconnect()#

Disconnect the connection

Ends and closes the connection.

static get_protocol_version()#

Determine the Open Scanner Protocol version.

Returns:

Implemented version of the Open Scanner Protocol

Return type:

tuple

get_scanner_details()#

Return scanner description and parameters.

get_scans(scan_id=None, details=True, pop_results=False)#

Get the stored scans.

Parameters:
  • scan_id (str, optional) – UUID identifier for a scan.

  • details (boolean, optional) – Whether to get full scan reports. Default: True

  • pop_results (boolean, optional) – results. Default: False

Returns:

Response from server.

Return type:

str

get_version()#

Get the version of the OSPD server which is connected to.

get_vts(vt_id=None)#

Return information about vulnerability tests, if offered by scanner.

Parameters:

vt_id (str, optional) – UUID identifier for a vulnerability test.

Returns:

Response from server.

Return type:

str

help()#

Get the help text.

is_connected()#

Status of the current connection

Returns:

True if a connection to the remote server has been established.

Return type:

bool

send_command(cmd)#

Send a command to the remote server

If the class is not connected to the server yet the connection will be established automatically.

Parameters:

cmd (str) – Command as string to be send over the connection to the server.

Returns:

The actual returned type depends on the set transform.

Per default - if no transform is set explicitly - the response is returned as string.

Return type:

any

start_scan(scan_id=None, parallel=1, target=None, ports=None, targets=None, scanner_params=None, vt_selection=None)#

Start a new scan.

Parameters:
  • scan_id (str, optional) – UUID identifier for a running scan.

  • parallel (int, optional) – Number of parallel scanned targets. Default 1.

  • target (dict, optional) – Deprecated. Please use targets instead.

  • targets (list, optional) – List of dictionaries. See example.

  • ports (str, optional) – Deprecated. Ports to use for target parameter.

  • scanner_params – (dict, optional): Dictionary of scanner parameters.

  • vt_selection – (dict, optional): Vulnerability tests to select. See example.

Returns:

Response from server.

Return type:

str

Examples

Scanner Parameters:

scanner_parameters = {
    'scan_param1': 'scan_param1_value',
    'scan_param2': 'scan_param2_value',
}

Targets:

targets = [{
    'hosts': 'localhost',
    'ports': '80,43'
}, {
    'hosts': '192.168.0.0/24',
    'ports': '22',
}, {
    'credentials': {
        'smb': {
            'password': 'pass',
            'port': 'port',
            'type': 'type',
            'username': 'username',
        }
    }
}]

VT Selection:

vt_selection = {
    'vt1': {},
    'vt2': {'value_id': 'value'},
    'vt_groups': ['family=debian', 'family=general']
}
stop_scan(scan_id)#

Stop a currently running scan.

Parameters:

scan_id (str) – UUID identifier for a running scan.

Returns:

Response from server.

Return type:

str