ECW - NTFS

Posted on jeu. 10 octobre 2019 in CTF

On récupère pour ce challenge un fichier compressé via 7zip. On peut donc l'ouvrir mais on obtiens une demande de mot de passe :

$ 7z e ntfs.7z 

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=fr_FR.UTF-8,Utf16=on,HugeFiles=on,64 bits,8 CPUs Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (806EA),ASM,AES-NI)

Scanning the drive for archives:
1 file, 28439786 bytes (28 MiB)

Extracting archive: ntfs.7z
--
Path = ntfs.7z
Type = 7z
Physical Size = 28439786
Headers Size = 170
Method = LZMA2:26 7zAES
Solid = -
Blocks = 1


Enter password (will not be echoed):

On doit donc commencer par trouver ce mot de passe. On peut cependant lister le contenu de l'archive et y voir le contenu :

$ 7z l ntfs.7z 

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=fr_FR.UTF-8,Utf16=on,HugeFiles=on,64 bits,8 CPUs Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (806EA),ASM,AES-NI)

Scanning the drive for archives:
1 file, 28439786 bytes (28 MiB)

Listing archive: ntfs.7z

--
Path = ntfs.7z
Type = 7z
Physical Size = 28439786
Headers Size = 170
Method = LZMA2:26 7zAES
Solid = -
Blocks = 1

   Date      Time    Attr         Size   Compressed  Name
------------------- ----- ------------ ------------  ------------------------
2019-03-25 17:09:16 ....A   2684354560     28439616  for_medium.img
------------------- ----- ------------ ------------  ------------------------
2019-03-25 17:09:16         2684354560     28439616  1 files

On commence avec johntheripper pour trouver le mot de passe. Il faut cependant utiliser un script afin de lui donner le hash pourqu'il puisse travailler dessus. On trouve facilement 7z2john :

$ python2 7z2john.py ntfs.7z
ntfs.7z : 7-Zip files without header encryption are *not* supported yet!

Ok, échec critique. On peut tenter avec hashcat. On aura peut-être plus de chance. Idem, trouve un script, 7z2hashcat, pour générer le hash :

perl 7z2hashcat.pl ntfs.7z 
WARNING: the file 'ntfs.7z' unfortunately can't be used with hashcat since the data length
in this particular case is too long (28439616 of the maximum allowed 327528 bytes).

Double échec.

On part donc à la recherche d'un autre outil. En cherchant, on trouve Kraken. Outil Windows permettant de brute-force un mot de passe sur une archive à partir d'un dictionnaire. On récupère l'exécutable et le dictionnaire rockyou.

On le lance, on patiente et HOP. On a notre mot de passe qui s'affiche :

ntfs_1.png

Parfait ! On a donc notre mot de passe et on peut enfin avoir son contenu.

C'est une image disque. On peut donc l'ouvrir avec testdisk pour y explorer le contenu :

TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org

  TestDisk is free software, and
comes with ABSOLUTELY NO WARRANTY.

Select a media (use Arrow keys, then press Enter):
>Disk for_medium.img - 2684 MB / 2560 MiB
Please select the partition table type, press Enter when done.
 [Intel  ] Intel/PC partition
 [EFI GPT] EFI GPT partition map (Mac i386, some x86_64...)
 [Humax  ] Humax partition table
 [Mac    ] Apple partition map
>[None   ] Non partitioned media
 [Sun    ] Sun Solaris partition
 [XBox   ] XBox partition
 [Return ] Return to disk selection
 [ Analyse  ] Analyse current partition structure and search for lost partitions
>[ Advanced ] Filesystem Utils
 [ Geometry ] Change disk geometry
 [ Options  ] Modify options
 [ Quit     ] Return to disk selection
     Partition                  Start        End    Size in sectors
>   P NTFS                     0   0  1   326  90 20    5242880

On prend List

>dr-xr-xr-x     0     0         0 25-Mar-2019 14:07 .
 dr-xr-xr-x     0     0         0 25-Mar-2019 14:07 ..
 dr-xr-xr-x     0     0         0 25-Mar-2019 16:10 .download
 dr-xr-xr-x     0     0         0 22-Mar-2019 17:54 divers
 dr-xr-xr-x     0     0         0 22-Mar-2019 17:54 reseau
 dr-xr-xr-x     0     0         0 22-Mar-2019 17:54 windows
 -r--r--r--     0     0    752146 22-Mar-2019 17:54 guide-charte-utilisation-moyens-informatiques-outils-numeriques_anssi.pdf
 -r--r--r--     0     0   2659730 22-Mar-2019 17:54 guide-methode-ebios-risk-manager.pdf
 -r--r--r--     0     0    661506 22-Mar-2019 17:54 guide_802.1x_anssi_pa_043_v1.pdf
 -r--r--r--     0     0   1761720 22-Mar-2019 17:54 guide_admin_securisee_si_anssi_pa_022_v2.pdf
 -r--r--r--     0     0    495875 22-Mar-2019 17:54 guide_cloisonnement_systeme_anssi_pg_040_v1.pdf
 -r--r--r--     0     0   4793303 22-Mar-2019 17:54 guide_hygiene_informatique_anssi.pdf
 -r--r--r--     0     0   1002452 22-Mar-2019 17:54 guide_sns_anssi_bp_031_v.2.0.pdf
 -r--r--r--     0     0       180 25-Mar-2019 11:14 liens_utiles.txt
 -r--r--r--     0     0       225 25-Mar-2019 11:14 liens_utiles.txt~
 -r--r--r--     0     0    997307 22-Mar-2019 17:54 linux_configuration-fr-v1.2.pdf
 -r--r--r--     0     0    188936 22-Mar-2019 17:54 np_cryhod_notetech.pdf
 -r--r--r--     0     0         0 22-Mar-2019 17:29 tmp
 -r--r--r--     0     0        36 22-Mar-2019 17:54 tools.pdf

On voit un dossier .download qui semble prometteur :

Directory /.download

>dr-xr-xr-x     0     0         0 25-Mar-2019 16:10 .
 dr-xr-xr-x     0     0         0 25-Mar-2019 14:07 ..
 -r--r--r--     0     0    374318 22-Mar-2019 18:05 27158365900_6d256cfae8_h.jpg
 -r--r--r--     0     0     77140 25-Mar-2019 15:42 ECW_flag_test.jpg
 -r--r--r--     0     0   3136473 22-Mar-2019 18:05 Red_Kitten_01.jpg
 -r--r--r--     0     0     64526 25-Mar-2019 15:44 clue.jpg
 -r--r--r--     0     0    108838 25-Mar-2019 15:42 example.jpg

On regarde alors nos fichiers images :

ntfs_clue1.jpg

ntfs_clue2.jpg

ntfs_clue3.jpg

Pas super concluant, mais très bon humour de la part du créateur ;).

Voyons voir du coup du côté des fichiers supprimés mais récupérable. On sélectionne undelete dans le menu du bas :

Deleted files

>./3590F75ABA9E485486C100C1A9D4FF06NKQITXGIIGQUSKWT  25-Mar-2019 14:07 261795840
 /.download/ECW_flag.jpg                             25-Mar-2019 15:42     52746
 /.download/methodology.jpg                          25-Mar-2019 15:43    113105
 /.download/special_kitten.png                       25-Mar-2019 16:08   1688578
 /.download/toto.png                                 25-Mar-2019 13:15   1688536
 /.download/toto.png:ads                             25-Mar-2019 13:15         7
 Z..Z..ZZ...Z..ZZ/Z....ZZZ.ZZ.ZZZZ                   25-Mar-2019 14:06       592
 Z..Z..ZZ...Z..ZZ/Z...Z..ZZ..Z.ZZZ                   25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/Z..Z....Z.Z...ZZ                   25-Mar-2019 14:06       600
 [...]
 Z..Z..ZZ...Z..ZZ/Z..Z..Z..ZZZZ.ZZ                   25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZZZ.ZZ.ZZ.....Z                   25-Mar-2019 14:06       600

Ok. On a donc bien d'autres images à récupérer. On les extraits depuis l'image sur le poste en local.

$ ls -al
total 3480
drwxr-xr-x 2 nlegall nlegall    4096 oct.  24 12:58 .
drwxr-xr-x 3 nlegall nlegall    4096 oct.  24 12:57 ..
-rw------- 1 nlegall nlegall   52746 mars  25  2019 ECW_flag.jpg
-rw------- 1 nlegall nlegall  113105 mars  25  2019 methodology.jpg
-rw------- 1 nlegall nlegall 1688578 mars  25  2019 special_kitten.png
-rw------- 1 nlegall nlegall 1688536 mars  25  2019 toto.png
-rw------- 1 nlegall nlegall       7 mars  25  2019 toto.png:ads

Le fichier special_kitten.png ayant la plus grande taille, on peut commencer par celui-là. Fichier image dit méta-données. On utilise la commande exiftool pour les lister :

$ exiftool special_kitten.png
ExifTool Version Number         : 11.70
File Name                       : special_kitten.png
Directory                       : .
File Size                       : 1649 kB
File Modification Date/Time     : 2019:03:25 16:08:52+01:00
File Access Date/Time           : 2019:03:25 16:08:52+01:00
File Inode Change Date/Time     : 2019:10:24 12:58:30+02:00
File Permissions                : rw-------
File Type                       : PNG
File Type Extension             : png
MIME Type                       : image/png
Image Width                     : 8000
Image Height                    : 4500
Bit Depth                       : 8
Color Type                      : RGB with Alpha
Compression                     : Deflate/Inflate
Filter                          : Adaptive
Interlace                       : Noninterlaced
Pixels Per Unit X               : 11811
Pixels Per Unit Y               : 11811
Pixel Units                     : meters
Warning                         : [minor] Text chunk(s) found after PNG IDAT (may be ignored by some readers)
Artist                          : calculate Message Digest 5 of file and add one
Image Size                      : 8000x4500
Megapixels                      : 36.0

YEAH ! Un indice sur le flag apparaît alors dans le champ Artist. On exécute alors les indications :

$ md5sum special_kitten.png
3d9382f08cd82a430a59343b21934752  special_kitten.png

Et on ajoute un de plus au hash et la nomenclature :

2 + 1 = 3 => ECW{3d9382f08cd82a430a59343b21934753}

Hop ! 50 points de plus :).