Phreaky

Catégorie: Forensics Difficulté: medium Flag: HTB{Th3Phr3aksReadyT0Att4ck}

Challenge

Description


In the shadowed realm where the Phreaks hold sway, A mole lurks within leading them astray. Sending keys to the Talents, so sly and so slick, A network packet capture must reveal the trick. Through data and bytes, the sleuth seeks the sign, Decrypting messages, crossing the line. The traitor unveiled, with nowhere to hide, Betrayal confirmed, they'd no longer abide.

Analyse du trafic

Dans le .pcap fourni on peut remarquer des échanges SMTP, c’est à dire des mails, entre [email protected] et [email protected]

Si l’on suit le flux TCP, on peut retrouver le contenu du mail

Notamment dans le mail, on voit la phrase “Attached is a part of the file. Password: S3w8yzixNoL8

En fait il y a 15 mails qui ont tous cette forme là :

  • Un zip chiffré joint

  • Le mot de passe associé au zip

On peut alors créer un script pour tout récupérer et concaténer pour récupérer le PDF final

from io import BytesIO
import pyshark
from base64 import b64decode
import zipfile

# Extrait le fichier du zip chiffré
def extract_zip(data: bytes, pwd: bytes) -> bytes:
	zf = zipfile.ZipFile(BytesIO(data), 'r')
	return zf.read(zf.filelist[0].filename, pwd=pwd)

def solve():
  # Fichier que nous allons récupérer au fil des mails
	file = b''
	# Lecture du fichier de capture
	packets = pyshark.FileCapture('phreaky.pcap', display_filter='smtp')
	for packet in packets:
		# Si le paquet contient des données
		if 'data_reassembled_length' in packet.smtp.field_names:
		  # Parsing des données pour récupérer le mot de passe dans le corps du mail
			password = bytes.fromhex(packet.imf.mime_multipart_part).split(b'Password: ')[1].strip()
			# Parsing pour récupérer le zip attaché au mail
			zf_data = b64decode(bytes.fromhex(packet.imf.media_type.replace(':', '')))
			file += extract_zip(zf_data, password)
	with open('phreaks_plan.pdf', 'wb') as f:
		f.write(file)

if __name__ == '__main__':
	solve()

On se retrouve alors avec un PDF valide qui contient le flag

Dernière mise à jour

Cet article vous a-t-il été utile ?