tyranid / DotNetToJScript

A tool to create a JScript file which loads a .NET v2 assembly from memory.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

JScript working, but not VBA

Arno0x opened this issue · comments

Hi,

Thanks to your explanations I've managed to get a v4 assembly to get executed through the DotNetToJscript technique.

However, with the exact same assembly (.dll), the JScript version, running in wscript.exe, works perfectly, but the VBA version fails with an unspecified error which I would translate in english to "an exception was raised by the target of a call".

The assembly DLL is compiled this way:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /target:library /out:dbc2_agent.dll *.cs

This works:
DotNetToJScript.exe --ver=auto -l JScript -c dropboxc2.C2_Agent dbc2_agent.dll > dbc2_agent.js

This fails, using the VBA code in Excel (32 bits if it makes any difference...):
DotNetToJScript.exe --ver=auto -l VBA -c dropboxc2.C2_Agent dbc2_agent.dll > dbc2_agent.vb

Any idea would be helpful.

Thanks !

Unfortunately VBA doesn't work with v4 at the moment as Office pre-loads a core DLL into memory before the script runs. This forces the loaded CLR to always be v2 no matter what the auto detection does. I might have a fix which I can submit in the future.

Ok, thanks for the quick answer (and for your amazing tool !).

Just curious, you had mentioned you might have a fix to allow you to use v4 within Office. Did you ever determine if it worked, or are you required to use v2 due to the CLR being forced to use v2.

I can't remember if I had a simpler fix but one way to can do it is to use the ActCtx object with a custom manifest to allow you to load v4 classes into VBA even though it's set to v2 only. I can help you offline with that if you need it.

Ah, that makes sense. I'll play with that, thanks for the idea!