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

Allow to specify listen address for pyrdp-mitm #412

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions bin/pyrdp-mitm.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ def main():
except Exception:
logger.warning('Unable to set transparent socket. Are you running as root?')

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

message = "MITM Server listening on 0.0.0.0:%(port)d"
params = {"port": config.listenPort}
message = "MITM Server listening on %(address)s:%(port)d"
params = {"address": config.listenAddress, "port": config.listenPort}

if "HOST_IP" in os.environ:
message += ". Host IP: %(host_ip)s"
Expand Down
2 changes: 2 additions & 0 deletions pyrdp/mitm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def showConfiguration(config: MITMConfig):
def buildArgParser():
parser = argparse.ArgumentParser()
parser.add_argument("target", help="IP:port of the target RDP machine (ex: 192.168.1.10:3390)", nargs='?', default=None)
parser.add_argument("-a", "--address", help="Address to listen on (default: 0.0.0.0)", default="0.0.0.0")
parser.add_argument("-l", "--listen", help="Port number to listen on (default: 3389)", default=3389)
parser.add_argument("-o", "--output", help="Output folder", default="pyrdp_output")
parser.add_argument("-i", "--destination-ip",
Expand Down Expand Up @@ -181,6 +182,7 @@ def configure(cmdline=None) -> MITMConfig:
config.targetHost = targetHost
config.targetPort = targetPort
config.privateKeyFileName = key
config.listenAddress = args.address
config.listenPort = int(args.listen)
config.certificateFileName = certificate
config.attackerHost = args.destination_ip
Expand Down
3 changes: 3 additions & 0 deletions pyrdp/mitm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def __init__(self):
self.targetPort: int = None
"""The RDP server's port"""

self.listenAddress: str = "0.0.0.0"
"""The address to listen on."""

self.listenPort: int = 3389
"""The port to bind for listening."""

Expand Down