Script to extract lv1 embedded selfs

Rip Cord

Administrator
Staff member
Developer
About 2 years ago PsiCoLeO released a script to extract the selfs embedded in lv1.elf for firmware versions 3.41 and 3.55. I added support for Rex firmwares 4.21.2, 4.30.2, and 441.2.

paste the script in a text editor
uncomment the 2 lines for size and offset of the applicable firmware version
save with .sh extension (lv1_extract.sh)
make it executable (chmod +x lv1_extract.sh)
use with lv1.elf (./lv1_extract.sh lv1.elf)

Code:
#!/bin/bash
# PsiCoLeO 2011
#
# Script to extract the embedded files from lv1.self
# There is no warranty that this script will work for you
# I can not be held responsable of what you do with this script or any damage you get from using it
# Use it as you please
 
# File names
files=( "pme_init" "sysmgr_ss.fself" "pme_init.conf" "ss_init.fself" "updater_frontend.fself" "ss_server1.fself" "ss_server2.fself" "ss_server3.fself" )
 
#comment and uncomment file sizes and offsets depending on the firmware
 
# File sizes 3.41
#size=( 0x24824 0x5f790 0xAF 0x34eb8 0x239F0 0x811D0 0x4A940 0x38ED0 )
 
# File offsets 3.41
#offset=( 0x1D00E8 0x1F490C 0x25409C 0x25414C 0x289004 0x2AC9F4 0x32DBC4 0x378504 )
 
# File sizes 3.55
#size=( 0x24824 0x5f790 0xAF 0x34EB8 0x239F0 0x813B8 0x4A940 0x38ED0 )
 
# File offsets 3.55
#offset=( 0x1D00E8 0x1F490C 0x25409C 0x25414C 0x289004 0x2AC9F4 0x32DDAC 0x3786EC )
 
 
#*******************************************************************************
# values for firmwares 4.21 - 4.41 have been added to PsiCoLeO's original release
 
# File sizes 4.21
#size=( 0x217D8 0x5FBC8 0xAF 0x35058 0x239F0 0x81890 0x4ACE0 0x39080 )
 
# File offsets 4.21
#offset=( 0x1F00E8 0x2118C0 0x271488 0x271538 0x2A6590 0x2C9F80 0x34B810 0x3964F0 )
 
# File sizes 4.30
#size=( 0x217D8 0x5FCA8 0xAF 0x35058 0x239F0 0x81A38 0x4ACE0 0x391D0 )
 
# File offsets 4.30
#offset=( 0x1F00E8 0x2118C0 0x271568 0x271618 0x2A6670 0x2CA060 0x34BA98 0x396778 )
 
# File sizes 4.41
size=( 0x217D8 0x5FCA8 0xAF 0x35058 0x23D90 0x81A38 0x4ACE0 0x391D0 )
 
# File offsets 4.41
offset=( 0x1F00E8 0x2118C0 0x271568 0x271618 0x2A6670 0x2CA400 0x34BE38 0x396B18)
 
#*******************************************************************************
 
cont=0
 
printf "***************************** \n"
printf "* Psicoleo's                * \n"
printf "* Dump lv1 Embedded files  * \n"
printf "***************************** \n\n"
 
for file in "${files[@]}"
do
        printf "***************************** \n\n"
        printf "      %s\n" "${file}"
        printf "***************************** \n\n"
    printf "%s\n" "${offset[$cont]}"
    printf "%s\n" "${size[$cont]}"
    printf "%s\n" "${cont}"
    dd if=$1 of=$file bs=1 obs=1 skip=$((${offset[$cont]})) count=$((${size[$cont]}))
    cont=$(($cont+1))
done
You can see in this one the lines for 4.41 have been uncommented. (To use with a different version remember to re-comment the size and offset for 4.41.) For windows users, script works in mingw.
 

Rip Cord

Administrator
Staff member
Developer
forgot to say those offsets and sizes are from the file table in the lv1.elf
for 4.21, 4.30 and 4.41 the table is at offset 001F0000
4 byte fields: number of entries in file table, length of file table, and then index, start and length for each file, and finally the list of filenames
as example, to find the absolute start for the first file
segment start + table length + start = real start,
1F0000 + E8 + 00000000 = 1F00E8

The table was also published. I should have said the date on his script was 2 years ago, but I don't know when it was released (only just saw it few days ago).
 
Top