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

Add a warning log message to keep track of bluekeep scanning/exploits attempts #114

Merged
merged 5 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
12 changes: 9 additions & 3 deletions pyrdp/mitm/MCSMITM.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (C) 2019 GoSecure Inc.
# Licensed under the GPLv3 or later.
#

from logging import LoggerAdapter
from typing import Callable, Dict

from pyrdp.enum import ClientCapabilityFlag, EncryptionLevel, EncryptionMethod, HighColorDepth, MCSChannelName, \
Expand All @@ -27,15 +27,18 @@ class MCSMITM:
external callback for building MCS channels when a join request is accepted.
"""

def __init__(self, client: MCSLayer, server: MCSLayer, state: RDPMITMState, recorder: Recorder, buildChannelCallback: Callable[[MCSServerChannel, MCSClientChannel], None]):
def __init__(self, client: MCSLayer, server: MCSLayer, state: RDPMITMState, recorder: Recorder,
buildChannelCallback: Callable[[MCSServerChannel, MCSClientChannel], None], log: LoggerAdapter):
"""
:param client: MCS layer for the client side
:param server: MCS layer for the server side
:param state: the RDP MITM shared state
:param recorder: the recorder for this session
:param buildChannelCallback: function called when MCS channels are built
:param log: logger for the MCS layer.
"""

self.log = log
self.client = client
self.server = server
self.state = state
Expand Down Expand Up @@ -76,8 +79,9 @@ def onConnectInitial(self, pdu: MCSConnectInitialPDU):
rdpClientConnectionParser = ClientConnectionParser()
gccConferenceCreateRequestPDU: GCCConferenceCreateRequestPDU = gccParser.parse(pdu.payload)

# FIPS is not implemented, so remove this flag if it's set
rdpClientDataPDU = rdpClientConnectionParser.parse(gccConferenceCreateRequestPDU.payload)

# FIPS is not implemented, so remove this flag if it's set
rdpClientDataPDU.securityData.encryptionMethods &= ~EncryptionMethod.ENCRYPTION_FIPS
rdpClientDataPDU.securityData.extEncryptionMethods &= ~EncryptionMethod.ENCRYPTION_FIPS

Expand All @@ -102,6 +106,8 @@ def onConnectInitial(self, pdu: MCSConnectInitialPDU):

if rdpClientDataPDU.networkData:
self.state.channelDefinitions = rdpClientDataPDU.networkData.channelDefinitions
if "MS_T120" in map(lambda channelDef: channelDef.name, rdpClientDataPDU.networkData.channelDefinitions):
self.log.info("Bluekeep (CVE-2019-0708) scan or exploit attempt detected.", {"bluekeep": True})

serverGCCPDU = GCCConferenceCreateRequestPDU("1", rdpClientConnectionParser.write(rdpClientDataPDU))
serverMCSPDU = MCSConnectInitialPDU(
Expand Down
2 changes: 1 addition & 1 deletion pyrdp/mitm/mitm.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def __init__(self, log: SessionLogger, config: MITMConfig):
self.x224 = X224MITM(self.client.x224, self.server.x224, self.getLog("x224"), self.state, serverConnector, self.startTLS)
"""X224 MITM component"""

self.mcs = MCSMITM(self.client.mcs, self.server.mcs, self.state, self.recorder, self.buildChannel)
self.mcs = MCSMITM(self.client.mcs, self.server.mcs, self.state, self.recorder, self.buildChannel, self.getLog("mcs"))
"""MCS MITM component"""

self.security: SecurityMITM = None
Expand Down