mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-15 01:23:04 -07:00
add a helper script to decode SPI flash JEDEC data
Signed-off-by: ANTodorov <ANTodorov@users.noreply.github.com>
This commit is contained in:
parent
c083d319ec
commit
f0862c9ee2
2 changed files with 87 additions and 0 deletions
|
@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
|
||||||
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
|
||||||
|
|
||||||
## [unreleased][unreleased]
|
## [unreleased][unreleased]
|
||||||
|
- add a helper script to decode JEDEC data `script run spi_flash_decode` (@ANTodorov)
|
||||||
- show SPI flash JEDEC Manufacturer ID and Device ID in `hw status` output (@ANTodorov)
|
- show SPI flash JEDEC Manufacturer ID and Device ID in `hw status` output (@ANTodorov)
|
||||||
- Improved `hf iclass configcards` to support generating config cards using a different key than the default k0 as the card's key (@antiklesys)
|
- Improved `hf iclass configcards` to support generating config cards using a different key than the default k0 as the card's key (@antiklesys)
|
||||||
- Added maur keys (@iceman1001)
|
- Added maur keys (@iceman1001)
|
||||||
|
|
86
client/pyscripts/spi_flash_decode.py
Normal file
86
client/pyscripts/spi_flash_decode.py
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import re
|
||||||
|
import pm3
|
||||||
|
# optional color support
|
||||||
|
try:
|
||||||
|
# pip install ansicolors
|
||||||
|
from colors import color
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
def color(s, fg=None):
|
||||||
|
_ = fg
|
||||||
|
return str(s)
|
||||||
|
|
||||||
|
spi = {
|
||||||
|
0x85:{
|
||||||
|
"manufacturer": "Puya",
|
||||||
|
0x60: {
|
||||||
|
0x15: {
|
||||||
|
"part": "P25Q16H",
|
||||||
|
"size": "16mbits",
|
||||||
|
"sizeB": "2MB",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
0xEF:{
|
||||||
|
"manufacturer": "Winbond",
|
||||||
|
0x30: {
|
||||||
|
0x11: {
|
||||||
|
"part": "W25X10BV",
|
||||||
|
"size": "1mbits",
|
||||||
|
"sizeB": "128KB",
|
||||||
|
},
|
||||||
|
0x12: {
|
||||||
|
"part": "W25X20BV",
|
||||||
|
"size": "2mbits",
|
||||||
|
"sizeB": "256KB",
|
||||||
|
},
|
||||||
|
0x13: {
|
||||||
|
"part": "W25X40BV",
|
||||||
|
"size": "4mbits",
|
||||||
|
"sizeB": "512KB",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
0x70: {
|
||||||
|
0x22: {
|
||||||
|
"part": "W25Q02JV-IM",
|
||||||
|
"size": "2mbits",
|
||||||
|
"sizeB": "256KB",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
p = pm3.pm3()
|
||||||
|
|
||||||
|
p.console("hw status")
|
||||||
|
|
||||||
|
rex = re.compile("...\s([0-9a-fA-F]{2})\s/\s([0-9a-fA-F]{4})")
|
||||||
|
for line in p.grabbed_output.split('\n'):
|
||||||
|
# [#] JEDEC Mfr ID / Dev ID... 85 / 6015
|
||||||
|
if " JEDEC " not in line:
|
||||||
|
continue
|
||||||
|
match = re.findall(rex, line)
|
||||||
|
mid = int(match[0][0], 16)
|
||||||
|
did = int(match[0][1], 16)
|
||||||
|
did_h = did >> 8
|
||||||
|
did_l = did & 0xff
|
||||||
|
t = None
|
||||||
|
if mid in spi:
|
||||||
|
mfr = spi[mid]['manufacturer']
|
||||||
|
if did_h in spi[mid]:
|
||||||
|
if did_l in spi[mid][did_h]:
|
||||||
|
t = spi[mid][did_h][did_l]
|
||||||
|
print("\n Manufacturer... " + color(f"{mfr}", fg="green") +
|
||||||
|
"\n Device......... " + color(f"{t['part']}", fg="green") +
|
||||||
|
"\n Size........... " + color(f"{t['size']} ({t['sizeB']})", fg="yellow")
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
print("\n Manufacturer... " + color(f"{mfr}", fg="green") +
|
||||||
|
"\n Device ID...... " + color(f"{did:04X}h (unknown)", fg="red"))
|
||||||
|
else:
|
||||||
|
print("\n Manufacturer... " + color(f"{mfr}", fg="green") +
|
||||||
|
"\n Device ID...... " + color(f"{did:04X}h (unknown)", fg="red"))
|
||||||
|
else:
|
||||||
|
print("\n Manufacturer... " + color(f"{mid:02X}h (unknown)", fg="red") +
|
||||||
|
"\n Device ID...... " + color(f"{did:04X}h (unknown)", fg="red"))
|
Loading…
Add table
Add a link
Reference in a new issue