Rids

Catégorie: Hardware Difficulté: easy Flag: HTB{m3m02135_57023_53c2375_f02_3v32y0n3_70_533!@}

Challenge

Description


Upon reaching the factory door, you physically open the RFID lock and find a flash memory chip inside. The chip's package has the word W25Q128 written on it. Your task is to uncover the secret encryption keys stored within so the team can generate valid credentials to gain access to the facility.

Résolution

Dans l’énoncé on nous parle de chipset W25Q128 et dans le code on voit jedec_id. Une rapide recherche google nous emmène sur la communication SPI.

En poussant les recherches, on trouve la liste des commandes existantes, 0x9F qui est envoyé dans le code source que nous avons correspond au READ ID

Ce qui nous intéresse c’est de lire les données en retour, on peut donc envoyé avec le même script 0x03 , la seconde valeur passée en paramètre à exchange correspond à readlen un peu plus loin, autrement dit c’est le nombre de bytes retour que l’on attend.


Script de résolution

import socket
import json

def exchange(hex_list, value=0):
	# Configure according to your setup
	host = '94.237.54.170'  # The server's hostname or IP address
	port = 37140  # The port used by the server
	cs = 0  # /CS on A*BUS3 (range: A*BUS3 to A*BUS7)

	usb_device_url = 'ftdi://ftdi:2232h/1'

	# Convert hex list to strings and prepare the command data
	command_data = {
		"tool": "pyftdi",
		"cs_pin": cs,
		"url": usb_device_url,
		"data_out": [hex(x) for x in hex_list],  # Convert hex numbers to hex strings
		"readlen": value
	}

	with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
		s.connect((host, port))

		# Serialize data to JSON and send
		s.sendall(json.dumps(command_data).encode('utf-8'))

		# Receive and process response
		data = b''
		while True:
			data += s.recv(1024)
			if data.endswith(b']'):
				break

		response = json.loads(data.decode('utf-8'))
	# print(f"Received: {response}")
	return response

data = exchange([0x03], 49)
print(''.join([chr(n) for n in data]))

Dernière mise à jour

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