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

Exception on disconnect after file transfers #322

Closed
obilodeau opened this issue Jul 16, 2021 · 1 comment · Fixed by #333
Closed

Exception on disconnect after file transfers #322

obilodeau opened this issue Jul 16, 2021 · 1 comment · Fixed by #333
Labels
bug Something isn't working
Milestone

Comments

@obilodeau
Copy link
Collaborator

obilodeau commented Jul 16, 2021

I transferred a couple of files from a mapped drive first then from the clipboard. I also transferred a directory from the clipboard. When closing the connection, I got this:

Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python3.9/asyncio/base_events.py", line 596, in run_forever
    self._run_once()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 1890, in _run_once
    handle._run()
  File "/usr/lib/python3.9/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/venv/lib/python3.9/site-packages/twisted/internet/asyncioreactor.py", line 272, in _onTimer
    self.runUntilCurrent()
--- <exception caught here> ---
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/venv/lib/python3.9/site-packages/twisted/internet/base.py", line 999, in runUntilCurrent
    call.func(*call.args, **call.kw)
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/venv/lib/python3.9/site-packages/twisted/internet/tcp.py", line 506, in connectionLost
    self._commonConnection.connectionLost(self, reason)
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/venv/lib/python3.9/site-packages/twisted/internet/tcp.py", line 324, in connectionLost
    protocol.connectionLost(reason)
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/venv/lib/python3.9/site-packages/twisted/protocols/tls.py", line 394, in connectionLost
    ProtocolWrapper.connectionLost(self, reason)
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/venv/lib/python3.9/site-packages/twisted/protocols/policies.py", line 111, in connectionLost
    self.wrappedProtocol.connectionLost(reason)
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/pyrdp/layer/tcp.py", line 68, in connectionLost
    self.observer.onDisconnection(reason)
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/pyrdp/core/observer.py", line 82, in __call__
    self.composite.doCall(self.item, args, kwargs)
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/pyrdp/core/observer.py", line 56, in doCall
    getattr(observer, item)(*args, **kwargs)
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/pyrdp/mitm/DeviceRedirectionMITM.py", line 118, in onDisconnection
    mapping.onDisconnection(reason)
  File "/home/olivier/pyrdp-bh2021-demo/pyrdp/pyrdp/mitm/FileMapping.py", line 92, in onDisconnection
    Path(self.file.name).unlink(missing_ok=True)
  File "/usr/lib/python3.9/pathlib.py", line 1072, in __new__
    self = cls._from_parts(args, init=False)
  File "/usr/lib/python3.9/pathlib.py", line 697, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "/usr/lib/python3.9/pathlib.py", line 681, in _parse_args
    a = os.fspath(a)
builtins.TypeError: expected str, bytes or os.PathLike object, not int

Note that PyRDP keeps working and seem to have recorded everything correctly.

@obilodeau obilodeau added the bug Something isn't working label Jul 16, 2021
@obilodeau obilodeau added this to the v1.1.0 milestone Jul 16, 2021
@obilodeau
Copy link
Collaborator Author

Managed to reproduce with debug logs:

[2021-08-03 10:46:27,521] - DEBUG - Tracy269134 - pyrdp.mitm.connections.server.rdpdr - Received DeviceQueryDirectoryRequestPDU{'payload': b'', 'component': <DeviceRedirectionComponent.RDPDR_CTYP_CORE: 17522>, 'packetID': <DeviceRedirectionPacketID.PAKID_CORE_DEVICE_IOREQUEST: 18770>, 'deviceID': 2, 'fileID': 23, 'completionID': 5, 'majorFunction': <MajorFunction.IRP_MJ_DIRECTORY_CONTROL: 12>, 'minorFunction': <MinorFuncti
[...]
[2021-08-03 10:46:27,527] - DEBUG - Tracy269134 - pyrdp.mitm.connections.server.rdpdr - Received DeviceQueryDirectoryRequestPDU{'payload': b'', 'component': <DeviceRedirectionComponent.RDPDR_CTYP_CORE: 17522>, 'packetID': <DeviceRedirectionPacketID.PAKID_CORE_DEVICE_IOREQUEST: 18770>, 'deviceID': 2, 'fileID': 23, 'completionID': 5, 'majorFunction': <MajorFunction.IRP_MJ_DIRECTORY_CONTROL: 12>, 'minorFunction': <MinorFunction.IRP_MN_QUERY_DIRECTORY: 1>, 'informationClass': <FileSystemInformationClass.FileBothDirectoryInformation: 3>, 'initialQuery': 0, 'path': ''}
[...]
[2021-08-03 10:46:27,534] - DEBUG - Tracy269134 - pyrdp.mitm.connections.server.rdpdr - Received DeviceCloseRequestPDU{'payload': b'', 'component': <DeviceRedirectionComponent.RDPDR_CTYP_CORE: 17522>, 'packetID': <DeviceRedirectionPacketID.PAKID_CORE_DEVICE_IOREQUEST: 18770>, 'deviceID': 2, 'fileID': 23, 'completionID': 5, 'majorFunction': <MajorFunction.IRP_MJ_CLOSE: 2>, 'minorFunction': 0}
[...]
[2021-08-03 10:46:43,918] - DEBUG - Tracy269134 - pyrdp.mitm.connections.rdpdr - Closing and trying to delete '23'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant