# Attachments: Macros - Linux

Macros can be utilize with Linux as well, since there is no official support to run Microsoft Office on Linux we have to mess around with the alternative version called LibreOffice, this suite of tools allow Macros as well wit there own Scripting Language [LibreOffice Basic](https://help.libreoffice.org/6.1/en-US/text/sbasic/shared/01000000.html)  some advantages of this method of Initial Access is that there is no MOTW, now setting up macro execution is quite simple, we don't have the access to the Win32 API or any other implementations that are used with windows so will work with what we have, in the following example I scripted to execute the Calculator on Linux

```
Sub Main
Shell("gnome-calculator")
End Sub
```

With this code the calculator will launch when the Macro is executed, now implementing the Open Document execution so the Macro runs when the document has been opened with the following steps:

Tools > Customize > Events > Open Document

Verify the window looks similar to the one below to confirm that the Macro you are working with is actually selected to run when open

<figure><img src="https://315180959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRh03Vwd4nuiUi3Oje7%2Fuploads%2FDdiE9CVWub2pKEZUzVBe%2Fimage.png?alt=media&#x26;token=2f12c48c-b437-4c42-ab84-27e729d8ace8" alt=""><figcaption></figcaption></figure>

View below a small demonstration that the Macro has been executed successfully

<figure><img src="https://315180959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRh03Vwd4nuiUi3Oje7%2Fuploads%2FQDlwNV8FdnbZV8MPFcpQ%2FMacro-Linux.gif?alt=media&#x26;token=72a0f538-6131-4ec1-ad66-3f00c29c11f5" alt=""><figcaption></figcaption></figure>

Now unfortunately this method works because the macros are stored on my Local Machine and that's where it is executing from when sending to the user the Macro needs to be stored on the file not the local Library

<figure><img src="https://315180959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRh03Vwd4nuiUi3Oje7%2Fuploads%2F7rhnhuvQNn12bQqKUPjr%2Fimage.png?alt=media&#x26;token=f7bd938f-68de-44ef-aaea-3e1ed7e51d23" alt=""><figcaption></figcaption></figure>

And Macros by default are on High Security

<figure><img src="https://315180959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRh03Vwd4nuiUi3Oje7%2Fuploads%2Fz9YZmUk8Csm3fPmtLOmw%2Fimage.png?alt=media&#x26;token=278f862c-011b-4901-99b3-b27531184d85" alt=""><figcaption></figcaption></figure>

The only option is to run these files on a trusted location

<figure><img src="https://315180959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRh03Vwd4nuiUi3Oje7%2Fuploads%2F9ABw0cw5VIYwCLzyFeqk%2Fimage.png?alt=media&#x26;token=8d21c2fc-f955-49f1-a07d-463435608382" alt=""><figcaption></figcaption></figure>

And then Social Engineer to execute the Macros, since there is not "AutoOpen" feature in LibreOffice.

### OLE Objects

Now with OLE Objects we can utilize a technique called "Mouse Over Object" where we can select our Macro embedded onto the Document and Assign it the Action in this scenario there is no need for a Trusted Locations, In this example I used a formula which is the smallest I could quickly find:

<figure><img src="https://315180959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRh03Vwd4nuiUi3Oje7%2Fuploads%2F8Z0feAplxdTfcObdvExB%2Fimage.png?alt=media&#x26;token=7f673883-2afc-4cde-bc63-aeb35c570d36" alt=""><figcaption></figcaption></figure>

Then right-click and Assign the Action

<figure><img src="https://315180959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRh03Vwd4nuiUi3Oje7%2Fuploads%2FGu3hWbxpeGJZbMj9kP2p%2Fimage.png?alt=media&#x26;token=2251620b-977a-4cd7-955f-75e223cc0ec3" alt=""><figcaption></figcaption></figure>

And when the User hovers over the OLE Object we gain execution as seen in the Demo below:

<figure><img src="https://315180959-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MRh03Vwd4nuiUi3Oje7%2Fuploads%2FXnDPn6eMDjsxAn5SUnhE%2FMacro-Linux-OLE.gif?alt=media&#x26;token=ade32ced-7218-4e3c-9d73-d343df7a19ee" alt=""><figcaption></figcaption></figure>
