-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from GoSecure/twistd-support
Added a twisted plugin
- Loading branch information
Showing
8 changed files
with
337 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,6 @@ docs/*.html | |
|
||
# pyrdp-specific | ||
pyrdp_output/ | ||
|
||
# twisted | ||
/twisted/plugins/dropin.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# | ||
# This file is part of the PyRDP project. | ||
# Copyright (C) 2020 GoSecure Inc. | ||
# Licensed under the GPLv3 or later. | ||
# | ||
import logging | ||
import random | ||
|
||
from twisted.internet.protocol import ServerFactory | ||
import names | ||
|
||
from pyrdp.mitm import MITMConfig, RDPMITM | ||
from pyrdp.logging import LOGGER_NAMES, SessionLogger | ||
|
||
|
||
class MITMServerFactory(ServerFactory): | ||
""" | ||
Server factory for the RDP man-in-the-middle that generates a unique session ID for every connection. | ||
""" | ||
|
||
def __init__(self, config: MITMConfig): | ||
""" | ||
:param config: the MITM configuration | ||
""" | ||
self.config = config | ||
|
||
def buildProtocol(self, addr): | ||
sessionID = f"{names.get_first_name()}{random.randrange(100000,999999)}" | ||
|
||
# mainLogger logs in a file and stdout | ||
mainlogger = logging.getLogger(LOGGER_NAMES.MITM_CONNECTIONS) | ||
mainlogger = SessionLogger(mainlogger, sessionID) | ||
|
||
# crawler logger only logs to a file for analysis purposes | ||
crawlerLogger = logging.getLogger(LOGGER_NAMES.CRAWLER) | ||
crawlerLogger = SessionLogger(crawlerLogger, sessionID) | ||
|
||
mitm = RDPMITM(mainlogger, crawlerLogger, self.config) | ||
|
||
return mitm.getProtocol() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.