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

Add support for exporting replays as MP4 #199

Merged
merged 20 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ jobs:
run: sudo apt install python3-setuptools
- name: Install PyRDP dependencies
run: sudo apt install libdbus-1-dev libdbus-glib-1-dev libgl1-mesa-glx git python3-dev
- name: Install wheel
working-directory: .
run: pip install wheel
- name: Install PyRDP
working-directory: .
run: pip install -U -e .[full]
Expand Down Expand Up @@ -87,6 +90,9 @@ jobs:
run: python --version
- name: Pip version
run: pip --version
- name: Install wheel
working-directory: .
run: pip install wheel
- name: Install PyRDP
working-directory: .
run: pip install -U -e .[full]
Expand Down
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
python3-venv \
# Required to build RLE module and dbus-python (GUI)
build-essential python3-dev \
libdbus-1-dev \
libdbus-glib-1-dev
libdbus-1-dev libdbus-glib-1-dev

RUN python3 -m venv /opt/venv
# Make sure we use the virtualenv:
ENV PATH="/opt/venv/bin:$PATH"

# Install dependencies only (speeds repetitive builds)
COPY requirements.txt /pyrdp/requirements.txt
RUN cd /pyrdp && pip3 --no-cache-dir install -r requirements.txt
RUN cd /pyrdp && \
pip3 install wheel && \
pip3 --no-cache-dir install -r requirements.txt

# Compile only our C extension and install
# This way changes to source tree will not trigger full images rebuilds
Expand All @@ -41,6 +42,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends python3 \
# GUI and notifications stuff
libgl1-mesa-glx \
notify-osd dbus-x11 libxkbcommon-x11-0 \
# Runtime requirement by progressbar (required by pyrdp-convert)
python3-distutils \
&& rm -rf /var/lib/apt/lists/*

# Copy preinstalled dependencies from compile image
Expand Down
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ research use cases in mind.
+ [Cloning a certificate](#cloning-a-certificate)
+ [Using a custom private key](#using-a-custom-private-key)
+ [Other cloner arguments](#other-cloner-arguments)
* [Using PyRDP Convert](#using-pyrdp-convert)
* [Configuring PyRDP](#configuring-pyrdp)
* [Using PyRDP as a Library](#using-pyrdp-as-a-library)
* [Using PyRDP with twistd](#using-pyrdp-with-twistd)
Expand Down Expand Up @@ -435,6 +436,54 @@ pyrdp-clonecert.py 192.168.1.10 cert.pem -i input_key.pem
#### Other cloner arguments
Run `pyrdp-clonecert.py --help` for a full list of arguments.

### Using PyRDP Convert

`pyrdp-convert` is a helper script that performs several useful conversions. The script has the best chance of working
on traffic captured by PyRDP due to unsupported RDP protocol features that might be used in a non-intercepted
connection.

The following conversions are supported:

- Network Capture (PCAP) to PyRDP replay file
- Network Capture to MP4 video file
- Replay file to MP4 video file

The script supports both encrypted (TLS) network captures (by providing `--secrets ssl.log`) and decrypted PDU exports.

```
# Export the session coming client 10.2.0.198 to a .pyrdp file.
pyrdp-convert.py --src 10.2.0.198 --secrets ssl.log -o path/to/output capture.pcapng

# Or as an MP4 video
pyrdp-convert.py --src 10.2.0.198 --secrets ssl.log -o path/to/output -f mp4 capture.pcapng

# List the sessions in a network trace, along with the decryptable ones.
pyrdp-convert.py --list capture.pcapng
```

Note that MP4 conversion requires libavcodec and ffmpeg, so this may require extra steps on Windows.

Manually decrypted network traces can be exported from Wireshark by selecting `File > Export PDUs` and selecting `OSI
Layer 7`. When using this method, it is also recommended to filter the exported stream to only contain the TCP stream of
the RDP session which must be converted.

First, make sure you configured wireshark to load TLS secrets:

![Configure TLS secrets log](docs/screens/wireshark-tls.png)

Next, export OSI Layer 7 PDUs:

![Export OSI Layer 7](docs/screens/wireshark-export.png)

And lastly, filter down the trace to contain only the conversation of interest (Optional but recommended) by applying a
display filter and clicking `File > Export Specified Packets...`

![Filtering the exported trace](docs/screens/wireshark-export-specified.png)


Now this trace can be used directly in `pyrdp-convert`.


### Configuring PyRDP

Most of the PyRDP configurations are done through command line switches, but it is also possible to use a
Expand Down
Loading