byt3bl33d3r / OffensiveNim

My experiments in weaponizing Nim (https://nim-lang.org/)
BSD 2-Clause "Simplified" License
2.82k stars 352 forks source link

Another way to invoke the EntryPoint of .NET assembly. #9

Closed khchen closed 3 years ago

khchen commented 3 years ago

https://docs.microsoft.com/en-us/dotnet/api/system.reflection.methodbase.invoke?view=net-5.0 Hint: parameters of EntryPoint.Invoke is (Object, Object[]). Object[] can be created by toCLRVariant(openArray), so...

# omit other part of execute_assembly_bin.nim...

var assembly = load(buf)
var arr = toCLRVariant(["From Nim & .NET!"], VT_BSTR)
echo assembly.EntryPoint.Invoke(nil, toCLRVariant([arr]))
byt3bl33d3r commented 3 years ago

sweet! Thank you!

byt3bl33d3r commented 3 years ago

Fixed! Thanks!

naliferopoulos commented 2 years ago

Sorry for reviving this old and closed issue but I have been trying to extend the functionality of the execute-assembly module to allow it to grab the stdout output of the Assembly after execution from the stdout buffer. I have tried reopen() to remap stdout to a file and seeking back to its start to read it, as well as seeking directly on the stdout pipe but without much success. Does anybody know how to implement this correctly? Thanks :)