From 955fa61852b20110e06e709ffa15272b11e233f0 Mon Sep 17 00:00:00 2001 From: Greg Edwards Date: Sat, 17 May 2014 16:27:24 -0400 Subject: [PATCH] Simple SSL proxy to help record the GenV battle video server --- pkmnFoundations.sln | 12 ++++++ sslProxy/Program.cs | 63 ++++++++++++++++++++++++++++ sslProxy/Properties/AssemblyInfo.cs | 36 ++++++++++++++++ sslProxy/iis private key.pfx | Bin 0 -> 2571 bytes sslProxy/sslProxy.csproj | 62 +++++++++++++++++++++++++++ 5 files changed, 173 insertions(+) create mode 100644 sslProxy/Program.cs create mode 100644 sslProxy/Properties/AssemblyInfo.cs create mode 100644 sslProxy/iis private key.pfx create mode 100644 sslProxy/sslProxy.csproj diff --git a/pkmnFoundations.sln b/pkmnFoundations.sln index dbfe8650..1019d59b 100644 --- a/pkmnFoundations.sln +++ b/pkmnFoundations.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "gts", "gts\gts.csproj", "{2 EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "bvCrawler4", "bvCrawler4\bvCrawler4.csproj", "{04E4EB3B-166B-4D8B-86AA-2178F2A927D5}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sslProxy", "sslProxy\sslProxy.csproj", "{50712E7D-EA8E-4B0D-A896-09008F819F42}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -71,6 +73,16 @@ Global {04E4EB3B-166B-4D8B-86AA-2178F2A927D5}.Release|Mixed Platforms.Build.0 = Release|x86 {04E4EB3B-166B-4D8B-86AA-2178F2A927D5}.Release|x86.ActiveCfg = Release|x86 {04E4EB3B-166B-4D8B-86AA-2178F2A927D5}.Release|x86.Build.0 = Release|x86 + {50712E7D-EA8E-4B0D-A896-09008F819F42}.Debug|Any CPU.ActiveCfg = Debug|x86 + {50712E7D-EA8E-4B0D-A896-09008F819F42}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {50712E7D-EA8E-4B0D-A896-09008F819F42}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {50712E7D-EA8E-4B0D-A896-09008F819F42}.Debug|x86.ActiveCfg = Debug|x86 + {50712E7D-EA8E-4B0D-A896-09008F819F42}.Debug|x86.Build.0 = Debug|x86 + {50712E7D-EA8E-4B0D-A896-09008F819F42}.Release|Any CPU.ActiveCfg = Release|x86 + {50712E7D-EA8E-4B0D-A896-09008F819F42}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {50712E7D-EA8E-4B0D-A896-09008F819F42}.Release|Mixed Platforms.Build.0 = Release|x86 + {50712E7D-EA8E-4B0D-A896-09008F819F42}.Release|x86.ActiveCfg = Release|x86 + {50712E7D-EA8E-4B0D-A896-09008F819F42}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/sslProxy/Program.cs b/sslProxy/Program.cs new file mode 100644 index 00000000..71109c6e --- /dev/null +++ b/sslProxy/Program.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Net.Sockets; +using System.Threading; +using System.IO; +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; +using System.Net; + +namespace sslProxy +{ + class Program + { + public static X509Certificate2 m_cert; + static void Main(string[] args) + { + TcpListener listener = new TcpListener(new IPAddress(new byte[]{10, 211, 55, 8}), 12401); + Directory.CreateDirectory("log"); + m_cert = new X509Certificate2("iis private key.pfx", "letmein"); + + // turn off cert validation entirely... + // http://stackoverflow.com/questions/777607/the-remote-certificate-is-invalid-according-to-the-validation-procedure-using + + listener.Start(); + Console.WriteLine("Waiting for connection..."); + while (true) + { + if (!listener.Pending()) + { + Thread.Sleep(5); + continue; + } + + BeginConversation(listener.AcceptTcpClient()); + } + } + + static void BeginConversation(TcpClient client) + { + Console.WriteLine("Received connection from {0}", client.Client.AddressFamily); + + SslStream sslClient = new SslStream(client.GetStream()); + sslClient.AuthenticateAsServer(m_cert); + + TcpClient server = new TcpClient("pkgdsprod.nintendo.co.jp", 12401); + SslStream sslServer = new SslStream(server.GetStream(), false, delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }); + sslServer.AuthenticateAsClient("pkgdsprod.nintendo.co.jp"); + + ThreadPool.QueueUserWorkItem(delegate(object state) + { + sslServer.CopyTo(sslClient); + }); + + ThreadPool.QueueUserWorkItem(delegate(object state) + { + sslClient.CopyTo(sslServer); + }); + + } + } +} diff --git a/sslProxy/Properties/AssemblyInfo.cs b/sslProxy/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..4e3c99f3 --- /dev/null +++ b/sslProxy/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("sslProxy")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("sslProxy")] +[assembly: AssemblyCopyright("Copyright © 2014")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9687ddd4-d6a0-47a0-9436-eb306d9d7833")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/sslProxy/iis private key.pfx b/sslProxy/iis private key.pfx new file mode 100644 index 0000000000000000000000000000000000000000..0b187427651f7c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W2nVu_wt;yYACK2qIRjqX{HLV9cN9+I~`lL)$@d!1;F@Dj7}eo1_lXey$41uKV%fbu9Q}e@HnpE7cbCc4W4!Rjh7v38OZSgMIbs*&X z5J_3*3dcqGJlBQ!@S6@5@tTweN^oZr*0q&&SW8OO3hrwQX|brGGUdLig>-AoM}& + + + Debug + x86 + 8.0.30703 + 2.0 + {50712E7D-EA8E-4B0D-A896-09008F819F42} + Exe + Properties + sslProxy + sslProxy + v4.0 + Client + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Always + + + + + \ No newline at end of file