Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zerologon password reset warning #998

Merged
merged 27 commits into from
Mar 2, 2021
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b5b8d28
cc: add a note about resetting password after failed zerologon attempt
mssalvatore Feb 24, 2021
b6bb6d8
cc: format exploiter_classes.py with black
mssalvatore Feb 24, 2021
36bd983
agent: add zerologon password restore success/failure to telemetry
mssalvatore Feb 24, 2021
4fbb0f2
ui: add machine-related recommendation for Zerologon to security report
mssalvatore Feb 24, 2021
70fd7d7
cc: add password_restore_success to zerologon report issue
mssalvatore Feb 24, 2021
f17c08d
cc,agent: rename password_restore_success -> password_restored
mssalvatore Feb 24, 2021
3da1de3
Add Zerologon (and Drupal) information to "Immediate Threats"
shreyamalviya Feb 25, 2021
6581a5a
Add warning to machine-specific recommendation if password was not reset
shreyamalviya Feb 25, 2021
8b7e0d0
Added ZeroLogon overview section to the report
VakarisZ Feb 25, 2021
94ac75e
Improved zero logon overview UI and added password restoration warnin…
VakarisZ Feb 25, 2021
67fd171
report: rename ZEROLOGON_CRED_RESTORE_FAILED -> ZEROLOGON_PASSWORD_RE…
mssalvatore Feb 25, 2021
e9b84ff
Improved zero logon exploiter to fail on failed domain controller nam…
VakarisZ Feb 25, 2021
ce697b3
Improved exception handling of expected exceptions - if they are expe…
VakarisZ Feb 25, 2021
c0d2d5b
Fix typo, remove unused import, change function/variable names for co…
shreyamalviya Feb 25, 2021
2f99631
Fix unit tests
shreyamalviya Feb 26, 2021
f094c3e
docs: Add warnings and password restoration instructions for Zerologon
mssalvatore Feb 28, 2021
5e088e6
docs: minor rewording in zerologon docs
mssalvatore Feb 28, 2021
abc76e0
docs: add missing comma on zerologon docs
mssalvatore Feb 28, 2021
b3e9922
Changed the logic of zerologon password restoration issue overview to…
VakarisZ Mar 1, 2021
8eeed20
Changed zerologon links to be more consistent and have a style
VakarisZ Mar 1, 2021
e49b7b8
Improved formatting and link styles in SecurityReport.js
VakarisZ Mar 1, 2021
9171ed8
Minor formatting improvements in SecurityReport.js
VakarisZ Mar 1, 2021
9e3fe03
Replace double quotes with single quotes in SecurityReport.js
VakarisZ Mar 1, 2021
ac530b2
cc: reword zerologon exploiter class info
mssalvatore Mar 1, 2021
89907d1
Improved warning icon display style in the overview
VakarisZ Mar 2, 2021
6babcd0
Change warning order and phrasing in report
shreyamalviya Mar 2, 2021
5f66a99
Consider non-threat issues when calculating threat count
shreyamalviya Mar 2, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 54 additions & 6 deletions docs/content/reference/exploiters/Zerologon.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,67 @@ tags: ["exploit", "windows"]

The Zerologon exploiter exploits [CVE-2020-1472](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2020-1472).

This exploiter is unsafe.
* It will temporarily change the target domain controller's password.
* It may break the target domain controller's communication with other systems in the network, affecting functionality.

It is, therefore, **not** enabled by default.


### Description

An elevation of privilege vulnerability exists when an attacker establishes a vulnerable Netlogon secure channel connection to a domain controller, using the Netlogon Remote Protocol (MS-NRPC).

To download the relevant security update and read more, click [here](https://msrc.microsoft.com/update-guide/en-US/vulnerability/CVE-2020-1472).

### A note on safety

This exploiter is not safe for production or other sensitive environments. It
is, therefore, **not** enabled by default.

During successful exploitation, the Zerologon exploiter:

* will temporarily change the target domain controller's password.
* may break the target domain controller's communication with other systems in the network, affecting functionality.
* may change the administrator's password.
* will *attempt* to revert all changes.

While the Zerologon exploiter is usually successful in reverting its changes
and restoring the original passwords, it sometimes fails. Restoring passwords
manually after the Zerologon exploiter has run is nontrivial. For information
on restoring the original passwords see the section on manually restoring your
passwords.

To minimize the risk posed by this exploiter, it is recommended that this
exploiter be run _only_ against VMs with a recent snapshot and _only_ in
testing or staging environments.


### Manually restoring your password

This exploiter attempts to restore the original passwords after exploitation.
It is usually successful, but it sometimes fails. If this exploiter has changed
a password but was unable to restore the original, you can try the following
methods to restore the original password.

#### Restore the VM from a recent snapshot

If the affected system is a virtual machine, the simplest way to restore it to
a working state is to revert to a recent snapshot.

#### Restore the administrator's password

If you are unable to log in as the administrator, you can follow the
instructions
[here](https://www.top-password.com/knowledge/reset-windows-server-2019-password.html)
to regain access to the system.

#### Use Reset-ComputerMachinePassword

If you are able to login as the administrator, you can use the
[Reset-ComputerMachinePassword](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/reset-computermachinepassword?view=powershell-5.1)
powershell command to restore the domain controller's password.


#### Try a zerologon password restoration tool
If all other approaches have failed, you can try the tools and steps found
[here](https://github.com/risksense/zerologon).



### Notes

Expand Down
4 changes: 4 additions & 0 deletions monkey/common/utils/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ class VersionServerConnectionError(Exception):

class FindingWithoutDetailsError(Exception):
""" Raise when pulling events for a finding, but get none """


class DomainControllerNameFetchError(FailedExploitationError):
""" Raise on failed attempt to extract domain controller's name """
4 changes: 2 additions & 2 deletions monkey/infection_monkey/exploit/HostExploiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def exploit_host(self):
result = None
try:
result = self._exploit_host()
except FailedExploitationError:
logger.debug('Exploiter failed.', exc_info=True)
except FailedExploitationError as e:
logger.debug(f'Exploiter failed: {e}.')
except Exception:
logger.error('Exception in exploit_host', exc_info=True)
finally:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest
from nmb.NetBIOS import NetBIOS

from common.utils.exceptions import DomainControllerNameFetchError
from infection_monkey.exploit.zerologon_utils.vuln_assessment import \
get_dc_details
from infection_monkey.model.host import VictimHost
Expand Down Expand Up @@ -38,8 +39,5 @@ def test_get_dc_details_no_netbios_names(host, monkeypatch):

stub_queryIPForName = _get_stub_queryIPForName(NETBIOS_NAMES)
monkeypatch.setattr(NetBIOS, "queryIPForName", stub_queryIPForName)

dc_ip, dc_name, dc_handle = get_dc_details(host)
assert dc_ip == IP
assert dc_name == ""
assert dc_handle == "\\\\"
with pytest.raises(DomainControllerNameFetchError):
dc_ip, dc_name, dc_handle = get_dc_details(host)
3 changes: 3 additions & 0 deletions monkey/infection_monkey/exploit/zerologon.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(self, host: object):
super().__init__(host)
self.vulnerable_port = None
self.exploit_info["credentials"] = {}
self.exploit_info["password_restored"] = None
self._extracted_creds = {}

def _exploit_host(self) -> bool:
Expand All @@ -62,9 +63,11 @@ def _exploit_host(self) -> bool:
# Restore DC's original password.
if _exploited:
if self.restore_password():
self.exploit_info["password_restored"] = True
self.store_extracted_creds_for_exploitation()
LOG.info("System exploited and password restored successfully.")
else:
self.exploit_info["password_restored"] = False
LOG.info("System exploited but couldn't restore password!")
else:
LOG.info("System was not exploited.")
Expand Down
21 changes: 13 additions & 8 deletions monkey/infection_monkey/exploit/zerologon_utils/vuln_assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import nmb.NetBIOS
from impacket.dcerpc.v5 import nrpc, rpcrt

from common.common_consts.timeouts import MEDIUM_REQUEST_TIMEOUT
from common.utils.exceptions import DomainControllerNameFetchError

LOG = logging.getLogger(__name__)


Expand All @@ -18,14 +21,16 @@ def _get_dc_name(dc_ip: str) -> str:
"""
Gets NetBIOS name of the Domain Controller (DC).
"""
try:
nb = nmb.NetBIOS.NetBIOS()
name = nb.queryIPForName(
ip=dc_ip
) # returns either a list of NetBIOS names or None
return name[0] if name else ""
except BaseException as ex:
LOG.info(f"Exception: {ex}")
nb = nmb.NetBIOS.NetBIOS()
name = nb.queryIPForName(
ip=dc_ip,
timeout=MEDIUM_REQUEST_TIMEOUT
) # returns either a list of NetBIOS names or None

if name:
return name[0]
else:
raise DomainControllerNameFetchError("Couldn't get domain controller's name, maybe it's on external network?")


def is_exploitable(zerologon_exploiter_object) -> (bool, Optional[rpcrt.DCERPC_v5]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,166 +2,142 @@

EXPLOITER_CLASSES = {
"title": "Exploit class",
"description": "Click on exploiter to get more information about it." + WARNING_SIGN +
" Note that using unsafe exploits may cause crashes of the exploited machine/service.",
"description": "Click on exploiter to get more information about it."
+ WARNING_SIGN
+ " Note that using unsafe exploits may cause crashes of the exploited machine/service.",
"type": "string",
"anyOf": [
{
"type": "string",
"enum": [
"SmbExploiter"
],
"enum": ["SmbExploiter"],
"title": "SMB Exploiter",
"safe": True,
"attack_techniques": ["T1110", "T1075", "T1035"],
"info": "Brute forces using credentials provided by user and"
" hashes gathered by mimikatz.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/smbexec/"
" hashes gathered by mimikatz.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/smbexec/",
},
{
"type": "string",
"enum": [
"WmiExploiter"
],
"enum": ["WmiExploiter"],
"title": "WMI Exploiter",
"safe": True,
"attack_techniques": ["T1110", "T1106"],
"info": "Brute forces WMI (Windows Management Instrumentation) "
"using credentials provided by user and hashes gathered by mimikatz.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/wmiexec/"
"using credentials provided by user and hashes gathered by mimikatz.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/wmiexec/",
},
{
"type": "string",
"enum": [
"MSSQLExploiter"
],
"enum": ["MSSQLExploiter"],
"title": "MSSQL Exploiter",
"safe": True,
"attack_techniques": ["T1110"],
"info": "Tries to brute force into MsSQL server and uses insecure "
"configuration to execute commands on server.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/mssql/"
"configuration to execute commands on server.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/mssql/",
},
{
"type": "string",
"enum": [
"Ms08_067_Exploiter"
],
"enum": ["Ms08_067_Exploiter"],
"title": "MS08-067 Exploiter",
"safe": False,
"info": "Unsafe exploiter, that might cause system crash due to the use of buffer overflow. "
"Uses MS08-067 vulnerability.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/ms08-067/"
"Uses MS08-067 vulnerability.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/ms08-067/",
},
{
"type": "string",
"enum": [
"SSHExploiter"
],
"enum": ["SSHExploiter"],
"title": "SSH Exploiter",
"safe": True,
"attack_techniques": ["T1110", "T1145", "T1106"],
"info": "Brute forces using credentials provided by user and SSH keys gathered from systems.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/sshexec/"
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/sshexec/",
},
{
"type": "string",
"enum": [
"ShellShockExploiter"
],
"enum": ["ShellShockExploiter"],
"title": "ShellShock Exploiter",
"safe": True,
"info": "CVE-2014-6271, based on logic from "
"https://github.com/nccgroup/shocker/blob/master/shocker.py .",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/shellshock/"
"https://github.com/nccgroup/shocker/blob/master/shocker.py .",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/shellshock/",
},
{
"type": "string",
"enum": [
"SambaCryExploiter"
],
"enum": ["SambaCryExploiter"],
"title": "SambaCry Exploiter",
"safe": True,
"info": "Bruteforces and searches for anonymous shares. Uses Impacket.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/sambacry/"
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/sambacry/",
},
{
"type": "string",
"enum": [
"ElasticGroovyExploiter"
],
"enum": ["ElasticGroovyExploiter"],
"title": "ElasticGroovy Exploiter",
"safe": True,
"info": "CVE-2015-1427. Logic is based on Metasploit module.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/elasticgroovy/"
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/elasticgroovy/",
},
{
"type": "string",
"enum": [
"Struts2Exploiter"
],
"enum": ["Struts2Exploiter"],
"title": "Struts2 Exploiter",
"safe": True,
"info": "Exploits struts2 java web framework. CVE-2017-5638. Logic based on "
"https://www.exploit-db.com/exploits/41570 .",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/struts2/"
"https://www.exploit-db.com/exploits/41570 .",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/struts2/",
},
{
"type": "string",
"enum": [
"WebLogicExploiter"
],
"enum": ["WebLogicExploiter"],
"title": "WebLogic Exploiter",
"safe": True,
"info": "Exploits CVE-2017-10271 and CVE-2019-2725 vulnerabilities on WebLogic server.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/weblogic/"
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/weblogic/",
},
{
"type": "string",
"enum": [
"HadoopExploiter"
],
"enum": ["HadoopExploiter"],
"title": "Hadoop/Yarn Exploiter",
"safe": True,
"info": "Remote code execution on HADOOP server with YARN and default settings. "
"Logic based on https://github.com/vulhub/vulhub/tree/master/hadoop/unauthorized-yarn.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/hadoop/"
"Logic based on https://github.com/vulhub/vulhub/tree/master/hadoop/unauthorized-yarn.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/hadoop/",
},
{
"type": "string",
"enum": [
"VSFTPDExploiter"
],
"enum": ["VSFTPDExploiter"],
"title": "VSFTPD Exploiter",
"safe": True,
"info": "Exploits a malicious backdoor that was added to the VSFTPD download archive. "
"Logic based on Metasploit module.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/vsftpd/"
"Logic based on Metasploit module.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/vsftpd/",
},
{
"type": "string",
"enum": [
"DrupalExploiter"
],
"enum": ["DrupalExploiter"],
"title": "Drupal Exploiter",
"safe": True,
"info": "Exploits a remote command execution vulnerability in a Drupal server,"
"for which certain modules (such as RESTful Web Services) are enabled.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/drupal/"
"for which certain modules (such as RESTful Web Services) are enabled.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/drupal/",
},
{
"type": "string",
"enum": [
"ZerologonExploiter"
],
"enum": ["ZerologonExploiter"],
"title": "Zerologon Exploiter",
"safe": False,
"info": "Exploits a privilege escalation vulnerability (CVE-2020-1472) in a Windows "
"server domain controller by using the Netlogon Remote Protocol (MS-NRPC). "
"This exploiter changes the password of a Windows server domain controller "
"account and could prevent the victim domain controller from communicating "
"with other domain controllers.",
"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/zerologon/"
}
]
"server domain controller by using the Netlogon Remote Protocol (MS-NRPC). "
"This exploiter changes the password of a Windows server domain controller "
"account and could prevent the victim domain controller from communicating "
"with other domain controllers. While it attempts to undo "
"its changes and reset the password back to the original after the "
"vulnerability is exploited, this is not successful in all cases. For "
"instructions on how to reset the domain controller's password, see the documentation.",
Copy link
Contributor Author

@VakarisZ VakarisZ Mar 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"account and could prevent the victim domain controller from communicating "
"with other domain controllers. While it attempts to undo "
"its changes and reset the password back to the original after the "
"vulnerability is exploited, this is not successful in all cases. For "
"instructions on how to reset the domain controller's password, see the documentation.",
"account and then attempts to restore it. Victim domain controller can't communicate "
"with other domain controllers until the password is restored. If the Infection Monkey fails to "
"restore the password automatically, you'll have to do it manually. For more information see the "
"documentation.",

"link": "https://www.guardicore.com/infectionmonkey/docs/reference/exploiters/zerologon/",
},
],
}
Loading