Streamline Vulnerability Scanning with Ansible and Terrapin Scanner — Video Tutorial
Learn how to use Ansible to automate the deployment and execution of the Terrapin Vulnerability Scanner. This guide walks through an Ansible playbook designed to download, configure, and run the scanner, providing a practical approach to integrating vulnerability assessments into your IT workflows. Ideal for cybersecurity professionals looking to enhance their security practices with automation.
Watch Video
Watch "Streamline Vulnerability Scanning with Ansible and Terrapin Scanner" on YouTube
What You'll Learn
- Introduction
- Understanding the Ansible Playbook
- Explanation of the Playbook
- Execution
- Conclusion
- Related Articles
Full Tutorial Content
Introduction
In the rapidly evolving landscape of cybersecurity, regular vulnerability assessments are essential to identify and mitigate potential security risks. The Terrapin Vulnerability Scanner, developed by the RUB-NDS research group, offers a powerful tool for scanning and evaluating the security posture of systems. In this article, we explore how Ansible, a popular automation tool, can be leveraged to streamline the process of deploying and executing the Terrapin Scanner.
Understanding the Ansible Playbook
The provided Ansible playbook is a set of instructions written in YAML format, defining a sequence of tasks to be executed on remote hosts. Let’s break down the key components of the playbook:
```yaml
---
- name: Terrapin Vulnerability Scanner
hosts: all
gather_facts: false
vars:
scanner: "Terrapin_Scanner_MacOS_arm64_darwin"
target: "rhel.example.com"
version: "1.1.0"
myurl: "https://github.com/RUB-NDS/Terrapin-Scanner/releases/download/v{{ version }}/{{ scanner }}"
mydest: "./"
cli_params: "-json -connect {{ target }}"
tasks:
- name: Download the scanner
ansible.builtin.get_url:
url: "{{ myurl }}"
dest: "{{ mydest }}"
mode: '0644'
- name: Set scanner execution permission
ansible.builtin.file:
dest: "{{ mydest }}/{{ scanner }}"
mode: 'a+x'
- name: Execute the scanner
ansible.builtin.command: "{{ mydest }}/{{ scanner }} {{ cli_params }}"
register: command_output
- name: Print message on the screen
ansible.builtin.debug:
var: command_output
```
Explanation of the Playbook
- `hosts: all`: Specifies that the tasks will be executed on all hosts.
- `gather_facts: false`: Disables the gathering of facts about the target hosts. Facts include information about the system, such as IP address, OS version, etc.
- `vars`: Defines variables used throughout the playbook, such as the scanner name, target host, version, download URL, destination directory, and command-line parameters.
- `tasks`: Describes a series of tasks to be executed in order.
- Download the scanner: Uses the `get_url` Ansible module to download the Terrapin Scanner from the specified URL and save it to the destination directory.
- Set scanner execution permission: Uses the `file` Ansible module to set the execution permission for the downloaded scanner.
- Execute the scanner: Runs the Terrapin Scanner with the specified command-line parameters.
- Print message on the screen: Displays the output of the scanner execution for further analysis.
Execution
- localhost inventory
```bash
localhost ansible_connection=local
```
- Playbook Execution
```bash
ansible-playbook -i inventory terrapin.yml
```
- Output for a vulnerable OpenSSH connection
```bash
PLAY [Terrapin Vulnerability Scanner] ***************************************************
TASK [Download the scanner] *************************************************************
changed: [localh
About This Tutorial
- Author: Luca Berton
- Difficulty: Beginner
- Read time: 3 min
- Category: troubleshooting
Read the full written article: Streamline Vulnerability Scanning with Ansible and Terrapin Scanner
Topics Covered
Related Video Tutorials
- Ansible 2.17.0-rc1: Elevating Automation with ‘Gallows Pole’ — Ansible 2.17.0-rc1, codenamed "Gallows Pole," introduces critical updates including phasing out support for older Python versions, tightened security measures, and enhanced functionality. The release aims to streamline performance, boost security, and improve user experience, marking a significant advancement in the Ansible automation platform.
- Ansible-Lint: Complete Guide to Linting Playbooks & Roles — Complete guide to ansible-lint. Install, configure, run linting on playbooks and roles, fix common errors, and integrate with CI/CD pipelines.
- Ansible troubleshooting - Error internal-error — Learn how to troubleshoot and resolve internal errors in Ansible playbooks, including examples of problematic and corrected code to guide you through the process.
- Ansible Permission Denied (Errno 13): Fix File Access Errors — Fix Ansible Permission denied [Errno 13] errors. Resolve file permission, become/sudo, SELinux, and directory access issues with troubleshooting steps.
- Ansible 'Failure Downloading' Error: Fix get_url & uri Module Issues — Fix Ansible 'failure downloading' errors with get_url and uri modules. Covers SSL certificate issues, proxy settings, timeouts, and authentication for file downloads.
- Ansible 'fatal: template error while templating string' Fix (Guide) — Fix Ansible template error while templating string. Resolve undefined variables, syntax errors, and Jinja2 issues in playbooks and templates with examples.