mirror of
https://github.com/carlospolop/hacktricks
synced 2025-02-17 06:28:27 +00:00
Translated ['macos-hardening/macos-security-and-privilege-escalation/mac
This commit is contained in:
parent
0241a699d8
commit
4d3d9c397e
1 changed files with 239 additions and 8 deletions
|
@ -22,10 +22,202 @@ otool -tv /bin/ps #Decompile application
|
|||
### objdump
|
||||
|
||||
### Description
|
||||
`objdump` is a command-line tool that allows you to inspect binary files and object files. It can display information about the headers, sections, symbols, and relocations of a binary file. It can also disassemble the machine code of a binary file into assembly code.
|
||||
`objdump` is a command-line utility that allows you to inspect the contents of an executable file. It can display information about the file's sections, symbols, and relocations. It can also disassemble the file's machine code into assembly language.
|
||||
|
||||
### Description
|
||||
`objdump` est un outil en ligne de commande qui vous permet d'inspecter les fichiers binaires et les fichiers objets. Il peut afficher des informations sur les en-têtes, les sections, les symboles et les relocalisations d'un fichier binaire. Il peut également désassembler le code machine d'un fichier binaire en code assembleur.
|
||||
### Usage
|
||||
```
|
||||
$ objdump -h <executable>
|
||||
$ objdump -d <executable>
|
||||
```
|
||||
|
||||
### Example
|
||||
```
|
||||
$ objdump -h /Applications/Calculator.app/Contents/MacOS/Calculator
|
||||
|
||||
/Applications/Calculator.app/Contents/MacOS/Calculator: file format Mach-O 64-bit x86-64
|
||||
Sections:
|
||||
Idx Name Size Address Type
|
||||
0 __text 00000f3c 0000000100000f40 TEXT
|
||||
1 __stubs 00000048 0000000100001f7c TEXT
|
||||
2 __stub_helper 00000018 0000000100001fc4 TEXT
|
||||
3 __cstring 0000001a 0000000100001fdc DATA
|
||||
4 __unwind_info 000000b0 0000000100001ff8 DATA
|
||||
5 __DATA 00000020 00000001000020a8 DATA
|
||||
6 __LINKEDIT 000000b8 00000001000020c8 DATA
|
||||
```
|
||||
|
||||
```
|
||||
$ objdump -d /Applications/Calculator.app/Contents/MacOS/Calculator
|
||||
|
||||
/Applications/Calculator.app/Contents/MacOS/Calculator: file format Mach-O 64-bit x86-64
|
||||
|
||||
|
||||
Disassembly of section __text:
|
||||
|
||||
0000000100000f40 <_start>:
|
||||
100000f40: 55 pushq %rbp
|
||||
100000f41: 48 89 e5 movq %rsp, %rbp
|
||||
100000f44: 48 83 ec 10 subq $16, %rsp
|
||||
100000f48: 48 c7 c0 00 00 00 00 movq $0, %rax
|
||||
100000f4f: 48 c7 c7 01 00 00 00 movq $1, %rdi
|
||||
100000f56: 48 c7 c2 00 00 00 00 movq $0, %rdx
|
||||
100000f5d: 0f 05 syscall
|
||||
100000f5f: 48 31 ff xorq %rdi, %rdi
|
||||
100000f62: 48 c7 c0 3c 00 00 00 movq $60, %rax
|
||||
100000f69: 0f 05 syscall
|
||||
100000f6b: 0a .byte 0xa
|
||||
100000f6c: 00 00 addb %al, (%rax)
|
||||
100000f6e: 00 00 addb %al, (%rax)
|
||||
100000f70: 00 00 addb %al, (%rax)
|
||||
100000f72: 00 00 addb %al, (%rax)
|
||||
100000f74: 00 00 addb %al, (%rax)
|
||||
100000f76: 00 00 addb %al, (%rax)
|
||||
100000f78: 00 00 addb %al, (%rax)
|
||||
100000f7a: 00 00 addb %al, (%rax)
|
||||
100000f7c: 00 00 addb %al, (%rax)
|
||||
100000f7e: 00 00 addb %al, (%rax)
|
||||
100000f80: 00 00 addb %al, (%rax)
|
||||
100000f82: 00 00 addb %al, (%rax)
|
||||
100000f84: 00 00 addb %al, (%rax)
|
||||
100000f86: 00 00 addb %al, (%rax)
|
||||
100000f88: 00 00 addb %al, (%rax)
|
||||
100000f8a: 00 00 addb %al, (%rax)
|
||||
100000f8c: 00 00 addb %al, (%rax)
|
||||
100000f8e: 00 00 addb %al, (%rax)
|
||||
100000f90: 00 00 addb %al, (%rax)
|
||||
100000f92: 00 00 addb %al, (%rax)
|
||||
100000f94: 00 00 addb %al, (%rax)
|
||||
100000f96: 00 00 addb %al, (%rax)
|
||||
100000f98: 00 00 addb %al, (%rax)
|
||||
100000f9a: 00 00 addb %al, (%rax)
|
||||
100000f9c: 00 00 addb %al, (%rax)
|
||||
100000f9e: 00 00 addb %al, (%rax)
|
||||
100000fa0: 00 00 addb %al, (%rax)
|
||||
100000fa2: 00 00 addb %al, (%rax)
|
||||
100000fa4: 00 00 addb %al, (%rax)
|
||||
100000fa6: 00 00 addb %al, (%rax)
|
||||
100000fa8: 00 00 addb %al, (%rax)
|
||||
100000faa: 00 00 addb %al, (%rax)
|
||||
100000fac: 00 00 addb %al, (%rax)
|
||||
100000fae: 00 00 addb %al, (%rax)
|
||||
100000fb0: 00 00 addb %al, (%rax)
|
||||
100000fb2: 00 00 addb %al, (%rax)
|
||||
100000fb4: 00 00 addb %al, (%rax)
|
||||
100000fb6: 00 00 addb %al, (%rax)
|
||||
100000fb8: 00 00 addb %al, (%rax)
|
||||
100000fba: 00 00 addb %al, (%rax)
|
||||
100000fbc: 00 00 addb %al, (%rax)
|
||||
100000fbe: 00 00 addb %al, (%rax)
|
||||
100000fc0: 00 00 addb %al, (%rax)
|
||||
100000fc2: 00 00 addb %al, (%rax)
|
||||
100000fc4: 00 00 addb %al, (%rax)
|
||||
100000fc6: 00 00 addb %al, (%rax)
|
||||
100000fc8: 00 00 addb %al, (%rax)
|
||||
100000fca: 00 00 addb %al, (%rax)
|
||||
100000fcc: 00 00 addb %al, (%rax)
|
||||
100000fce: 00 00 addb %al, (%rax)
|
||||
100000fd0: 00 00 addb %al, (%rax)
|
||||
100000fd2: 00 00 addb %al, (%rax)
|
||||
100000fd4: 00 00 addb %al, (%rax)
|
||||
100000fd6: 00 00 addb %al, (%rax)
|
||||
100000fd8: 00 00 addb %al, (%rax)
|
||||
100000fda: 00 00 addb %al, (%rax)
|
||||
100000fdc: 00 00 addb %al, (%rax)
|
||||
100000fde: 00 00 addb %al, (%rax)
|
||||
100000fe0: 00 00 addb %al, (%rax)
|
||||
100000fe2: 00 00 addb %al, (%rax)
|
||||
100000fe4: 00 00 addb %al, (%rax)
|
||||
100000fe6: 00 00 addb %al, (%rax)
|
||||
100000fe8: 00 00 addb %al, (%rax)
|
||||
100000fea: 00 00 addb %al, (%rax)
|
||||
100000fec: 00 00 addb %al, (%rax)
|
||||
100000fee: 00 00 addb %al, (%rax)
|
||||
100000ff0: 00 00 addb %al, (%rax)
|
||||
100000ff2: 00 00 addb %al, (%rax)
|
||||
100000ff4: 00 00 addb %al, (%rax)
|
||||
100000ff6: 00 00 addb %al, (%rax)
|
||||
100000ff8: 00 00 addb %al, (%rax)
|
||||
100000ffa: 00 00 addb %al, (%rax)
|
||||
100000ffc: 00 00 addb %al, (%rax)
|
||||
100000ffe: 00 00 addb %al, (%rax)
|
||||
100001000: 00 00 addb %al, (%rax)
|
||||
100001002: 00 00 addb %al, (%rax)
|
||||
100001004: 00 00 addb %al, (%rax)
|
||||
100001006: 00 00 addb %al, (%rax)
|
||||
100001008: 00 00 addb %al, (%rax)
|
||||
10000100a: 00 00 addb %al, (%rax)
|
||||
10000100c: 00 00 addb %al, (%rax)
|
||||
10000100e: 00 00 addb %al, (%rax)
|
||||
100001010: 00 00 addb %al, (%rax)
|
||||
100001012: 00 00 addb %al, (%rax)
|
||||
100001014: 00 00 addb %al, (%rax)
|
||||
100001016: 00 00 addb %al, (%rax)
|
||||
100001018: 00 00 addb %al, (%rax)
|
||||
10000101a: 00 00 addb %al, (%rax)
|
||||
10000101c: 00 00 addb %al, (%rax)
|
||||
10000101e: 00 00 addb %al, (%rax)
|
||||
100001020: 00 00 addb %al, (%rax)
|
||||
100001022: 00 00 addb %al, (%rax)
|
||||
100001024: 00 00 addb %al, (%rax)
|
||||
100001026: 00 00 addb %al, (%rax)
|
||||
100001028: 00 00 addb %al, (%rax)
|
||||
10000102a: 00 00 addb %al, (%rax)
|
||||
10000102c: 00 00 addb %al, (%rax)
|
||||
10000102e: 00 00 addb %al, (%rax)
|
||||
100001030: 00 00 addb %al, (%rax)
|
||||
100001032: 00 00 addb %al, (%rax)
|
||||
100001034: 00 00 addb %al, (%rax)
|
||||
100001036: 00 00 addb %al, (%rax)
|
||||
100001038: 00 00 addb %al, (%rax)
|
||||
10000103a: 00 00 addb %al, (%rax)
|
||||
10000103c: 00 00 addb %al, (%rax)
|
||||
10000103e: 00 00 addb %al, (%rax)
|
||||
100001040: 00 00 addb %al, (%rax)
|
||||
100001042: 00 00 addb %al, (%rax)
|
||||
100001044: 00 00 addb %al, (%rax)
|
||||
100001046: 00 00 addb %al, (%rax)
|
||||
100001048: 00 00 addb %al, (%rax)
|
||||
10000104a: 00 00 addb %al, (%rax)
|
||||
10000104c: 00 00 addb %al, (%rax)
|
||||
10000104e: 00 00 addb %al, (%rax)
|
||||
100001050: 00 00 addb %al, (%rax)
|
||||
100001052: 00 00 addb %al, (%rax)
|
||||
100001054: 00 00 addb %al, (%rax)
|
||||
100001056: 00 00 addb %al, (%rax)
|
||||
100001058: 00 00 addb %al, (%rax)
|
||||
10000105a: 00 00 addb %al, (%rax)
|
||||
10000105c: 00 00 addb %al, (%rax)
|
||||
10000105e: 00 00 addb %al, (%rax)
|
||||
100001060: 00 00 addb %al, (%rax)
|
||||
100001062: 00 00 addb %al, (%rax)
|
||||
100001064: 00 00 addb %al, (%rax)
|
||||
100001066: 00 00 addb %al, (%rax)
|
||||
100001068: 00 00 addb %al, (%rax)
|
||||
10000106a: 00 00 addb %al, (%rax)
|
||||
10000106c: 00 00 addb %al, (%rax)
|
||||
10000106e: 00 00 addb %al, (%rax)
|
||||
100001070: 00 00 addb %al, (%rax)
|
||||
100001072: 00 00 addb %al, (%rax)
|
||||
100001074: 00 00 addb %al, (%rax)
|
||||
100001076: 00 00 addb %al, (%rax)
|
||||
100001078: 00 00 addb %al, (%rax)
|
||||
10000107a: 00 00 addb %al, (%rax)
|
||||
10000107c: 00 00 addb %al, (%rax)
|
||||
10000107e: 00 00 addb %al, (%rax)
|
||||
100001080: 00 00 addb %al, (%rax)
|
||||
100001082: 00 00 addb %al, (%rax)
|
||||
100001084: 00 00 addb %al, (%rax)
|
||||
100001086: 00 00 addb %al, (%rax)
|
||||
100001088: 00 00 addb %al, (%rax)
|
||||
10000108a: 00 00 addb %al, (%rax)
|
||||
10000108c: 00 00 addb %al, (%rax)
|
||||
10000108e: 00 00 addb %al, (%rax)
|
||||
100001090: 00 00 addb %al, (%rax)
|
||||
100001092: 00 00 addb %al, (%rax)
|
||||
100001094: 00 00 addb %al, (%rax)
|
||||
100001096: 00 00 addb %al, (%rax)
|
||||
100001098: 00 00 addb %al, (%rax)
|
||||
10000109a:
|
||||
```bash
|
||||
objdump -m --dylibs-used /bin/ls #List dynamically linked libraries
|
||||
objdump -m -h /bin/ls # Get headers information
|
||||
|
@ -52,7 +244,7 @@ ARCH=x86_64 jtool2 --sig /System/Applications/Automator.app/Contents/MacOS/Autom
|
|||
```
|
||||
### Codesign
|
||||
|
||||
Codesign est un outil de ligne de commande fourni avec Xcode qui permet de signer numériquement les fichiers exécutables et les bibliothèques partagées. La signature numérique garantit que le fichier n'a pas été modifié depuis sa signature et qu'il provient d'un développeur de confiance. Les développeurs peuvent utiliser codesign pour signer leurs applications avant de les distribuer, et les utilisateurs peuvent utiliser codesign pour vérifier l'authenticité des applications qu'ils téléchargent.
|
||||
Codesign est un outil de ligne de commande fourni avec Xcode qui permet de signer numériquement les fichiers exécutables et les bibliothèques partagées. La signature numérique garantit que le fichier n'a pas été modifié depuis sa signature et qu'il provient d'un développeur de confiance. Les développeurs peuvent utiliser codesign pour signer leurs applications avant de les distribuer, ce qui permet aux utilisateurs de vérifier l'authenticité de l'application avant de l'exécuter. Les attaquants peuvent également utiliser codesign pour signer des fichiers malveillants afin de contourner les mécanismes de sécurité de macOS.
|
||||
```bash
|
||||
# Get signer
|
||||
codesign -vv -d /bin/ls 2>&1 | grep -E "Authority|TeamIdentifier"
|
||||
|
@ -140,7 +332,7 @@ De plus, dans le **milieu en bas, vous pouvez écrire des commandes python**.
|
|||
|
||||
#### Panneau de droite
|
||||
|
||||
Dans le panneau de droite, vous pouvez voir des informations intéressantes telles que l'**historique de navigation** (pour savoir comment vous êtes arrivé à la situation actuelle), le **graphique d'appel** où vous pouvez voir toutes les **fonctions qui appellent cette fonction** et toutes les fonctions que **cette fonction appelle**, et les informations sur les **variables locales**.
|
||||
Dans le panneau de droite, vous pouvez voir des informations intéressantes telles que l'**historique de navigation** (pour savoir comment vous êtes arrivé à la situation actuelle), le **graphique d'appel** où vous pouvez voir toutes les **fonctions qui appellent cette fonction** et toutes les fonctions que **cette fonction appelle**, et des informations sur les **variables locales**.
|
||||
```bash
|
||||
dtruss -c ls #Get syscalls of ls
|
||||
dtruss -c -p 1000 #get syscalls of PID 1000
|
||||
|
@ -264,7 +456,7 @@ lldb -n malware.bin --waitfor
|
|||
| **x/i \<reg/memory address>** | Affiche la mémoire sous forme d'instruction d'assemblage. |
|
||||
| **x/b \<reg/memory address>** | Affiche la mémoire sous forme de byte. |
|
||||
| **print object (po)** | <p>Cela affichera l'objet référencé par le paramètre</p><p>po $raw</p><p><code>{</code></p><p><code>dnsChanger = {</code></p><p><code>"affiliate" = "";</code></p><p><code>"blacklist_dns" = ();</code></p><p>Notez que la plupart des API ou méthodes Objective-C d'Apple renvoient des objets et doivent donc être affichées via la commande "print object" (po). Si po ne produit pas de sortie significative, utilisez <code>x/b</code></p> |
|
||||
| **memory** | <p>memory read 0x000....<br>memory read $x0+0xf2a<br>memory write 0x100600000 -s 4 0x41414141 #Écrire AAAA dans cette adresse<br>memory write -f s $rip+0x11f+7 "AAAA" #Écrire AAAA dans l'adresse</p> |
|
||||
| **memory** | <p>memory read 0x000....<br>memory read $x0+0xf2a<br>memory write 0x100600000 -s 4 0x41414141 #Écrire AAAA à cette adresse<br>memory write -f s $rip+0x11f+7 "AAAA" #Écrire AAAA à l'adresse</p> |
|
||||
| **disassembly** | <p>dis #Désassemble la fonction actuelle<br>dis -c 6 #Désassemble 6 lignes<br>dis -c 0x100003764 -e 0x100003768 # De l'une à l'autre<br>dis -p -c 4 # Commence à l'adresse actuelle à désassembler</p> |
|
||||
| **parray** | parray 3 (char \*\*)$x1 # Vérifiez le tableau de 3 composants dans le registre x1 |
|
||||
|
||||
|
@ -347,10 +539,49 @@ dtrace -n 'syscall::recv*:entry { printf("-> %s (pid=%d)", execname, pid); }' >>
|
|||
sort -u recv.log > procs.txt
|
||||
cat procs.txt
|
||||
```
|
||||
### Utilisez `netstat` ou `lsof`
|
||||
Ou utilisez `netstat` ou `lsof`
|
||||
|
||||
### Fuzzers
|
||||
|
||||
#### [AFL++](https://github.com/AFLplusplus/AFLplusplus)
|
||||
|
||||
Fonctionne pour les outils CLI
|
||||
|
||||
#### [Litefuzz](https://github.com/sec-tools/litefuzz)
|
||||
|
||||
Il fonctionne "**juste"** avec les outils GUI de macOS. Notez que certaines applications macOS ont des exigences spécifiques telles que des noms de fichiers uniques, la bonne extension, la nécessité de lire les fichiers à partir du sandbox (`~/Library/Containers/com.apple.Safari/Data`)...
|
||||
|
||||
Quelques exemples:
|
||||
|
||||
{% code overflow="wrap" %}
|
||||
```bash
|
||||
# iBooks
|
||||
litefuzz -l -c "/System/Applications/Books.app/Contents/MacOS/Books FUZZ" -i files/epub -o crashes/ibooks -t /Users/test/Library/Containers/com.apple.iBooksX/Data/tmp -x 10 -n 100000 -ez
|
||||
|
||||
# -l : Local
|
||||
# -c : cmdline with FUZZ word (if not stdin is used)
|
||||
# -i : input directory or file
|
||||
# -o : Dir to output crashes
|
||||
# -t : Dir to output runtime fuzzing artifacts
|
||||
# -x : Tmeout for the run (default is 1)
|
||||
# -n : Num of fuzzing iterations (default is 1)
|
||||
# -e : enable second round fuzzing where any crashes found are reused as inputs
|
||||
# -z : enable malloc debug helpers
|
||||
|
||||
# Font Book
|
||||
litefuzz -l -c "/System/Applications/Font Book.app/Contents/MacOS/Font Book FUZZ" -i input/fonts -o crashes/font-book -x 2 -n 500000 -ez
|
||||
|
||||
# smbutil (using pcap capture)
|
||||
litefuzz -lk -c "smbutil view smb://localhost:4455" -a tcp://localhost:4455 -i input/mac-smb-resp -p -n 100000 -z
|
||||
|
||||
# screensharingd (using pcap capture)
|
||||
litefuzz -s -a tcp://localhost:5900 -i input/screenshared-session --reportcrash screensharingd -p -n 100000
|
||||
```
|
||||
{% endcode %}
|
||||
|
||||
### Plus d'informations sur le fuzzing MacOS
|
||||
|
||||
* [https://www.youtube.com/watch?v=T5xfL9tEg44](https://www.youtube.com/watch?v=T5xfL9tEg44)
|
||||
* [https://github.com/bnagy/slides/blob/master/OSXScale.pdf](https://github.com/bnagy/slides/blob/master/OSXScale.pdf)
|
||||
* [https://github.com/bnagy/francis/tree/master/exploitaben](https://github.com/bnagy/francis/tree/master/exploitaben)
|
||||
* [https://github.com/ant4g0nist/crashwrangler](https://github.com/ant4g0nist/crashwrangler)
|
||||
|
@ -366,7 +597,7 @@ cat procs.txt
|
|||
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
||||
|
||||
* Travaillez-vous dans une entreprise de **cybersécurité** ? Voulez-vous voir votre entreprise annoncée dans HackTricks ? ou voulez-vous avoir accès à la **dernière version de PEASS ou télécharger HackTricks en PDF** ? Consultez les [**PLANS D'ABONNEMENT**](https://github.com/sponsors/carlospolop) !
|
||||
* Découvrez [**The PEASS Family**](https://opensea.io/collection/the-peass-family), notre collection exclusive de [**NFTs**](https://opensea.io/collection/the-peass-family)
|
||||
* Découvrez [**The PEASS Family**](https://opensea.io/collection/the-peass-family), notre collection exclusive de [**NFT**](https://opensea.io/collection/the-peass-family)
|
||||
* Obtenez le [**swag officiel PEASS & HackTricks**](https://peass.creator-spring.com)
|
||||
* **Rejoignez le** [**💬**](https://emojipedia.org/speech-balloon/) [**groupe Discord**](https://discord.gg/hRep4RUj7f) ou le [**groupe telegram**](https://t.me/peass) ou **suivez** moi sur **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks\_live)**.**
|
||||
* **Partagez vos astuces de piratage en soumettant des PR au** [**repo hacktricks**](https://github.com/carlospolop/hacktricks) **et au** [**repo hacktricks-cloud**](https://github.com/carlospolop/hacktricks-cloud).
|
||||
|
|
Loading…
Add table
Reference in a new issue