You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PurpleDome/plugins/default/vulnerabilities/linux_sshd_config/linux_sshd_config_issues.py

45 lines
1.3 KiB
Python

#!/usr/bin/env python3
# Some users are created (with weak passwords) and sshd is set to allow password-based access
from plugins.base.vulnerability_plugin import VulnerabilityPlugin
class SshdVulnerability(VulnerabilityPlugin):
# Boilerplate
name = "sshd_config_vul"
description = "Allowing passwords based sshd access"
ttp = "T1110"
references = ["https://attack.mitre.org/techniques/T1110/"]
required_files = [] # Files shipped with the plugin which are needed by the machine. Will be copied to the share
def __init__(self):
super().__init__()
self.plugin_path = __file__
def start(self):
# allow password access via ssh
cmd = "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config"
print(cmd)
self.run_cmd(cmd)
# Restart ssh
cmd = "sudo service ssh restart"
print(cmd)
self.run_cmd(cmd)
def stop(self):
# Re-configure sshd to stable state
cmd = "sudo sed -i 's/PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh/sshd_config"
print(cmd)
self.run_cmd(cmd)
# Restart ssh
cmd = "sudo service ssh restart"
print(cmd)
self.run_cmd(cmd)