Guest User

JoinBlackistedMinecraftServers Source Code

a guest
May 11th, 2016
488
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using Fiddler;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Runtime.InteropServices;
  8. using System.Security.Permissions;
  9. using System.Text;
  10.  
  11. namespace JoinBlacklistedMinecraftServers
  12. {
  13.     class Program
  14.     {
  15.         private enum CtrlType
  16.         {
  17.             CTRL_BREAK_EVENT = 1,
  18.             CTRL_C_EVENT = 0,
  19.             CTRL_CLOSE_EVENT = 2,
  20.             CTRL_LOGOFF_EVENT = 5,
  21.             CTRL_SHUTDOWN_EVENT = 6
  22.         }
  23.  
  24.         private delegate bool ConsoleCtrlEvent(CtrlType sig);
  25.         private static ConsoleCtrlEvent ConsoleCtrlEventHandler;
  26.         [DllImport("Kernel32")]
  27.         private static extern bool SetConsoleCtrlHandler(Program.ConsoleCtrlEvent handler, bool add);
  28.         [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)]
  29.  
  30.         static void Main(string[] args)
  31.         {
  32.             Console.Title = "JoinBlacklistedMinecraftServers";
  33.             Console.CancelKeyPress += Console_CancelKeyPress;
  34.  
  35.             Program.ConsoleCtrlEventHandler = (ConsoleCtrlEvent)Delegate.Combine(Program.ConsoleCtrlEventHandler, new Program.ConsoleCtrlEvent(Program.ConsoleCloseEvent));
  36.             Program.SetConsoleCtrlHandler(Program.ConsoleCtrlEventHandler, true);
  37.  
  38.             Logger.WriteLine("Made by isokissa3", ConsoleColor.Yellow);
  39.             Logger.WriteLine("YOU MAY NEED RUN THIS AS ADMINISTRATOR!", ConsoleColor.Red);
  40.  
  41.             Logger.Write("Creating FiddlerCore cert... ");
  42.             if (!Fiddler.CertMaker.rootCertExists())
  43.             {
  44.                 if (!Fiddler.CertMaker.createRootCert())
  45.                 {
  46.                     Console.WriteLine("Unable to create cert for FiddlerCore.");
  47.                     return;
  48.                 }
  49.             }
  50.             Logger.WriteLine("done!", ConsoleColor.Green);
  51.  
  52.             Logger.Write("Installing FiddlerCore cert... ");
  53.             if (!Fiddler.CertMaker.rootCertIsTrusted())
  54.             {
  55.                 if (!Fiddler.CertMaker.trustRootCert())
  56.                 {
  57.                     Console.WriteLine("Unable to install FiddlerCore's cert.");
  58.                     return;
  59.                 }
  60.             }
  61.             Logger.WriteLine("done!", ConsoleColor.Green);
  62.  
  63.             Logger.Write("Writing FiddlerCore cert in the file... ");
  64.             File.WriteAllBytes("cert.cer", Fiddler.CertMaker.GetRootCertificate().Export(System.Security.Cryptography.X509Certificates.X509ContentType.Cert, ""));
  65.             Logger.WriteLine("done!", ConsoleColor.Green);
  66.  
  67.             Logger.Write("Removing previous cert... ");
  68.             Process.Start("cmd.exe", "/c \"\"C:\\Program Files (x86)\\Minecraft\\runtime\\jre-x64\\1.8.0_25\\bin\\keytool.exe\" -delete -keystore \"C:\\Program Files (x86)\\Minecraft\\runtime\\jre-x64\\1.8.0_25\\lib\\security\\cacerts\" -alias Fiddler -noprompt -storepass changeit\"").WaitForExit();
  69.             Logger.WriteLine("done!", ConsoleColor.Green);
  70.  
  71.             Logger.Write("Adding the new cert... ");
  72.             Process.Start("cmd.exe", "/c \"\"C:\\Program Files (x86)\\Minecraft\\runtime\\jre-x64\\1.8.0_25\\bin\\keytool.exe\" -import -file \"" + Path.GetFullPath("cert.cer") + "\" -keystore \"C:\\Program Files (x86)\\Minecraft\\runtime\\jre-x64\\1.8.0_25\\lib\\security\\cacerts\" -alias Fiddler -noprompt -storepass changeit\"").WaitForExit();
  73.             Logger.WriteLine("done!", ConsoleColor.Green);
  74.  
  75.             Logger.Write("Starting the proxy... ");
  76.             FiddlerApplication.BeforeRequest += FiddlerApplication_BeforeRequest;
  77.             FiddlerApplication.Startup(8888, false, true, false);
  78.             Logger.WriteLine("done!", ConsoleColor.Green);
  79.             Logger.WriteLine("READY!", ConsoleColor.Green);
  80.  
  81.             while (true)
  82.             {
  83.                 string command = Console.ReadLine();
  84.                 if (command == "shutdown" || command == "stop")
  85.                 {
  86.                     FiddlerApplication.Shutdown();
  87.                     Environment.Exit(0);
  88.                 }
  89.             }
  90.         }
  91.  
  92.         private static bool ConsoleCloseEvent(CtrlType sig)
  93.         {
  94.             FiddlerApplication.Shutdown();
  95.             return true;
  96.         }
  97.  
  98.         static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
  99.         {
  100.             FiddlerApplication.Shutdown();
  101.         }
  102.  
  103.         static void FiddlerApplication_BeforeRequest(Session oSession)
  104.         {
  105.             if (oSession.fullUrl == "https://sessionserver.mojang.com/blockedservers")
  106.             {
  107.                 oSession.utilCreateResponseAndBypassServer();
  108.             }
  109.         }
  110.     }
  111. }
RAW Paste Data