NTFS

Catégorie: Forensique

Points: 50

Description:

NTFS

Fichiers: ntfs.7z

Note: Les organisateurs du challenge n'autorisent pas la mise à disposition des sources.

TL;DR

Un fichier est retrouvé dans une partition NTFS grace à la MFT.

Méthodologie

On commence avec une archive 7z.

>_ file -k ntfs.7z
ntfs2.7z: 7-zip archive data, version 0.4\012- data

On décompresse l'archive.

>_ 7z e ntfs2.7z

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

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

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

Enter password (will not be echoed):
ERROR: Data Error in encrypted file. Wrong password? : for_medium.img

Sub items Errors: 1

Archives with Errors: 1

Sub items Errors: 1

Super on a une archive chiffrée et on a aucune info pour récupérer le mot de passe !

On va tenter un bruteforce avec rockyou.txt. Le problème est que John et Hashcat ne parviennent pas à générer correctement un hash de l'archive.

meme_crack_7z

Une petite recherche sur github et on trouve un petit script qui nous fait ça très bien.

>_ 7z_bruteforce.py ntfs.7z rockyou.txt
Password found: infected

Et maintenant on peut extraire le fichier for_medium.img.

>_ 7z e ntfs.7z

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,8 CPUs Intel(R) Core(TM) i5-8350U CPU @ 1.70GHz (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):
Everything is Ok     

Size:       2684354560
Compressed: 28439786

On obtient une image ntfs. D'où le titre du chall !

>_ file -k for_medium.img
for_medium.img: DOS/MBR boot sector, code offset 0x52+2, OEM-ID "NTFS    ", sectors/cluster 8, Media descriptor 0xf8, sectors/track 0, dos < 4.0 BootSector (0x80), FAT (1Y bit by descriptor); NTFS, sectors 5242879, $MFT start cluster 4, $MFTMirror start cluster 327679, bytes/RecordSegment 2^(-1*246), clusters/index block 1, serial number 01d66d0eb2ff5e7f3\012- DOS/MBR boot sector\012-  DOS/MBR boot sector DOS executable (COM), boot code\012-  (Lepton 3.x), scale 0-0, spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000\012-  (Lepton 2.x), scale 0-0, spot sensor temperature 0.000000, unit celsius, color scheme 0, calibration: offset 0.000000, slope 0.000000\012- data

>_ fdisk -l for_medium.img
Disk for_medium.img: 2.51 GiB, 2684354560 bytes, 5242880 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device          Boot Start     End Sectors  Size Id Type
for_medium.img1       2048 5242879 5240832  2.5G 87 NTFS volume set

Premier réflexe, on sait jamais !

>_ strings for_medium.img| grep --color=auto -i ecw
https://challenge-ecw.fr/
https://challenge-ecw.fr/
rc:ecW6
ecw_
EcW"
3pEcw
FECw
ECWA
eCW^>
)ECW
EcW"
3pEcw
HECw
becWl
ECWA
eCW^>
)ECW
EcW"
3pEcw

On monte l'image pour voir ce qu'il y a dedans.

>_ sudo mount -t auto -o loop for_medium.img usb
[sudo] password for lambdhack:

>_ cd usb

>_ ls -al
total 13046
drwxrwxrwx 1 root      root     4096 Mar 25  2019 ./
drwxr-xr-x 9 lambdhack users    4096 Oct 24 21:37 ../
drwxrwxrwx 1 root      root     4096 Mar 22  2019 divers/
drwxrwxrwx 1 root      root     4096 Oct  6 12:47 .download/
-rwxrwxrwx 1 root      root   661506 Mar 22  2019 guide_802.1x_anssi_pa_043_v1.pdf
-rwxrwxrwx 1 root      root  1761720 Mar 22  2019 guide_admin_securisee_si_anssi_pa_022_v2.pdf
-rwxrwxrwx 1 root      root   752146 Mar 22  2019 guide-charte-utilisation-moyens-informatiques-outils-numeriques_anssi.pdf
-rwxrwxrwx 1 root      root   495875 Mar 22  2019 guide_cloisonnement_systeme_anssi_pg_040_v1.pdf
-rwxrwxrwx 1 root      root  4793303 Mar 22  2019 guide_hygiene_informatique_anssi.pdf
-rwxrwxrwx 1 root      root  2659730 Mar 22  2019 guide-methode-ebios-risk-manager.pdf
-rwxrwxrwx 1 root      root  1002452 Mar 22  2019 guide_sns_anssi_bp_031_v.2.0.pdf
-rwxrwxrwx 1 root      root      180 Mar 25  2019 liens_utiles.txt
-rwxrwxrwx 1 root      root      225 Mar 25  2019 liens_utiles.txt~
-rwxrwxrwx 1 root      root   997307 Mar 22  2019 linux_configuration-fr-v1.2.pdf
-rwxrwxrwx 1 root      root   188936 Mar 22  2019 np_cryhod_notetech.pdf
drwxrwxrwx 1 root      root     4096 Mar 22  2019 reseau/
-rwxrwxrwx 1 root      root        0 Mar 22  2019 tmp
-rwxrwxrwx 1 root      root       36 Mar 22  2019 tools.pdf
drwxrwxrwx 1 root      root        0 Mar 22  2019 windows/

Le dossier .download a l'air intéressant mais c'est juste un troll.

>_ ls -al .download
total 3688
drwxrwxrwx 1 root root    4096 Oct  6 12:47 ./
drwxrwxrwx 1 root root    4096 Mar 25  2019 ../
-rwxrwxrwx 1 root root  374318 Mar 22  2019 27158365900_6d256cfae8_h.jpg
-rwxrwxrwx 1 root root   64526 Mar 25  2019 clue.jpg
-rwxrwxrwx 1 root root   77140 Mar 25  2019 ECW_flag_test.jpg
-rwxrwxrwx 1 root root  108838 Mar 25  2019 example.jpg
-rwxrwxrwx 1 root root 3136473 Mar 22  2019 Red_Kitten_01.jpg

27158365900_6d256cfae8_h.jpg clue.jpg ECW_flag_test.jpg example.jpg Red_Kitten_01.jpg

En comparrant les 2 fichiers liens_utiles on obtient un site qui a l'air intéressant.

>_ cat liens_utiles.txt
https://www.thalesgroup.com/fr
https://github.com/swisskyrepo/PayloadsAllTheThings
https://guif.re/windowseop
https://hausec.com/
https://adsecurity.org/
https://challenge-ecw.fr/

>_ cat liens_utiles.txt\~
https://www.thalesgroup.com/fr
https://github.com/swisskyrepo/PayloadsAllTheThings
https://guif.re/windowseop
https://hausec.com/
https://adsecurity.org/
https://challenge-ecw.fr/
https://6215a8ee0353577b9a296542095b6eef.io/

Apres recherche, le site n'existe pas et crackstation ne parvient pas à cracker le hash.

Peut etre qu'on aura plus de chance avec foremost.

>_ foremost for_medium.img
Processing: for_medium.img
|**************************|

>_ tree
.
├── for_medium.img
└── output
    ├── audit.txt
    ├── jpg
    │   ├── 00721864.jpg
    │   ├── 00722113.jpg
    │   ├── 00788688.jpg
    │   ├── 00886672.jpg
    │   ├── 01049912.jpg
    │   ├── 01050064.jpg
    │   ├── 01282240.jpg
    │   ├── 01315008.jpg
    │   ├── 01315744.jpg
    │   ├── 01315872.jpg
    │   └── 01381376.jpg
    └── pdf
        ├── 00656352.pdf
        ├── 00689088.pdf
        ├── 00754624.pdf
        ├── 00787392.pdf
        ├── 00820160.pdf
        ├── 00852928.pdf
        ├── 00885696.pdf
        ├── 00918464.pdf
        ├── 00951232.pdf
        ├── 00984000.pdf
        ├── 01016768.pdf
        ├── 01049536.pdf
        ├── 01082304.pdf
        ├── 01115072.pdf
        ├── 01180608.pdf
        ├── 01213376.pdf
        ├── 01246144.pdf
        └── 01278912.pdf

3 directories, 31 files

Il y a plus d'images mais ce ne sont que les miniatures des images déjà trouvées.

Comme on a rien en montant la partition et que des outils comme binwalk/foremost ne nous donnent rien on va tenter une autre approche.

we_need_to_go_deeper

On va utiliser testdisk qui est très pratique pour aller fouiller dans des images de disque. Comme le NTFS est un système de journalisation de fichiers, testdisk va nous permettre d'aller récupérer des fichiers potentiellement supprimés grace à la MFT.

nb: On re-extrait l'image de l'archive car en la montant on a peut etre modifié voir supprimé des données de journalisation.

On ouvre notre image avec testdisk et on choisi Proceed pour commencer.

>_ testdisk for_medium.img
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

>[Proceed ]  [  Sudo  ]  [  Quit  ]

Comme on a une partition NTFS on choisi None que tesdisk nous propose par défaut.

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

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

Hint: None partition table type has been detected.
Note: Do NOT select 'None' for media with only a single partition. It's very
rare for a disk to be 'Non-partitioned'.

On sélectionne Advanced.

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

Disk for_medium.img - 2684 MB / 2560 MiB
     CHS 327 255 63 - sector size=512

 [ 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

Note: Correct disk geometry is required for a successful recovery. 'Analyse'
process may give some warnings if it thinks the logical geometry is mismatched.

On liste les fichiers qui se trouvent dans la partition.

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

Disk for_medium.img - 2684 MB / 2560 MiB - CHS 327 255 63

     Partition                  Start        End    Size in sectors
>   P NTFS                     0   0  1   326  90 20    5242880

 [  Type  ]  [  Boot  ] >[  List  ]  [Undelete]  [Image Creation]  [  Quit  ]
                              Boot sector recovery

On regarde si de nouveaux fichiers ou dossiers apparaissent en comparant avec ce qu'on avait dans notre image montée mais on n'a rien de nouveau.

TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
   P NTFS                     0   0  1   326  90 20    5242880
Directory /

>dr-xr-xr-x     0     0         0 24-Oct-2019 21:42 .
 dr-xr-xr-x     0     0         0 24-Oct-2019 21:42 ..
 dr-xr-xr-x     0     0         0  6-Oct-2019 12:47 .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_ans
 -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

                                                   Next
Use Right to change directory, h to hide Alternate Data Stream
    q to quit, : to select the current file, a to select all files
    C to copy the selected files, c to copy the current file

TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
   P NTFS                     0   0  1   326  90 20    5242880
Directory /.download

>dr-xr-xr-x     0     0         0  6-Oct-2019 12:47 .
 dr-xr-xr-x     0     0         0 24-Oct-2019 21:42 ..
 -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

                                                   Next
Use Left arrow to go back, Right to change directory, h to hide Alternate Data Stream
    q to quit, : to select the current file, a to select all files
    C to copy the selected files, c to copy the current file

On fait marche arrière et on va voir les fichiers supprimés.

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

Disk for_medium.img - 2684 MB / 2560 MiB - CHS 327 255 63

     Partition                  Start        End    Size in sectors
>   P NTFS                     0   0  1   326  90 20    5242880

 [  Type  ]  [  Boot  ]  [  List  ] >[Undelete]  [Image Creation]  [  Quit  ]
                                 File undelete

Et la on obtient 5 fichiers qui se trouvaient dans le dossier .download.

TestDisk 7.0, Data Recovery Utility, April 2015
Christophe GRENIER <grenier@cgsecurity.org>
http://www.cgsecurity.org
   P NTFS                     0   0  1   326  90 20    5242880
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/Z..Z.Z...ZZ.Z.ZZ                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/Z..Z.ZZ....Z.ZZZ                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/Z..Z.ZZ.Z..Z.Z.Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/Z..ZZ....ZZ.Z.ZZ                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/Z..ZZ.Z.Z...Z..Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/Z..ZZ.ZZ.ZZ...ZZ                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/Z.Z.Z....Z..Z..Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/Z.Z.ZZZ..Z.....Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/Z.ZZZZ..ZZ.ZZZ.Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/Z.ZZZZZZ...ZZ..Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZ.....Z...ZZ.ZZ                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZ...ZZ.Z...ZZZZ                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZ.Z..ZZ.ZZZZZZZ                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZ.ZZ.Z....ZZZ.Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZ.ZZ.ZZZZZZZ..Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZ.ZZZZ...ZZZ.ZZ                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZZ...ZZZZ.Z.Z.Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZZ.Z.Z.ZZ..Z.ZZ                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZZ.Z.ZZZZZZ.ZZZ                                                          25-Mar-2019 14:06       592
 Z..Z..ZZ...Z..ZZ/ZZZ.ZZZZZ.Z.Z..Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZZZ.ZZ....Z...Z                                                          25-Mar-2019 14:06       600
 Z..Z..ZZ...Z..ZZ/ZZZZ.ZZ.ZZ.....Z                                                          25-Mar-2019 14:06       600

Use : to select the current file, a to select/deselect all files,
    C to copy the selected files, c to copy the current file, q to quit

On extrait tout les fichiers et on regarde ce que c'est.

>_ file -k .download/*
.download/ECW_flag.jpg:       JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, progressive, precision 8, 642x389, components 3\012- data
.download/methodology.jpg:    JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, progressive, precision 8, 500x701, components 3\012- data
.download/special_kitten.png: PNG image data, 8000 x 4500, 8-bit/color RGBA, non-interlaced\012- data
.download/toto.png:           PNG image data, 8000 x 4500, 8-bit/color RGBA, non-interlaced\012- data
.download/toto.png:ads:       ASCII text, with CRLF line terminators
>_ cat toto.png:ads
toto 

ECW_flag methodology special_kitten toto

On obtient 2 trolls de plus et 2 images quasiment identiques.

>_ exiftool toto.png
ExifTool Version Number         : 11.50
File Name                       : toto.png
Directory                       : .
File Size                       : 1649 kB
File Modification Date/Time     : 2019:03:25 13:15:15+01:00
File Access Date/Time           : 2019:10:24 22:37:01+02:00
File Inode Change Date/Time     : 2019:10:24 22:36:37+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
Artist                          : FLAG
Image Size                      : 8000x4500
Megapixels                      : 36.0

>_ exiftool special_kitten.png
ExifTool Version Number         : 11.50
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:10:24 22:37:01+02:00
File Inode Change Date/Time     : 2019:10:24 22:36:37+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
Artist                          : calculate Message Digest 5 of file and add one
Image Size                      : 8000x4500
Megapixels                      : 36.0

La seule chose qui change entre ces 2 images c'est le nom de l'artiste. On comprend vite que pour obtenir notre flag, il faut prendre le md5 de special_kitten.png puis ajouter 1.

>_ md5sum special_kitten.png
3d9382f08cd82a430a59343b21934752  special_kitten.png

Flag_is:

ECW{3d9382f08cd82a430a59343b21934753}