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

File naming #272

Merged
merged 18 commits into from
Jan 4, 2021
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
113 changes: 64 additions & 49 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,52 +35,56 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax.
architecture: 'x64'

- name: Python version
run: python --version
- name: Pip version
run: pip --version

- name: Install setuptools
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]

- name: Install ci dependencies
run: pip install -r requirements-ci.txt

- name: Extract test files
uses: DuckSoft/extract-7z-action@v1.0
with:
pathSource: test/files/test_files.zip
pathTarget: test/files

- name: Integration Test with a prerecorded PCAP.
working-directory: ./
run: coverage run test/test_prerecorded.py

- name: pyrdp-mitm.py initialization integration test
working-directory: ./
run: coverage run --append test/test_mitm_initialization.py dummy_value

- name: pyrdp-player.py read a replay in headless mode test
working-directory: ./
run: coverage run --append bin/pyrdp-player.py --headless test/files/test_session.replay

- name: Coverage
working-directory: ./
run: coverage report --fail-under=40
- uses: actions/checkout@v2
- uses: actions/setup-python@v1
with:
python-version: '3.7' # Version range or exact version of a Python version to use, using semvers version range syntax.
architecture: 'x64'

- name: Python version
run: python --version
- name: Pip version
run: pip --version

- name: Install setuptools
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]

- name: Install ci dependencies
run: pip install -r requirements-ci.txt

- name: Extract test files
uses: DuckSoft/extract-7z-action@v1.0
with:
pathSource: test/files/test_files.zip
pathTarget: test/files

- name: Integration Test with a prerecorded PCAP.
working-directory: ./
run: coverage run test/test_prerecorded.py

- name: pyrdp-mitm.py initialization integration test
working-directory: ./
run: coverage run --append test/test_mitm_initialization.py dummy_value

- name: pyrdp-player.py read a replay in headless mode test
working-directory: ./
run: coverage run --append bin/pyrdp-player.py --headless test/files/test_session.replay

- name: Run unit tests
working-directory: ./
run: coverage run --append -m unittest discover -v

- name: Coverage report
working-directory: ./
run: coverage report --fail-under=40



Expand All @@ -104,6 +108,9 @@ jobs:
- name: Install PyRDP
working-directory: .
run: pip install -U -e .[full]
- name: Install coverage
working-directory: .
run: pip install coverage

- name: Extract test files
uses: DuckSoft/extract-7z-action@v1.0
Expand All @@ -113,12 +120,20 @@ jobs:

- name: Integration Test with a prerecorded PCAP.
working-directory: ./
run: python test/test_prerecorded.py
run: coverage run test/test_prerecorded.py

- name: pyrdp-mitm.py initialization test
working-directory: ./
run: python test/test_mitm_initialization.py dummy_value
run: coverage run --append test/test_mitm_initialization.py dummy_value

- name: pyrdp-player.py read a replay in headless mode test
working-directory: ./
run: python bin/pyrdp-player.py --headless test/files/test_session.replay
run: coverage run --append bin/pyrdp-player.py --headless test/files/test_session.replay

- name: Run unit tests
working-directory: ./
run: coverage run --append -m unittest discover -v

- name: Coverage report
working-directory: ./
run: coverage report --fail-under=40
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ mitm.json

# twisted
/twisted/plugins/dropin.cache

# code coverage
htmlcov/
2 changes: 1 addition & 1 deletion bin/pyrdp-convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def sendBytesStub(_: bytes):
# We'll set up the recorder ourselves
config.recordReplays = False

state = RDPMITMState(config)
state = RDPMITMState(config, log.sessionID)

sink, outfile = getSink(format, output_path)
transport = ConversionLayer(sink) if sink else FileLayer(outfile)
Expand Down
10 changes: 6 additions & 4 deletions pyrdp/mitm/ClipboardMITM.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from pyrdp.enum import ClipboardFormatNumber, ClipboardMessageFlags, ClipboardMessageType, PlayerPDUType, FileContentsFlags
from pyrdp.layer import ClipboardLayer
from pyrdp.logging.StatCounter import StatCounter, STAT
from pyrdp.mitm.state import RDPMITMState
from pyrdp.pdu import ClipboardPDU, FormatDataRequestPDU, FormatDataResponsePDU, FileContentsRequestPDU, FileContentsResponsePDU
from pyrdp.parser.rdp.virtual_channel.clipboard import FileDescriptor
from pyrdp.recording import Recorder
Expand All @@ -32,7 +33,7 @@ class PassiveClipboardStealer:
"""

def __init__(self, config: MITMConfig, client: ClipboardLayer, server: ClipboardLayer, log: LoggerAdapter, recorder: Recorder,
statCounter: StatCounter):
statCounter: StatCounter, state: RDPMITMState):
"""
:param client: clipboard layer for the client side
:param server: clipboard layer for the server side
Expand All @@ -44,13 +45,14 @@ def __init__(self, config: MITMConfig, client: ClipboardLayer, server: Clipboard
self.server = server
self.config = config
self.log = log
self.state = state
self.recorder = recorder
self.forwardNextDataResponse = True
self.files = []
self.transfers = {}
self.timeouts = {} # Track active timeout monitoring tasks.

self.fileDir = f"{self.config.fileDir}/{self.log.sessionID}"
self.fileDir = f"{self.config.fileDir}/{self.state.sessionID}"

self.client.createObserver(
onPDUReceived = self.onClientPDUReceived,
Expand Down Expand Up @@ -206,8 +208,8 @@ class ActiveClipboardStealer(PassiveClipboardStealer):
"""

def __init__(self, config: MITMConfig, client: ClipboardLayer, server: ClipboardLayer, log: LoggerAdapter, recorder: Recorder,
statCounter: StatCounter):
super().__init__(config, client, server, log, recorder, statCounter)
statCounter: StatCounter, state: RDPMITMState):
super().__init__(config, client, server, log, recorder, statCounter, state)

def handlePDU(self, pdu: ClipboardPDU, destination: ClipboardLayer):
"""
Expand Down
Loading