More tweaks after pen-testing.
This commit is contained in:
parent
f4899b4ce6
commit
2ff5d82218
@ -6,6 +6,7 @@ using System.Text;
|
|||||||
|
|
||||||
using RobloxFiles.Enums;
|
using RobloxFiles.Enums;
|
||||||
using RobloxFiles.DataTypes;
|
using RobloxFiles.DataTypes;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace RobloxFiles.BinaryFormat.Chunks
|
namespace RobloxFiles.BinaryFormat.Chunks
|
||||||
{
|
{
|
||||||
@ -571,7 +572,6 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
|||||||
else if (prop.Type != Type)
|
else if (prop.Type != Type)
|
||||||
throw new Exception($"Property {Name} is not using the correct type in {instance.GetFullName()}!");
|
throw new Exception($"Property {Name} is not using the correct type in {instance.GetFullName()}!");
|
||||||
|
|
||||||
prop.CurrentWriter = writer;
|
|
||||||
props.Add(prop);
|
props.Add(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -628,7 +628,12 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
|||||||
writer.WriteFloats(floats);
|
writer.WriteFloats(floats);
|
||||||
break;
|
break;
|
||||||
case PropertyType.Double:
|
case PropertyType.Double:
|
||||||
props.ForEach(prop => prop.WriteValue<double>());
|
props.ForEach(prop =>
|
||||||
|
{
|
||||||
|
double value = prop.CastValue<double>();
|
||||||
|
writer.Write(BinaryRobloxFileWriter.GetBytes(value));
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PropertyType.UDim:
|
case PropertyType.UDim:
|
||||||
var UDim_Scales = new List<float>();
|
var UDim_Scales = new List<float>();
|
||||||
@ -689,7 +694,12 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
|||||||
break;
|
break;
|
||||||
case PropertyType.Faces:
|
case PropertyType.Faces:
|
||||||
case PropertyType.Axes:
|
case PropertyType.Axes:
|
||||||
props.ForEach(prop => prop.WriteValue<byte>());
|
props.ForEach(prop =>
|
||||||
|
{
|
||||||
|
byte value = prop.CastValue<byte>();
|
||||||
|
writer.Write(value);
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PropertyType.BrickColor:
|
case PropertyType.BrickColor:
|
||||||
var BrickColorIds = new List<int>();
|
var BrickColorIds = new List<int>();
|
||||||
@ -1003,6 +1013,13 @@ namespace RobloxFiles.BinaryFormat.Chunks
|
|||||||
props.ForEach(prop =>
|
props.ForEach(prop =>
|
||||||
{
|
{
|
||||||
var shared = prop.CastValue<SharedString>();
|
var shared = prop.CastValue<SharedString>();
|
||||||
|
|
||||||
|
if (shared == null)
|
||||||
|
{
|
||||||
|
byte[] empty = Array.Empty<byte>();
|
||||||
|
shared = SharedString.FromBuffer(empty);
|
||||||
|
}
|
||||||
|
|
||||||
string key = shared.Key;
|
string key = shared.Key;
|
||||||
|
|
||||||
if (!sstr.Lookup.ContainsKey(key))
|
if (!sstr.Lookup.ContainsKey(key))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using Konscious.Security.Cryptography;
|
using Konscious.Security.Cryptography;
|
||||||
|
|
||||||
namespace RobloxFiles.DataTypes
|
namespace RobloxFiles.DataTypes
|
||||||
@ -15,7 +16,7 @@ namespace RobloxFiles.DataTypes
|
|||||||
|
|
||||||
public class SharedString
|
public class SharedString
|
||||||
{
|
{
|
||||||
private static Dictionary<string, byte[]> Lookup = new Dictionary<string, byte[]>();
|
private static ConcurrentDictionary<string, byte[]> Lookup = new ConcurrentDictionary<string, byte[]>();
|
||||||
public string Key { get; internal set; }
|
public string Key { get; internal set; }
|
||||||
public string ComputedKey { get; internal set; }
|
public string ComputedKey { get; internal set; }
|
||||||
|
|
||||||
@ -29,12 +30,15 @@ namespace RobloxFiles.DataTypes
|
|||||||
|
|
||||||
internal static void Register(string key, byte[] buffer)
|
internal static void Register(string key, byte[] buffer)
|
||||||
{
|
{
|
||||||
Lookup.Add(key, buffer);
|
if (Lookup.ContainsKey(key))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Lookup.TryAdd(key, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SharedString(byte[] buffer)
|
private SharedString(byte[] buffer)
|
||||||
{
|
{
|
||||||
using (HMACBlake2B blake2B = new HMACBlake2B(16 * 8))
|
using (var blake2B = new HMACBlake2B(16 * 8))
|
||||||
{
|
{
|
||||||
byte[] hash = blake2B.ComputeHash(buffer);
|
byte[] hash = blake2B.ComputeHash(buffer);
|
||||||
ComputedKey = Convert.ToBase64String(hash);
|
ComputedKey = Convert.ToBase64String(hash);
|
||||||
|
@ -2252,7 +2252,7 @@ namespace RobloxFiles
|
|||||||
public ModelLevelOfDetail LevelOfDetail = ModelLevelOfDetail.Automatic;
|
public ModelLevelOfDetail LevelOfDetail = ModelLevelOfDetail.Automatic;
|
||||||
public CFrame ModelInPrimary = new CFrame();
|
public CFrame ModelInPrimary = new CFrame();
|
||||||
public CFrame ModelMeshCFrame = new CFrame();
|
public CFrame ModelMeshCFrame = new CFrame();
|
||||||
public byte[] ModelMeshData = Array.Empty<byte>();
|
public SharedString ModelMeshData;
|
||||||
public Vector3 ModelMeshSize = new Vector3();
|
public Vector3 ModelMeshSize = new Vector3();
|
||||||
public BasePart PrimaryPart;
|
public BasePart PrimaryPart;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ namespace RobloxFiles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string lead = Encoding.UTF8.GetString(buffer, 0, 100);
|
||||||
throw new Exception("Unrecognized header!");
|
throw new Exception("Unrecognized header!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>1</WarningLevel>
|
<WarningLevel>1</WarningLevel>
|
||||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<StartupObject />
|
<StartupObject />
|
||||||
|
Binary file not shown.
@ -56,11 +56,9 @@ namespace RobloxFiles
|
|||||||
public byte[] RawBuffer { get; internal set; }
|
public byte[] RawBuffer { get; internal set; }
|
||||||
|
|
||||||
internal object RawValue;
|
internal object RawValue;
|
||||||
internal BinaryRobloxFileWriter CurrentWriter;
|
|
||||||
|
|
||||||
internal static BindingFlags BindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase;
|
internal static BindingFlags BindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy | BindingFlags.IgnoreCase;
|
||||||
internal static MemberTypes FieldOrProperty = MemberTypes.Field | MemberTypes.Property;
|
|
||||||
|
|
||||||
// !! FIXME: Map typeof(ProtectedString) to PropertyType.ProtectedString when binary files are allowed to read it.
|
// !! FIXME: Map typeof(ProtectedString) to PropertyType.ProtectedString when binary files are allowed to read it.
|
||||||
public static readonly IReadOnlyDictionary<Type, PropertyType> Types = new Dictionary<Type, PropertyType>()
|
public static readonly IReadOnlyDictionary<Type, PropertyType> Types = new Dictionary<Type, PropertyType>()
|
||||||
{
|
{
|
||||||
@ -329,16 +327,5 @@ namespace RobloxFiles
|
|||||||
|
|
||||||
return (T)result;
|
return (T)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void WriteValue<T>() where T : struct
|
|
||||||
{
|
|
||||||
if (CurrentWriter == null)
|
|
||||||
throw new Exception("Property.CurrentWriter must be set to use WriteValue<T>");
|
|
||||||
|
|
||||||
T value = CastValue<T>();
|
|
||||||
byte[] bytes = BinaryRobloxFileWriter.GetBytes(value);
|
|
||||||
|
|
||||||
CurrentWriter.Write(bytes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user