Exemple #1
0
def main():
    config = configure()
    logger = logging.getLogger(LOGGER_NAMES.PYRDP)

    # Create a listening socket to accept connections.
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setblocking(0)

    if config.transparent:
        try:
            if not s.getsockopt(socket.SOL_IP, socket.IP_TRANSPARENT):
                s.setsockopt(socket.SOL_IP, socket.IP_TRANSPARENT, 1)
                s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
        except Exception:
            logger.warning('Unable to set transparent socket. Are you running as root?')

    s.bind(('0.0.0.0', config.listenPort))
    s.listen()  # Non-blocking.
    reactor.adoptStreamPort(s.fileno(), socket.AF_INET, MITMServerFactory(config))
    s.close()  # reactor creates a copy of the fd.

    logger.info("MITM Server listening on port %(port)d", {"port": config.listenPort})

    reactor.run()

    logger.info("MITM terminated")
    showConfiguration(config)
Exemple #2
0
def main():
    config = configure()
    reactor.listenTCP(config.listenPort, MITMServerFactory(config))
    logger = logging.getLogger(LOGGER_NAMES.PYRDP)

    logger.info("MITM Server listening on port %(port)d",
                {"port": config.listenPort})
    reactor.run()

    logger.info("MITM terminated")
    showConfiguration(config)
Exemple #3
0
 def parseOptions(self, args):
     self['config'] = configure(args)
#!/usr/bin/python3

#
# This file is part of the PyRDP project.
# Copyright (C) 2020 GoSecure Inc.
# Licensed under the GPLv3 or later.
#
"""
Integration test for the initialization of pyrdp-mitm.py.
It could be enhanced with relevant assertions but for now only executes the code to catch
potential basic errors/import problems.
"""
from pyrdp.core.mitm import MITMServerFactory
from pyrdp.mitm.cli import configure

if __name__ == "__main__":
    config = configure()
    server_factory = MITMServerFactory(config)
    server_factory.buildProtocol(addr=None)