Escape from sandbox: reflection

213 Views Asked by At

I have really fun problem. It's kind of sandbox escaping.

Aim: get private methods of class

What I can:
1) Load standart assemblies by assemblies by long name
2) Use GetType and Type's methods

What I cannot:
1) Use using in code 2) Use System word in code. When I load assemblies I use such hack Load("Sys" + "tem....")

Looks like I could load private methods like

myType.GetMethods(BindingFlags.NonPublic | BindingFlags.Instance);

but I haven't BindingFlags imported in my code.

OK, I could create instance of BindingFlags and use GetField of it, but again it returns Object and I can't cast it to BindingFlags.

var value = bindingFlagsType.GetField("NonPublic").GetValue(null); //it's Object not BindingFlags

I tried Convert.ChangeType method, but Invoke return Object :)

How could I resolve this issue?

0

There are 0 best solutions below