Skip to content

Instantly share code, notes, and snippets.

@Lonegwadiwaitor
Last active November 21, 2021 12:43
Show Gist options
  • Save Lonegwadiwaitor/266246650087860e85e6291ff8b1c4fe to your computer and use it in GitHub Desktop.
Save Lonegwadiwaitor/266246650087860e85e6291ff8b1c4fe to your computer and use it in GitHub Desktop.
Automatically downgrade from Roblox "beta" builds to the latest release version
using System;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net;
using Microsoft.Win32;
namespace beta_removal
{
class Program
{
static void Main(string[] args)
{
using var wc = new WebClient();
// first, get the location of the "Roblox" folder
// usually at %localappdata%\Roblox but its best to make sure
var robloxFolder = String.Join("\\", ((string)Registry.ClassesRoot.OpenSubKey("roblox-player\\shell\\open\\command", true).GetValue(null))
.Split('\\').SkipLast(1)).Replace("\"", ""); // what a mess
if (robloxFolder.Contains("Program Files") &&
!(new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator)))
{
Console.WriteLine("Your ROBLOX folder is located in \"C:\\Program Files (x86)\" which requires admin rights to access\nPlease restart the program as Administrator");
Console.ReadKey();
Environment.Exit(1);
}
var robloxExecutable = Path.Combine(robloxFolder, "RobloxPlayerBeta.exe");
var currentHash = wc.DownloadString("https://pastebin.com/raw/9tnbrk3v");
if (SHA512(robloxExecutable) == currentHash)
{
// not on a beta
Console.WriteLine("You're not on a ROBLOX beta build.\nPress any key to exit");
Console.ReadKey();
Environment.Exit(1);
}
// uh oh
Console.WriteLine("Incorrect ROBLOX version detected.");
var currentVersion = wc.DownloadString("http://setup.roblox.com/version");
Console.WriteLine("Downloading ROBLOX...");
var zipBytes = wc.DownloadData($"http://setup.roblox.com/{currentVersion}-RobloxApp.zip");
Console.WriteLine("Extracting ROBLOX...");
var archive = new ZipArchive(new MemoryStream(zipBytes)); // why bother using temp? just do everything via memory 💪
var robloxPlayerBeta = new MemoryStream();
archive.GetEntry("RobloxPlayerBeta.exe")?.Open().CopyTo(robloxPlayerBeta); // probably not the most efficient but whatever
if (robloxPlayerBeta.Length == 0) fuck();
File.WriteAllBytes(robloxExecutable, robloxPlayerBeta.ToArray());
// ensures success
if (SHA512(robloxExecutable) == currentHash)
{
Console.WriteLine("Success!");
Console.WriteLine(
"You're no longer on the ROBLOX beta.\nIf your ROBLOX updates again, feel free to re-run this utility.\nPress any key to exit");
Console.ReadKey();
}
else fuck();
}
static void fuck()
{
Console.WriteLine("Something went wrong, Please reinstall ROBLOX.");
Console.ReadKey();
Environment.Exit(1);
}
static string SHA512(string path)
{
var bytes = File.ReadAllBytes(path);
using (var hash = System.Security.Cryptography.SHA512.Create())
{
var hashedInputBytes = hash.ComputeHash(bytes);
var hashedInputStringBuilder = new System.Text.StringBuilder(128);
foreach (var b in hashedInputBytes)
hashedInputStringBuilder.Append(b.ToString("X2"));
return hashedInputStringBuilder.ToString();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment