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 a CI and a basic integration test #194

Merged
merged 19 commits into from
Mar 25, 2020
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
24 changes: 24 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[run]
branch = True
include =
pyrdp/*
twisted/*
bin/*

[report]
# Regexes for lines to exclude from consideration
exclude_lines =
# Have to re-enable the standard pragma
pragma: no cover

# Don't complain about missing debug-only code:
def __repr__

# Don't complain if tests don't hit defensive assertion code:
raise AssertionError
raise NotImplementedError

# Don't complain if non-runnable code isn't run:
if 0:

ignore_errors = True
69 changes: 69 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Continuous Integration

on: [push, pull_request]

jobs:
docker-build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Build Docker image
run: docker build .

install-and-test-ubuntu:
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 PyRDP
working-directory: .
run: pip install -U -e .
Res260 marked this conversation as resolved.
Show resolved Hide resolved

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

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

- name: Coverage
run: coverage report --fail-under=50



install-and-test-windows:
runs-on: windows-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 PyRDP
working-directory: .
run: pip install -U -e .

- name: Integration Test with a prerecorded PCAP.
working-directory: ./
run: python test/test.py
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
*.pyd
venv*/
/*.prof
.coverage

# Zip the pcap instead
*.pcap

# IDE stuff
.project
Expand Down
9 changes: 5 additions & 4 deletions pyrdp/mitm/RDPMITM.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,16 @@
from pyrdp.mitm.TCPMITM import TCPMITM
from pyrdp.mitm.VirtualChannelMITM import VirtualChannelMITM
from pyrdp.mitm.X224MITM import X224MITM
from pyrdp.recording import FileLayer, RecordingFastPathObserver, RecordingSlowPathObserver
from pyrdp.recording import FileLayer, RecordingFastPathObserver, RecordingSlowPathObserver, \
Recorder


class RDPMITM:
"""
Main MITM class. The job of this class is to orchestrate the components for all the protocols.
"""

def __init__(self, mainLogger: SessionLogger, crawlerLogger: SessionLogger, config: MITMConfig):
def __init__(self, mainLogger: SessionLogger, crawlerLogger: SessionLogger, config: MITMConfig, state: RDPMITMState=None, recorder: Recorder=None):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: this is duplicated from another active PR

"""
:param log: base logger to use for the connection
:param config: the MITM configuration
Expand All @@ -72,7 +73,7 @@ def __init__(self, mainLogger: SessionLogger, crawlerLogger: SessionLogger, conf
self.statCounter = StatCounter()
"""Class to keep track of connection-related statistics such as # of mouse events, # of output events, etc."""

self.state = RDPMITMState(config)
self.state = state if state is not None else RDPMITMState(self.config)
"""The MITM state"""

self.client = RDPLayerSet()
Expand All @@ -84,7 +85,7 @@ def __init__(self, mainLogger: SessionLogger, crawlerLogger: SessionLogger, conf
self.player = TwistedPlayerLayerSet()
"""Layers on the attacker side"""

self.recorder = MITMRecorder([], self.state)
self.recorder = recorder if recorder is not None else MITMRecorder([], self.state)
"""Recorder for this connection"""

self.channelMITMs = {}
Expand Down
1 change: 1 addition & 0 deletions requirements-ci.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
'PySide2',
'pytz',
'rsa',
'scapy',
'service_identity',
'twisted',
'dbus-python;platform_system!="Windows"',
Expand Down
Empty file added test/__init__.py
Empty file.
Binary file added test/files/test_session.zip
Binary file not shown.
Loading