OSP v1

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

class Osp
__init__(connection, *, transform=<function str_transform>)

Create a new GvmProtocol instance.

Parameters:
  • connection (GvmConnection) – Connection to use to talk with the remote daemon. See gvm.connections for possible connection types.

  • transform (Callable[[Response], T]) – Optional transform callable to convert response data. After each request the callable gets passed the plain response data which can be used to check the data and/or conversion into different representations like a xml dom.

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)

Delete a finished scan.

Parameters:

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

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

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 | None) – UUID identifier for a vulnerability test.

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 string command to the remote daemon and return the response as string

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 | None) – UUID identifier for a running scan.

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

  • target – Deprecated. Please use targets instead.

  • targets (list[dict[str, str]] | None) – List of dictionaries. See example.

  • ports – Deprecated. Ports to use for target parameter.

  • scanner_params: – Dictionary of scanner parameters.:

  • vt_selection: – Vulnerability tests to select. See example.:

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.