Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code cleanup #130

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 12 additions & 16 deletions ysoserial/Helpers/SerializersHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using System.Xml;
using System.Xml.Serialization;
using YamlDotNet.Serialization;
using ysoserial.Helpers.ModifiedVulnerableBinaryFormatters;

namespace ysoserial.Helpers
{
Expand Down Expand Up @@ -636,25 +637,24 @@ public static object BinaryFormatter_test(object myobj)
}
}

public static string BinaryFormatter_serialize_ToJson(object myobj)
{
return AdvancedBinaryFormatterParser.StreamToJson(BinaryFormatter_serialize_ToMemoryStream(myobj), false, true, true);
}

public static string BinaryFormatter_serialize_ToBase64(object myobj)
{
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, myobj);
return Convert.ToBase64String(ms.ToArray());
return Convert.ToBase64String(BinaryFormatter_serialize_ToMemoryStream(myobj).ToArray());
}

public static byte[] BinaryFormatter_serialize_ToByteArray(object myobj)
{
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, myobj);
return ms.ToArray();
return BinaryFormatter_serialize_ToMemoryStream(myobj).ToArray();
}

public static MemoryStream BinaryFormatter_serialize_ToMemoryStream(object myobj)
{
BinaryFormatter bf = new BinaryFormatter();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, myobj);
ms.Position = 0;
Expand All @@ -665,23 +665,19 @@ public static object BinaryFormatter_deserialize_FromBase64(string str)
{
byte[] byteArray = Convert.FromBase64String(str);
MemoryStream ms = new MemoryStream(byteArray);
BinaryFormatter bf = new BinaryFormatter();
ms.Position = 0;
return bf.Deserialize(ms);
return BinaryFormatter_deserialize(ms);
}

public static object BinaryFormatter_deserialize(byte[] byteArray)
{
MemoryStream ms = new MemoryStream(byteArray);
BinaryFormatter bf = new BinaryFormatter();
ms.Position = 0;
return bf.Deserialize(ms);
return BinaryFormatter_deserialize(ms);
}

public static object BinaryFormatter_deserialize(MemoryStream ms)
{
ms.Position = 0;
BinaryFormatter bf = new BinaryFormatter();
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
return bf.Deserialize(ms);
}

Expand Down
8 changes: 4 additions & 4 deletions ysoserial/packages.config
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="fastJSON" version="2.1.27" targetFramework="net452" />
<package id="FSharp.Core" version="3.1.2" targetFramework="net48" />
<package id="FsPickler" version="4.6" targetFramework="net461" />
<package id="FsPickler.CSharp" version="4.6" targetFramework="net461" />
<package id="FsPickler.Json" version="4.6" targetFramework="net461" />
<package id="FSharp.Core" version="3.1.2.5" targetFramework="net452" />
<package id="FsPickler" version="4.6" targetFramework="net452" />
<package id="FsPickler.CSharp" version="4.6" targetFramework="net452" />
<package id="FsPickler.Json" version="4.6" targetFramework="net452" />
<package id="Microsoft.IdentityModel" version="7.0.0" targetFramework="net452" />
<package id="NDesk.Options" version="0.2.1" targetFramework="net452" />
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net452" />
Expand Down
23 changes: 10 additions & 13 deletions ysoserial/ysoserial.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -90,39 +90,36 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="fastjson, Version=2.1.0.0, Culture=neutral, PublicKeyToken=6b75a806b86095cd, processorArchitecture=MSIL">
<HintPath>..\packages\fastJSON.2.1.27\lib\net40\fastjson.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\myysoserial.net\packages\fastJSON.2.1.27\lib\net40\fastjson.dll</HintPath>
</Reference>
<Reference Include="FSharp.Core, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\FSharp.Core.3.1.2\lib\net40\FSharp.Core.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\myysoserial.net\packages\FSharp.Core.3.1.2.5\lib\net40\FSharp.Core.dll</HintPath>
</Reference>
<Reference Include="FsPickler, Version=4.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FsPickler.4.6\lib\net45\FsPickler.dll</HintPath>
<HintPath>..\..\myysoserial.net\packages\FsPickler.4.6\lib\net45\FsPickler.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FsPickler.CSharp, Version=4.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FsPickler.CSharp.4.6\lib\net45\FsPickler.CSharp.dll</HintPath>
<HintPath>..\..\myysoserial.net\packages\FsPickler.CSharp.4.6\lib\net45\FsPickler.CSharp.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="FsPickler.Json, Version=4.6.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\FsPickler.Json.4.6\lib\net45\FsPickler.Json.dll</HintPath>
<HintPath>..\..\myysoserial.net\packages\FsPickler.Json.4.6\lib\net45\FsPickler.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="microsoft.identitymodel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.IdentityModel.7.0.0\lib\net35\microsoft.identitymodel.dll</HintPath>
<Private>True</Private>
<HintPath>..\..\myysoserial.net\packages\Microsoft.IdentityModel.7.0.0\lib\net35\microsoft.identitymodel.dll</HintPath>
</Reference>
<Reference Include="NDesk.Options, Version=0.2.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath>
<HintPath>..\..\myysoserial.net\packages\NDesk.Options.0.2.1\lib\NDesk.Options.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath>..\..\myysoserial.net\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Polenter.SharpSerializer, Version=3.0.1.0, Culture=neutral, PublicKeyToken=8f4f20011571ee5f, processorArchitecture=MSIL">
<HintPath>..\packages\SharpSerializer.3.0.1\lib\net452\Polenter.SharpSerializer.dll</HintPath>
<HintPath>..\..\myysoserial.net\packages\SharpSerializer.3.0.1\lib\net452\Polenter.SharpSerializer.dll</HintPath>
</Reference>
<Reference Include="PresentationFramework" />
<Reference Include="System" />
Expand Down Expand Up @@ -151,7 +148,7 @@
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Reference Include="YamlDotNet, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\YamlDotNet.4.3.2\lib\net45\YamlDotNet.dll</HintPath>
<HintPath>..\..\myysoserial.net\packages\YamlDotNet.4.3.2\lib\net45\YamlDotNet.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
Expand Down