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)