Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Fiddler;
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Security.Permissions;
- using System.Text;
- namespace JoinBlacklistedMinecraftServers
- {
- class Program
- {
- private enum CtrlType
- {
- CTRL_BREAK_EVENT = 1,
- CTRL_C_EVENT = 0,
- CTRL_CLOSE_EVENT = 2,
- CTRL_LOGOFF_EVENT = 5,
- CTRL_SHUTDOWN_EVENT = 6
- }
- private delegate bool ConsoleCtrlEvent(CtrlType sig);
- private static ConsoleCtrlEvent ConsoleCtrlEventHandler;
- [DllImport("Kernel32")]
- private static extern bool SetConsoleCtrlHandler(Program.ConsoleCtrlEvent handler, bool add);
- [SecurityPermission(SecurityAction.Demand, Flags = SecurityPermissionFlag.ControlAppDomain)]
- static void Main(string[] args)
- {
- Console.Title = "JoinBlacklistedMinecraftServers";
- Console.CancelKeyPress += Console_CancelKeyPress;
- Program.ConsoleCtrlEventHandler = (ConsoleCtrlEvent)Delegate.Combine(Program.ConsoleCtrlEventHandler, new Program.ConsoleCtrlEvent(Program.ConsoleCloseEvent));
- Program.SetConsoleCtrlHandler(Program.ConsoleCtrlEventHandler, true);
- Logger.WriteLine("Made by isokissa3", ConsoleColor.Yellow);
- Logger.WriteLine("YOU MAY NEED RUN THIS AS ADMINISTRATOR!", ConsoleColor.Red);
- Logger.Write("Creating FiddlerCore cert... ");
- if (!Fiddler.CertMaker.rootCertExists())
- {
- if (!Fiddler.CertMaker.createRootCert())
- {
- Console.WriteLine("Unable to create cert for FiddlerCore.");
- return;
- }
- }
- Logger.WriteLine("done!", ConsoleColor.Green);
- Logger.Write("Installing FiddlerCore cert... ");
- if (!Fiddler.CertMaker.rootCertIsTrusted())
- {
- if (!Fiddler.CertMaker.trustRootCert())
- {
- Console.WriteLine("Unable to install FiddlerCore's cert.");
- return;
- }
- }
- Logger.WriteLine("done!", ConsoleColor.Green);
- Logger.Write("Writing FiddlerCore cert in the file... ");
- File.WriteAllBytes("cert.cer", Fiddler.CertMaker.GetRootCertificate().Export(System.Security.Cryptography.X509Certificates.X509ContentType.Cert, ""));
- Logger.WriteLine("done!", ConsoleColor.Green);
- Logger.Write("Removing previous cert... ");
- 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();
- Logger.WriteLine("done!", ConsoleColor.Green);
- Logger.Write("Adding the new cert... ");
- 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();
- Logger.WriteLine("done!", ConsoleColor.Green);
- Logger.Write("Starting the proxy... ");
- FiddlerApplication.BeforeRequest += FiddlerApplication_BeforeRequest;
- FiddlerApplication.Startup(8888, false, true, false);
- Logger.WriteLine("done!", ConsoleColor.Green);
- Logger.WriteLine("READY!", ConsoleColor.Green);
- while (true)
- {
- string command = Console.ReadLine();
- if (command == "shutdown" || command == "stop")
- {
- FiddlerApplication.Shutdown();
- Environment.Exit(0);
- }
- }
- }
- private static bool ConsoleCloseEvent(CtrlType sig)
- {
- FiddlerApplication.Shutdown();
- return true;
- }
- static void Console_CancelKeyPress(object sender, ConsoleCancelEventArgs e)
- {
- FiddlerApplication.Shutdown();
- }
- static void FiddlerApplication_BeforeRequest(Session oSession)
- {
- if (oSession.fullUrl == "https://sessionserver.mojang.com/blockedservers")
- {
- oSession.utilCreateResponseAndBypassServer();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement