Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated †...

33
PUBLIC Persisting with Microsoft Office: Abusing Extensibility Options William Knowles

Transcript of Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated †...

Page 1: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Persisting with Microsoft Office:Abusing Extensibility Options

William Knowles

Page 2: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Urgh, Microsoft Office … why?

• It’s –everywhere- and it’s got lots of use cases

• Office templates? What else?

1

Page 3: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

2

Page 4: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Urgh, Microsoft Office … why?

• It’s –everywhere- and it’s got lots of use cases

• Office templates? What else?

3

Page 5: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

WLL? Word … Linked Libraries?

• It’s just a DLL …

• “… are standard Windows DLLs that implement and export specific functions

to extend Word functionality”

• “… no enhancements and no documentation updates to Word WLLs since

Microsoft Office 97”

4

Page 6: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

WLLs ain’t nothin’ but vanilla DLLs

5

Page 7: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Word … Linked Libraries?

• Is it active? No.

6

Page 8: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Excel (XLL?) too …

• Considerably more updated …

• You need to export the right functions.

• Does an XLL really need to be *.xll?

7

Page 9: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

It’s like VBA’s Auto_Open() but not …

8

Page 10: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

DEMO

9

Page 11: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

AdditionalActionsDLL

• Only for Word with 2013/2016 Professional Plus.

• “AdditionalActionsDLL” is a property containing a path at:

HKEY_CURRENT_USER\Software\Microsoft\Office\<Version>\Common

10

Page 12: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Excel VBA add-ins

• *.xla // *.xlam – it’s all VBA, no

spreadsheets.

• *.xls // *.xlsm // *.xlsb

• … // does it matter?

11

Page 13: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

User defined locations with XLL/XLA/XLAM

• Does it even need to be in a Trusted Location?

HKEY_CURRENT_USER\Software\Microsoft\Office\<Version>\Excel\Options

12

Page 14: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

13

DEMO

Page 15: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

PowerPoint VBA add-ins

• *.ppa // *.ppam // yep, doesn’t matter

• Register at:

HKEY_CURRENT_USER\Software\Microsoft\Office\<Version>\PowerPoint\AddIns\<AddInName>

14

Page 16: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

A brief introduction to COM

• It’s a binary interface standard to facilitate component interaction.

• File extensions: *.dll, *.ocx, *.sct, … many more

15

Page 17: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Reimplementing WScript.Shell

16

Page 18: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Demystifying (mystifying?) COM registration and resolution

17

Page 19: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

18

Page 20: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

=calc() with Excel Automation add-ins

• Specific COM use case – for user defined functions.

• Register COM object then add-in with the “OPEN” property at:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\<version>\Excel\Options

19

Page 21: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

20

Page 22: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

The manual labour of “automation”

• The problem? You actually have to call the function.

21

Page 23: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

COM add-ins for *

• Single add-in, multi application.

• The “IDTExtensibility2” interface.

• Register COM object with Windows, then register add-in with the Office

application.

HKEY_CURRENT_USER\Software\Microsoft\Office\<Program>\Addins\<AddInName>

22

Page 24: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

COM add-ins for *

23

Page 25: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

24

Page 26: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Attacking VBA snoopers with VBE add-ins

• Why? Why? Why?

• Register with Windows, then do the application-specific registration at:

HKEY_CURRENT_USER\Software\Microsoft\VBA\VBE\6.0\Addins\<VBEAddIn.Name>

25

Page 27: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

26

Page 28: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Office add-ins tabulated

† Registry edits can be used to bypass trusted location settings and store files in arbitrary locations

‡ Requires "StartUp" location to be on a network share.

27

Targets

Registry Edits Required

Arbitrary File Extensions Allowed

VDI Applicable (w/o Roaming Profiles)

Admin Privileges Required

WLL Word No No Potentially ‡ No

XLL Excel No † Yes Potentially ‡ No

AdditionalActionsDLL Word Yes Yes No No

XLA/XLAM/XL* Excel No † Yes Potentially ‡ No

PPA/PPAM PowerPoint Yes Yes No No

Automation Excel Yes Yes No No

COM All Yes Yes No No

VBE All Yes Yes No No

Page 29: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

The things I didn’t cover

• Visual Studio Tools for Office (VSTO)

• Outlook rules

• Outlook VBProject.OTM

• HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office Test\Special\Perf

• “Other” command line switches

• … all of the other stuff requiring administrative privileges.

28

Page 30: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

The future of Office add-ins?

• Office Web Add-Ins

29

source: dev.office.com

Page 31: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Defending against malicious add-ins (1)

• Easy for the Excel “/R <path>” registry edit, PPA/PPAM, Excel Automation,

COM, and VSTO add-ins:

• If required – sign and disable notifications.

30

Page 32: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Defending against malicious add-ins (2)

• For WLL, XLL and Excel’s VBA add-ins (startup only) … not so much.

• (1) Remove or relocate trusted locations.

• (2) Detective capability:

– Monitor trusted locations for changes

– Monitor registry keys used to enable add-ins.

– Process relationships.

31

Page 33: Persisting with Microsoft Office: Abusing Extensibility ... · PUBLIC Office add-ins tabulated † Registry edits can be used to bypass trusted location settings and store files in

PUBLIC

Conclusion@william_knows