-
-
Notifications
You must be signed in to change notification settings - Fork 114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Named function invocations can break deobfuscation #40
Comments
Interesting. I will add these functions. No need to update the grammar I suppose SET.NAME is used to define a name... SET.NAME is partially implemented |
Generated a new sample based on an upcoming Macrome release - it's a wrapped up version of EXCELntDonut with some obfuscation thrown in. There's a small amount of using the SET.NAME aliasing from defining a statement like
As an added "treat", the cells that are built contain raw binary strings rather than wrapping them as CHAR(). It looks like XLMMacroDeobfuscator handles this fine (though it does play a bunch of console alerts as it prints things out which tends to slow down the printing rate) but this may slightly frustrate some of the binary dumping. |
Generated an alternate document which can also cause some issues by abusing user defined functions combined with variables set using SET.NAME. By hiding a subroutine in the sheet somewhere else (it can be simple like,
Which is identical to Right now this sort of approach will not be emulated, so once the GOTO() is reached, there's no content shown. |
Here's a slightly more refined version of the character substitution approach. This time the variables used take advantage of some unicode silliness in Excel. From the Excel UI, a cell looks like: I can't actually copy paste the content out of Excel directly since there are null bytes in the formula, and it will truncate at those bytes. |
This is addressed in v0.1.5 (currently on Master branch) |
Uploading a sample which takes advantage of some more Unicode ridiculous-ness involving Excel's magic treatment of ḁ (U+1E01) |
That make sense to be honest. The same for À (can be represented with two characters in ASCII or one unicode) |
Here's a refinement of that abuse in a different way that could be used by attackers to obscure which argument is being passed to a function when performing analysis. In the sample below each cell uses an AND statement to execute two SET.NAME calls before invoking the user defined function. One SET.NAME sets the value to be used, the other sets a decoy value using a slightly different string that is only different at the byte level (it's imperceptible to the eye). It's randomized if the first or second SET.NAME value sets the correct argument each cell. |
Yeah, the capitalization is pretty reasonable - the issue is when there's sort of uneven handling of stuff like unicode Whitespace characters or unicode characters that are just ignored. Ex: The fact that the Lbl record string and "real" arg string are considered to be a match, but the "decoy" arg string is not makes me wonder just how much of this behavior is following the Unicode specification vs a series of arbitrary edge case handling. |
Macro sheets allow Excel to replicate the effect of a RUN() invocation by defining a name and then referencing it in a sheet by appending () to the name.
For example:
is identical to calling
RUN(B1)
. You can chain these expressions together as well, for example:will also replicate calling
RUN(B1)
. It looks like the invocation of a name and treating it as a RUN() expression hasn't been added to the grammar for the tool yet. Here's a small PoC for both of these cases that will help if maldoc authors start abusing this.setname-obfuscation.xls.zip
The text was updated successfully, but these errors were encountered: