Skip to content

muse0x19e/programmatic-vulnerability-remediations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

27 Commits
Β 
Β 
Β 
Β 

Repository files navigation

Programmatic Vulnerability Remediations on Linux

Automate vulnerability remediation with scripting (Bash)

Vulnerability Management Lab (Azure + Tenable)

This lab demonstrates how to provision a Linux VM in Azure, perform vulnerability scanning using Tenable with DISA STIG compliance, introduce vulnerabilities intentionally, and apply automated remediation using bash scripts.

tenable


Table of Contents

πŸš€ Step 1: Provision a Linux VM in Azure

  • Select a secure Linux distribution (e.g., Ubuntu 22.04 LTS).
  • Avoid using default credentials like labuser/Cyberlab123!.

image

  • Configure the VM with:

    • Password authentication (for lab only)
    • Public IP enabled
    • NSG rules allowing SSH (port 22)
    • OS Disk type: Standard HDD

    image

⚠️ Do not leave weak passwords or root access open β€” past labs have been breached due to exposed cloud VMs.

πŸ”’ Authentication

  • Default method is SSH key pair.
  • For lab purposes, set a strong password, but remember to delete the VM after testing.

πŸ”§ Step 2: Configure Network & Access

  • In Azure, make sure your Network Security Group (NSG) includes:

    • Inbound Rule: SSH (TCP/22)
    • Inbound Rule: ICMP (Ping)
    • Inbound Rule: Telnet (TCP/23) β€” temporarily for testing

image

⚠️ Only open Telnet for lab use and close it immediately after validation.


πŸ“± Step 3: Test Connectivity

After VM is deployed and running:

ping <vm-public-ip>
ssh <username>@<vm-public-ip>

Make sure:

  • VM is reachable

image

  • SSH login is successful

image


πŸ” Step 4: Initial Vulnerability Scan with Tenable

  • Log in to cloud.tenable.com
  • Create a new authenticated scan (Scan1)
  • Use the Linux DISA STIG compliance template

image

  • Scanner Type:

    • Use Internal Engine
  • Set scan target to the internal IP of the VM

  • Provide valid SSH credentials

  • Launch the scan

  • Export results (PDF or CSV)

image

Scan 1 Report - Baseline


πŸ§ͺ Step 5: Introduce Vulnerabilities

Login to your VM using SSH, then:

5.1 Install Insecure Telnet Service

sudo apt update
sudo apt install telnetd -y
sudo systemctl enable inetd.service
sudo systemctl start inetd.service
sudo systemctl status inetd.service

image

⚠️ Telnet is insecure and should be removed after testing.

5.2 Enable Root Login over SSH

sudo grep -q '^PermitRootLogin' /etc/ssh/sshd_config && \
  sudo sed -i 's/^PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config || \
  echo 'PermitRootLogin yes' | sudo tee -a /etc/ssh/sshd_config

sudo systemctl restart sshd

5.3 Set Insecure Root Password

sudo passwd root
# Enter password: root

⚠️ After enabling root, destroy or disable the VM immediately post-testing. Previous labs were compromised via open root logins.


πŸ”„ Step 6: Second Vulnerability Scan

  • Launch a second authenticated scan after introducing vulnerabilities

image

  • Validate findings:

    • Unencrypted Telnet service
    • Insecure root credentials

image

  • Export the results

Scan 2 - Vulnerbility Detection


🧰 Step 7: Run Remediation Scripts

Use provided bash scripts to remediate each finding.

7.1 Remediate Default Root Password

πŸ”— GitHub Script – Root Password

7.2 Remediate OpenSSL 3.0.5

πŸ”— GitHub Script – OpenSSL

image

7.3 Remove Telnet Service

πŸ”— GitHub Script – Telnet

image

πŸ›  How to run the scripts:

chmod +x scriptname.sh
sudo ./scriptname.sh
image image

πŸ”„ Step 8: Final Scan & Validation

  • Reboot the VM:
sudo reboot
  • Run a final authenticated scan in Tenable

  • Confirm:

    • Telnet is removed
    • Root password is changed
    • OpenSSL is updated (if applicable)

image

  • Export final scan results

Scan 3 Report - Remediated


🧹 Step 9: Clean Up

Delete the VM to prevent exposure or costs:


πŸ“Š Summary

Stage Task
βœ… Linux VM provisioned in Azure
βœ… NSG rules configured
βœ… Tenable baseline scan (Scan 1)
βœ… Vulnerabilities introduced
βœ… Second scan performed (Scan 2)
βœ… Remediation scripts executed
βœ… Final scan (Scan 3) and validation
βœ… VM deleted

πŸ”— References

πŸ” This lab simulates an enterprise workflow of provision β†’ assess β†’ harden β†’ validate.

About

Automate vulnerability remediation with scripting (PowerShell+Bash)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published