GoSecure / pyrdp

RDP monster-in-the-middle (mitm) and library for Python with the ability to watch connections live or after the fact
https://www.gosecure.net/blog/2020/10/20/announcing-pyrdp-1/
GNU General Public License v3.0
1.55k stars 250 forks source link

pyrdp-convert: Fails to extract replay with multiple connections in PCAP #221

Closed alxbl closed 3 years ago

alxbl commented 4 years ago

We ran into a bug where the master secret is not found when there are multiple different connections from the same source in the same trace:

[*] Analyzing network trace...
    - CLIENT -> SERVER: unknown master secret
    - CLIENT -> SERVER: master secret available (!)
    - CLIENT -> SERVER: unknown master secret
    - CLIENT -> SERVER: master secret available (!)
    - SERVER -> CLIENT: master secret available (!)
Traceback (most recent call last):
  File "./pyrdp-convert.py", line 378, in <module>
    main()
  File "./pyrdp-convert.py", line 342, in main
    streams.append((info, decrypted(stream, secrets[rnd]['master'])))
KeyError: ''

Looks like rnd is an empty string...

            rnd = findClientRandom(stream)
            if rnd not in self.secrets and rnd != '':
                print(' unknown master secret')
            else:
                print(' master secret available (!)')
                streams.append((info, decrypted(stream, self.secrets[rnd]['master'])))

I think this might be a TLS version issue between MITM - SERVER.

A work around might be specifying --src CLIENT.

xshill commented 3 years ago

I'm gonna work on this to make it more reliable. Here's some changes I would like to make to fully support multiple connections in a single pcap:

xshill commented 3 years ago

The output system hasn't been changed yet, I focused on refactoring it and fixing packet reconstruction. I'll move the output changes to another issue.