Thanks @Wurst420 for starting this, after a short talk with @g3gg0 here are finaly scripts to convert old V3 Flipper Zero NFC Files into the new V4 Format, this will allow you to emulate you existing .nfc files with the lastest Firmware i have tested the Emulation with the Xtreme Dev 18.02.2024
Hint:
after the NFC Refactoring the Flipper OFW Dev Team changed the Emulation to an 5 min. Limit, this makes it impossible to listen to an complete Audio without restart the emulation, i allready created an feature request to change this or add an option for endless emulation NFC Emulation Time Limit · Issue #3460 · flipperdevices/flipperzero-firmware · GitHub
I created the scripts with the help of ChatGPT.
The scripts are able convert a single file
fz-nfc-convert.sh -s flipper.nfc
or an folder of .nfc files
fz-nfc-convert.sh -f \nfc
the output file is allways within the same location as the input file, filename also stays the same *.nfc but with an added “_v4” so it will look like *_v4.nfc
fz-nfc-convert.sh for thoose who run an Linuy or Mac Device (tested on Ubuntu 23.04)
#!/bin/bash
while getopts ":sf:" option; do
case $option in
s)
single_file=true
;;
f)
folder_path="$OPTARG"
folder_mode=true
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
shift $((OPTIND - 1))
# Function to convert a single file
convert_file() {
local input_file="$1"
local output_file="${input_file%.nfc}_v4.nfc"
version=$(awk '/Version:/ {print $2}' "$input_file")
if [[ "$version" != "3" ]]; then
echo "Skipping conversion for $input_file (Version: $version)"
return
fi
uid=$(grep 'UID:' "$input_file" | sed 's/^[ \t]*UID: //')
data=$(grep 'Data Content:' "$input_file" | sed 's/^[ \t]*Data Content: //')
cat <<EOF > "$output_file"
Filetype: Flipper NFC device
Version: 4
Device type: SLIX
# UID is common for all formats
UID: $uid
# ISO15693-3 specific data
DSFID: 00
AFI: 00
IC Reference: 03
Lock DSFID: false
Lock AFI: false
# Number of memory blocks, valid range = 1..256
Block Count: 8
# Size of a single memory block, valid range = 01...20 (hex)
Block Size: 04
Data Content: $data
# Block Security Status: 01 = locked, 00 = not locked
Security Status: 00 00 00 00 00 00 00 00
# SLIX specific data
# Passwords are optional. If a password is omitted, a default value will be used
Password Privacy: 7F FD 6E 5B
Password Destroy: FF FF FF FF
Password EAS: 00 00 00 00
Privacy Mode: true
# SLIX Lock Bits
Lock EAS: false
EOF
echo "Conversion completed. Output written to $output_file"
}
# Handle single file mode
if [ "$single_file" = true ]; then
if [ "$#" -ne 1 ]; then
echo "Usage: $0 -s input_file"
exit 1
fi
convert_file "$1"
fi
# Handle folder mode
if [ "$folder_mode" = true ]; then
if [ ! -d "$folder_path" ]; then
echo "Invalid folder path: $folder_path"
exit 1
fi
for input_file in "$folder_path"/*.nfc; do
if [ -f "$input_file" ]; then
convert_file "$input_file"
fi
done
fi
fz-nfc-convert.bat for thoose who uses Windows Devices
t@echo off
setlocal enabledelayedexpansion
:parse_args
set "single_file="
set "folder_mode="
set "folder_path="
:parse_loop
if "%~1" == "" goto main
if /i "%~1" == "-s" (
set "single_file=true"
shift /1
goto parse_loop
)
if /i "%~1" == "-f" (
set "folder_mode=true"
set "folder_path=%~2"
shift /2
goto parse_loop
)
goto invalid_arg
:main
if not defined single_file if not defined folder_mode goto show_help
:process_files
if defined single_file (
call :convert_file "%~1"
) else (
if not defined folder_path goto show_help
for %%I in ("%folder_path%\*.nfc") do (
call :convert_file "%%I"
)
)
goto end
:convert_file
set "input_file=%~1"
set "output_file=!input_file:.nfc=_v4.nfc!"
for /f "tokens=2 delims=: " %%V in ('findstr /i "Version:" "%input_file%"') do set "version=%%V"
if /i not "!version!" == "3" (
echo Skipping conversion for %input_file% (Version: !version!)
goto :eof
)
for /f "tokens=2 delims=: " %%U in ('findstr /i "UID:" "%input_file%"') do set "uid=%%U"
for /f "tokens=3 delims=: " %%D in ('findstr /i "Data Content:" "%input_file%"') do set "data=%%D"
(
echo Filetype: Flipper NFC device
echo Version: 4
echo Device type: SLIX
echo # UID is common for all formats
echo UID: !uid!
echo # ISO15693-3 specific data
echo DSFID: 00
echo AFI: 00
echo IC Reference: 03
echo Lock DSFID: false
echo Lock AFI: false
echo # Number of memory blocks, valid range = 1..256
echo Block Count: 8
echo # Size of a single memory block, valid range = 01...20 (hex)
echo Block Size: 04
echo Data Content: !data!
echo # Block Security Status: 01 = locked, 00 = not locked
echo Security Status: 00 00 00 00 00 00 00 00
echo # SLIX specific data
echo # Passwords are optional. If a password is omitted, a default value will be used
echo Password Privacy: 7F FD 6E 5B
echo Password Destroy: FF FF FF FF
echo Password EAS: 00 00 00 00
echo Privacy Mode: true
echo # SLIX Lock Bits
echo Lock EAS: false
) > "%output_file%"
echo Conversion completed. Output written to %output_file%
goto :eof
:show_help
echo Usage: %~nx0 [-s input_file | -f folder_path]
goto end
:invalid_arg
echo Invalid argument: %1
goto :eof
:end
endlocal
fz-nfc-convert.py for thoose who want to use python ony universal maschines
import argparse
import os
def convert_file(input_file):
output_file = input_file.replace(".nfc", "_v4.nfc")
with open(input_file, 'r') as infile, open(output_file, 'w') as outfile:
version = None
uid = None
data = None
for line in infile:
if "Version:" in line:
version = line.split()[1]
elif "UID:" in line:
uid = line.split()[1]
elif "Data Content:" in line:
data = line.split()[2]
if version != "3":
print(f"Skipping conversion for {input_file} (Version: {version})")
return
outfile.write(f"""Filetype: Flipper NFC device
Version: 4
Device type: SLIX
# UID is common for all formats
UID: {uid}
# ISO15693-3 specific data
DSFID: 00
AFI: 00
IC Reference: 03
Lock DSFID: false
Lock AFI: false
# Number of memory blocks, valid range = 1..256
Block Count: 8
# Size of a single memory block, valid range = 01...20 (hex)
Block Size: 04
Data Content: {data}
# Block Security Status: 01 = locked, 00 = not locked
Security Status: 00 00 00 00 00 00 00 00
# SLIX specific data
# Passwords are optional. If a password is omitted, a default value will be used
Password Privacy: 7F FD 6E 5B
Password Destroy: FF FF FF FF
Password EAS: 00 00 00 00
Privacy Mode: true
# SLIX Lock Bits
Lock EAS: false
""")
print(f"Conversion completed. Output written to {output_file}")
def convert_folder(folder_path):
for filename in os.listdir(folder_path):
if filename.endswith(".nfc"):
convert_file(os.path.join(folder_path, filename))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Convert Flipper NFC files from version 3 to version 4")
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument("-s", "--single", help="Convert a single file", metavar="input_file")
group.add_argument("-f", "--folder", help="Convert all files in a folder", metavar="folder_path")
args = parser.parse_args()
if args.single:
convert_file(args.single)
elif args.folder:
convert_folder(args.folder)