Skip to content

Commit a12a0fe

Browse files
committedSep 3, 2024
Initial commit
1 parent 67391ef commit a12a0fe

12 files changed

+745
-0
lines changed
 

‎roblox_decryptor.sln

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.34601.136
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "roblox_decryptor", "roblox_decryptor\roblox_decryptor.vcxproj", "{95843837-C21A-4CDC-BC04-28271ABD09A6}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|x64 = Debug|x64
11+
Debug|x86 = Debug|x86
12+
Release|x64 = Release|x64
13+
Release|x86 = Release|x86
14+
EndGlobalSection
15+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16+
{95843837-C21A-4CDC-BC04-28271ABD09A6}.Debug|x64.ActiveCfg = Debug|x64
17+
{95843837-C21A-4CDC-BC04-28271ABD09A6}.Debug|x64.Build.0 = Debug|x64
18+
{95843837-C21A-4CDC-BC04-28271ABD09A6}.Debug|x86.ActiveCfg = Debug|Win32
19+
{95843837-C21A-4CDC-BC04-28271ABD09A6}.Debug|x86.Build.0 = Debug|Win32
20+
{95843837-C21A-4CDC-BC04-28271ABD09A6}.Release|x64.ActiveCfg = Release|x64
21+
{95843837-C21A-4CDC-BC04-28271ABD09A6}.Release|x64.Build.0 = Release|x64
22+
{95843837-C21A-4CDC-BC04-28271ABD09A6}.Release|x86.ActiveCfg = Release|Win32
23+
{95843837-C21A-4CDC-BC04-28271ABD09A6}.Release|x86.Build.0 = Release|Win32
24+
EndGlobalSection
25+
GlobalSection(SolutionProperties) = preSolution
26+
HideSolutionNode = FALSE
27+
EndGlobalSection
28+
GlobalSection(ExtensibilityGlobals) = postSolution
29+
SolutionGuid = {FF4F996F-CFDD-4C90-9869-5A658DD12C93}
30+
EndGlobalSection
31+
EndGlobal
+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
#include "decryptor.hpp"
2+
3+
#include "utils/memory.hpp"
4+
#include "utils/pe.hpp"
5+
6+
#include <Windows.h>
7+
8+
#include <vendor/chacha20/chacha20.hpp>
9+
10+
namespace decryptor
11+
{
12+
code_decryptor::code_decryptor(const std::filesystem::path& hyperion, const std::filesystem::path& roblox, const std::string& out_filename) : page_info_base{ 0 }
13+
{
14+
// Loading the module directly so we can work with memory mapped offsets
15+
hyperion_handle = LoadLibraryExA(hyperion.string().c_str(), NULL, DONT_RESOLVE_DLL_REFERENCES);
16+
roblox_handle = LoadLibraryExA(roblox.string().c_str(), NULL, DONT_RESOLVE_DLL_REFERENCES);
17+
18+
if (!roblox_handle || !hyperion_handle)
19+
return;
20+
21+
utils::pe roblox_image{ get_base_from_handle(roblox_handle) };
22+
utils::pe hyperion_image{ get_base_from_handle(hyperion_handle) };
23+
24+
const auto roblox_code = roblox_image.get_section(".text");
25+
const auto hyperion_code = hyperion_image.get_section(".byfron");
26+
27+
DWORD old;
28+
VirtualProtect(reinterpret_cast<LPVOID>(roblox_code.base), roblox_code.size, PAGE_READWRITE, &old);
29+
30+
// Attempt to automatically locate the page info array
31+
constexpr std::array<std::uint8_t, 6> constant_sig = { 0x10, 0x27, 0x00, 0x00, 0xCC, 0x29 };
32+
constexpr std::array<std::uint8_t, 3> lea_sig = { 0x04, 0xCC, 0x8D };
33+
34+
const auto constant_mov = utils::signature_scan(hyperion_code.base, hyperion_code.size, constant_sig);
35+
36+
if (!constant_mov)
37+
return;
38+
39+
auto page_info_lea = utils::signature_scan(constant_mov, 0x100, lea_sig);
40+
41+
if (!page_info_lea)
42+
return;
43+
44+
// Plus one because we include the end of the shl reg, 4 instruction
45+
page_info_lea += 1;
46+
47+
const auto dest = page_info_lea + *reinterpret_cast<std::int32_t*>(page_info_lea + 3) + 7;
48+
49+
page_info_base = dest;
50+
51+
std::ifstream src{ roblox, std::ios::binary };
52+
53+
out_file = std::ofstream{ out_filename, std::ios::binary };
54+
out_file << src.rdbuf();
55+
56+
src.close();
57+
}
58+
59+
code_decryptor::~code_decryptor()
60+
{
61+
if (hyperion_handle)
62+
FreeLibrary(static_cast<HMODULE>(hyperion_handle));
63+
64+
if (roblox_handle)
65+
FreeLibrary(static_cast<HMODULE>(roblox_handle));
66+
}
67+
68+
bool code_decryptor::is_initialized() const
69+
{
70+
return page_info_base != 0;
71+
}
72+
73+
void code_decryptor::decrypt()
74+
{
75+
utils::pe roblox_image{ get_base_from_handle(roblox_handle) };
76+
utils::pe hyperion_image{ get_base_from_handle(hyperion_handle) };
77+
78+
const auto roblox_code = roblox_image.get_section(".text");
79+
const auto hyperion_code = hyperion_image.get_section(".byfron");
80+
81+
for (auto target_page = roblox_code.base; target_page < roblox_code.base + roblox_code.size; target_page += 0x1000)
82+
{
83+
const auto target_page_number = (target_page - roblox_image.get_image_base()) / 0x1000;
84+
const auto target_page_info_base = page_info_base + (target_page_number % 10000) * 0x10;
85+
86+
const auto page_info = *reinterpret_cast<std::uintptr_t*>(target_page_info_base);
87+
const auto page_size = *reinterpret_cast<std::uint32_t*>(target_page_info_base + 0x8);
88+
89+
std::array<std::uint8_t, 32> key{};
90+
std::memcpy(key.data(), reinterpret_cast<void*>(page_info), page_size);
91+
92+
chacha20_context ctx;
93+
chacha20_init_context(&ctx, key.data(), 0);
94+
chacha20_xor(&ctx, reinterpret_cast<uint8_t*>(target_page), 0x1000);
95+
}
96+
97+
// Seek to the first section after the PE headers, assuming it should be code
98+
out_file.seekp(0x600);
99+
out_file.write(reinterpret_cast<char*>(roblox_code.base), roblox_code.size);
100+
out_file.flush();
101+
}
102+
103+
std::uintptr_t code_decryptor::get_base_from_handle(void* handle) const
104+
{
105+
return reinterpret_cast<std::uintptr_t>(handle);
106+
}
107+
}
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
#include <string>
5+
#include <filesystem>
6+
#include <fstream>
7+
#include <array>
8+
9+
namespace decryptor
10+
{
11+
class code_decryptor
12+
{
13+
public:
14+
code_decryptor(const std::filesystem::path& hyperion, const std::filesystem::path& roblox, const std::string& out_filename);
15+
~code_decryptor();
16+
17+
void decrypt();
18+
19+
bool is_initialized() const;
20+
21+
private:
22+
std::uintptr_t get_base_from_handle(void* handle) const;
23+
24+
private:
25+
void* hyperion_handle;
26+
void* roblox_handle;
27+
28+
std::uintptr_t page_info_base;
29+
30+
std::ofstream out_file;
31+
};
32+
}

‎roblox_decryptor/roblox_decryptor.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <iostream>
2+
3+
#include "decryptor/decryptor.hpp"
4+
5+
using namespace decryptor;
6+
7+
int main()
8+
{
9+
std::printf("Starting decryptor\n");
10+
11+
code_decryptor static_decryptor{ "RobloxPlayerBeta.dll", "RobloxPlayerBeta.exe", "decrypted.bin" };
12+
13+
if (!static_decryptor.is_initialized())
14+
{
15+
std::printf("Decryptor failed to initialize\n");
16+
17+
std::cin.get();
18+
19+
return 1;
20+
}
21+
22+
static_decryptor.decrypt();
23+
24+
std::printf("Decryptor successfully finished\n");
25+
26+
std::cin.get();
27+
}
+165
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|Win32">
5+
<Configuration>Debug</Configuration>
6+
<Platform>Win32</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Release|Win32">
9+
<Configuration>Release</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Debug|x64">
13+
<Configuration>Debug</Configuration>
14+
<Platform>x64</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|x64">
17+
<Configuration>Release</Configuration>
18+
<Platform>x64</Platform>
19+
</ProjectConfiguration>
20+
</ItemGroup>
21+
<PropertyGroup Label="Globals">
22+
<VCProjectVersion>16.0</VCProjectVersion>
23+
<Keyword>Win32Proj</Keyword>
24+
<ProjectGuid>{95843837-c21a-4cdc-bc04-28271abd09a6}</ProjectGuid>
25+
<RootNamespace>robloxdecryptor</RootNamespace>
26+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
27+
</PropertyGroup>
28+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
30+
<ConfigurationType>Application</ConfigurationType>
31+
<UseDebugLibraries>true</UseDebugLibraries>
32+
<PlatformToolset>v142</PlatformToolset>
33+
<CharacterSet>Unicode</CharacterSet>
34+
</PropertyGroup>
35+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
36+
<ConfigurationType>Application</ConfigurationType>
37+
<UseDebugLibraries>false</UseDebugLibraries>
38+
<PlatformToolset>v142</PlatformToolset>
39+
<WholeProgramOptimization>true</WholeProgramOptimization>
40+
<CharacterSet>Unicode</CharacterSet>
41+
</PropertyGroup>
42+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
43+
<ConfigurationType>Application</ConfigurationType>
44+
<UseDebugLibraries>true</UseDebugLibraries>
45+
<PlatformToolset>v142</PlatformToolset>
46+
<CharacterSet>Unicode</CharacterSet>
47+
</PropertyGroup>
48+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
49+
<ConfigurationType>Application</ConfigurationType>
50+
<UseDebugLibraries>false</UseDebugLibraries>
51+
<PlatformToolset>v142</PlatformToolset>
52+
<WholeProgramOptimization>true</WholeProgramOptimization>
53+
<CharacterSet>Unicode</CharacterSet>
54+
</PropertyGroup>
55+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
56+
<ImportGroup Label="ExtensionSettings">
57+
</ImportGroup>
58+
<ImportGroup Label="Shared">
59+
</ImportGroup>
60+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
61+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
62+
</ImportGroup>
63+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
64+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
65+
</ImportGroup>
66+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
67+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
68+
</ImportGroup>
69+
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
70+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
71+
</ImportGroup>
72+
<PropertyGroup Label="UserMacros" />
73+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
74+
<LinkIncremental>true</LinkIncremental>
75+
<IncludePath>./;$(IncludePath)</IncludePath>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
78+
<LinkIncremental>false</LinkIncremental>
79+
<IncludePath>./;$(IncludePath)</IncludePath>
80+
</PropertyGroup>
81+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
82+
<LinkIncremental>true</LinkIncremental>
83+
<IncludePath>./;$(IncludePath)</IncludePath>
84+
</PropertyGroup>
85+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
86+
<LinkIncremental>false</LinkIncremental>
87+
<IncludePath>./;$(IncludePath)</IncludePath>
88+
</PropertyGroup>
89+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
90+
<ClCompile>
91+
<WarningLevel>Level3</WarningLevel>
92+
<SDLCheck>true</SDLCheck>
93+
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
94+
<ConformanceMode>true</ConformanceMode>
95+
<LanguageStandard>stdcpp17</LanguageStandard>
96+
</ClCompile>
97+
<Link>
98+
<SubSystem>Console</SubSystem>
99+
<GenerateDebugInformation>true</GenerateDebugInformation>
100+
</Link>
101+
</ItemDefinitionGroup>
102+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
103+
<ClCompile>
104+
<WarningLevel>Level3</WarningLevel>
105+
<FunctionLevelLinking>true</FunctionLevelLinking>
106+
<IntrinsicFunctions>true</IntrinsicFunctions>
107+
<SDLCheck>true</SDLCheck>
108+
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
109+
<ConformanceMode>true</ConformanceMode>
110+
<LanguageStandard>stdcpp17</LanguageStandard>
111+
</ClCompile>
112+
<Link>
113+
<SubSystem>Console</SubSystem>
114+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
115+
<OptimizeReferences>true</OptimizeReferences>
116+
<GenerateDebugInformation>true</GenerateDebugInformation>
117+
</Link>
118+
</ItemDefinitionGroup>
119+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
120+
<ClCompile>
121+
<WarningLevel>Level3</WarningLevel>
122+
<SDLCheck>true</SDLCheck>
123+
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
124+
<ConformanceMode>true</ConformanceMode>
125+
<LanguageStandard>stdcpp17</LanguageStandard>
126+
</ClCompile>
127+
<Link>
128+
<SubSystem>Console</SubSystem>
129+
<GenerateDebugInformation>true</GenerateDebugInformation>
130+
</Link>
131+
</ItemDefinitionGroup>
132+
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
133+
<ClCompile>
134+
<WarningLevel>Level3</WarningLevel>
135+
<FunctionLevelLinking>true</FunctionLevelLinking>
136+
<IntrinsicFunctions>true</IntrinsicFunctions>
137+
<SDLCheck>true</SDLCheck>
138+
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
139+
<ConformanceMode>true</ConformanceMode>
140+
<LanguageStandard>stdcpp17</LanguageStandard>
141+
</ClCompile>
142+
<Link>
143+
<SubSystem>Console</SubSystem>
144+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
145+
<OptimizeReferences>true</OptimizeReferences>
146+
<GenerateDebugInformation>true</GenerateDebugInformation>
147+
</Link>
148+
</ItemDefinitionGroup>
149+
<ItemGroup>
150+
<ClCompile Include="decryptor\decryptor.cpp" />
151+
<ClCompile Include="roblox_decryptor.cpp" />
152+
<ClCompile Include="utils\memory.cpp" />
153+
<ClCompile Include="utils\pe.cpp" />
154+
<ClCompile Include="vendor\chacha20\chacha20.cpp" />
155+
</ItemGroup>
156+
<ItemGroup>
157+
<ClInclude Include="decryptor\decryptor.hpp" />
158+
<ClInclude Include="utils\memory.hpp" />
159+
<ClInclude Include="utils\pe.hpp" />
160+
<ClInclude Include="vendor\chacha20\chacha20.hpp" />
161+
</ItemGroup>
162+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
163+
<ImportGroup Label="ExtensionTargets">
164+
</ImportGroup>
165+
</Project>

0 commit comments

Comments
 (0)
Please sign in to comment.