Integrating OpenVAS into my Django project using the Greenbone Management Protocol (GMP) to perform vulnerability scans

I’m currently working on integrating OpenVAS into my Django project using the Greenbone Management Protocol (GMP) to perform vulnerability scans. I’ve established an SSH connection to the OpenVAS server and can send XML commands to create targets and tasks, as well as start scans. However, I’m looking for a more streamlined approach, possibly using a Python library like gvm-tools or python-gvm , to interact with OpenVAS through GMP. I’d appreciate any advice or examples on how to effectively use these libraries for creating targets with SSH credentials, initiating scans, and retrieving scan results in a Django application. Here’s a snippet of my current approach:

class OpenVAS:
def init(self, hostname, username, password, port, gvm_cli_path, gmp_username, gmp_password):
# SSH connection setup

def run_command(self, command):
    # Send XML command to OpenVAS

def start_scan(self, target):
    # Create target, create task, and start scan

def get_task_status(self, task_id):
    # Check the status of a task

Example usage

openvas = OpenVAS(hostname=“192.168.1.44”, username=“ubuntu”, password=“ubuntu”, port=22, gvm_cli_path=“/home/ubuntu/.local/bin/gvm-cli”, gmp_username=“admin”, gmp_password=“admin”)
target_ip = “192.168.1.44”
task_id = openvas.start_scan(target_ip)
status = openvas.get_task_status(task_id)

Hi,

please format your code accordingly to Start Here - #3 by bricks It’s very difficult to read at the moment.

I am not sure what you are asking for. Did you create GMP XML by yourself and ask if there is a better approach? If that’s the case, yes just use python-gvm.

2 Likes

hi
i have aprobleme with the gmp username and password when i send a command from djangoto gvm it cant work because of the authentification of gmp usage: gvm-cli [-h] [-c [CONFIG]] [--log [{DEBUG,INFO,WARNING,ERROR,CRITICAL}]] [--timeout TIMEOUT] [--gmp-username GMP_USERNAME] [--gmp-password GMP_PASSWORD] [-V] [--protocol {GMP,OSP}] CONNECTION_TYPE ...
using GVM CLI