Did stuff

This commit is contained in:
Liliesh 2024-11-03 08:54:16 +01:00
parent f20bcac9a9
commit 621021d43e
Signed by: liliesh
GPG key ID: 680387646C7BAE8E
6 changed files with 60 additions and 21 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@
sections/ sections/
*.zip *.zip
X570PG4*.* X570PG4*.*
*.extracted/

16
X570PG4/README.md Normal file
View file

@ -0,0 +1,16 @@
# ASRock X570 Phantom Gaming 4 FW
## Steps
1. download fw
2. binwalk
## Mappings
to be done
Take over from old doc:
- 4456808 = lzma = jpg images / boot splash
- 4591952 = lzma = windows pe binaries - unknown usage
- 4633968 = lzma = win-pe bins, aes-s box
Convinent:

View file

@ -1,19 +0,0 @@
= Reversing of the AsRock X570 Phantom Gaming 4 firmware image
== Steps
1. download fw
2. binwalk
== Mappings
=== 4456808
Compressed lzma
Contains boot images
|===
| Start, Length, Type, Description
| 4456808, 15525, LZMA Archive, Boot splash images
|===
4456808 = lzma = jpg images
4591952 = lzma = windows pe binaries - unknown usage
4633968 = lzma = win-pe bins, aes-s box

View file

@ -1,2 +1,3 @@
wget "https://download.asrock.com/BIOS/AM4/X570%20Phantom%20Gaming%204(5.60)ROM.zip" -O ASX570FW.zip wget "https://download.asrock.com/BIOS/AM4/X570%20Phantom%20Gaming%204(5.60)ROM.zip" -O X570PG4.zip
7z x ASX570FW.zip 7z x X570PG4.zip
rm X570PG4.zip

7
X570PG4/extract.sh Normal file → Executable file
View file

@ -14,3 +14,10 @@ mkdir sections/4591952
dd if=X570PG45.60 skip=4591952 bs=1 count=41951 of=sections/4591952/image.lzma dd if=X570PG45.60 skip=4591952 bs=1 count=41951 of=sections/4591952/image.lzma
unlzma sections/4591952/image.lzma unlzma sections/4591952/image.lzma
dd if=sections/4591952/image skip=204 bs=1 count=2020 of=sections/4591952/204.bin dd if=sections/4591952/image skip=204 bs=1 count=2020 of=sections/4591952/204.bin
# Section 23732584
echo "Extracting 23732584"
mkdir sections/23732584
dd if=X570PG45.60 skip=23732584 bs=1 count=15525 of=sections/23732584/image.lzma
unlzma sections/23732584/image.lzma

33
X570PG4/magic.py Normal file
View file

@ -0,0 +1,33 @@
import os
import io
def search_filetype(filePath, magicBytes):
with io.open(filePath, mode="rb") as file:
for line in file:
if magicBytes in line:
offset = file.tell()
print(f"Found at {hex(offset)}!")
def extract_jpeg(filePath, offset):
image = b''
with io.open(filePath, mode="rb") as file:
file.seek(offset)
for line in file:
if jpeg_sig not in line:
image += line
f = open(f"test/{offset}.jpeg", "a")
f.write(image)
f.close()
xz_sig = b'\x5d\x00\x00'
#tiff_sig = b'\x49\x49\x2A\x00'
#jpeg_sig = b'\xFF\xD8\xFF\xE0'
print("Searching for LZMA..")
search_filetype("X570PG45.60", xz_sig)
#print("Searching for TIFF...")
#search_filetype("X570PG45.60", tiff_sig)
#print("Searching for JPEG...")
#search_filetype("X570PG45.60", jpeg_sig)