Preamble
I have written this tiny utility for myself, and I decided to share it for anyone interested in (if any). This thread is intended for experienced Linux users (or at least Unix users). I will not provide any kind of support on how to use Linux and/or a shell prompt. I have no plan for making an user friendly utility, so feel free to use this as a starting point if you ever want to build a GUI.
The utility is based on sed (if your are not familiar with this awesome tool, you can learn more here). You can either invoke sed with a script file:
or with an inline script:
In both invocations, the -r flag allows to use extended regular expressions.
Replacing the unique ID
The following script is 100% equivalent to the "Patch ALL Games" button in No Ban No Sky: the given UNIQUE_ID is applied to all games.
Note that UNIQUE_ID must be replaced by 16 pairs of hexadecimal digits (01 23 45 67 89 AB CD EF 01 23 45 67 89 AB CD EF), without altering the surrounding \1 and \3.
Replacing the unique ID and the manufacturer
From my own experience, it appeared that replacing the unique ID was no always enough to play online. However, replacing the manufacturer byte with the one of my private header was much better. I don't know if it works for all games, but it did for all my tests. The following script applies both the given UNIQUE_ID and the given MANUFACTURER to all games.
Note that MANUFACTURER must be replaced by a pair of hexadecimal digits, without altering the surrounding \1 and \3.
All-in-one script
If you are lazy like I am, and don't want to manually extract the UNIQUE_ID and the MANUFACTURER from you private header, you can use the following Bash script (ensure that hexdump is installed on your machine).
Save the script in a .sh file, and make it executable. Then run it like this:
Other platforms
I only tested this on Linux, but since sed is a standard Unix tool, you can probably run it also on Mac OS, or even on Windows (using Cygwin or sed for Windows).
I have written this tiny utility for myself, and I decided to share it for anyone interested in (if any). This thread is intended for experienced Linux users (or at least Unix users). I will not provide any kind of support on how to use Linux and/or a shell prompt. I have no plan for making an user friendly utility, so feel free to use this as a starting point if you ever want to build a GUI.
The utility is based on sed (if your are not familiar with this awesome tool, you can learn more here). You can either invoke sed with a script file:
Code:
sed -r -f SCRIPT_FILE.txt < template.txt > template_private.txt
Code:
sed -r 'INLINE_SCRIPT' < template.txt > template_private.txt
In both invocations, the -r flag allows to use extended regular expressions.
Replacing the unique ID
The following script is 100% equivalent to the "Patch ALL Games" button in No Ban No Sky: the given UNIQUE_ID is applied to all games.
Code:
/^SHA1:/{
n
n
n
n
n
s/^(\s*)(\s*[0-9A-F]{2}){16}(\s*)$/\1UNIQUE_ID\3/
}
Code:
/^SHA1:/{n;n;n;n;n;s/^(\s*)(\s*[0-9A-F]{2}){16}(\s*)$/\1UNIQUE_ID\3/}
Note that UNIQUE_ID must be replaced by 16 pairs of hexadecimal digits (01 23 45 67 89 AB CD EF 01 23 45 67 89 AB CD EF), without altering the surrounding \1 and \3.
Replacing the unique ID and the manufacturer
From my own experience, it appeared that replacing the unique ID was no always enough to play online. However, replacing the manufacturer byte with the one of my private header was much better. I don't know if it works for all games, but it did for all my tests. The following script applies both the given UNIQUE_ID and the given MANUFACTURER to all games.
Code:
/^SHA1:/{
n
s/^((\s*[0-9A-F]{2}){4}\s*)[0-9A-F]{2}((\s*[0-9A-F]{2}){11}\s*)$/\1MANUFACTURER\3/
n
n
n
n
s/^(\s*)(\s*[0-9A-F]{2}){16}(\s*)$/\1$id\3/
}
Code:
/^SHA1:/{n;s/^((\s*[0-9A-F]{2}){4}\s*)[0-9A-F]{2}((\s*[0-9A-F]{2}){11}\s*)$/\1MANUFACTURER\3/;n;n;n;n;s/^(\s*)(\s*[0-9A-F]{2}){16}(\s*)$/\1UNIQUE_ID\3/}
Note that MANUFACTURER must be replaced by a pair of hexadecimal digits, without altering the surrounding \1 and \3.
All-in-one script
If you are lazy like I am, and don't want to manually extract the UNIQUE_ID and the MANUFACTURER from you private header, you can use the following Bash script (ensure that hexdump is installed on your machine).
Code:
#!/bin/bash
set -eu
if [ "$#" -lt 1 ]
then
echo "Usage: $(basename "$0") <header.bin>" 1>&2
exit 1
fi
id="$(hexdump -n 16 -e '16/1 "%X "' "$1")"
man="$(hexdump -s 64 -n 1 -e '"%X"' "$1")"
script="$(cat <<EOF
/^SHA1:/{
n
s/^((\s*[0-9A-F]{2}){4}\s*)[0-9A-F]{2}((\s*[0-9A-F]{2}){11}\s*)$/\1$man\3/
n
n
n
n
s/^(\s*)(\s*[0-9A-F]{2}){16}(\s*)$/\1$id\3/
}
EOF
)"
sed -r "$script"
Save the script in a .sh file, and make it executable. Then run it like this:
Code:
./apply_header.sh PRIVATE_HEADER.bin < template.txt > template_private.txt
Other platforms
I only tested this on Linux, but since sed is a standard Unix tool, you can probably run it also on Mac OS, or even on Windows (using Cygwin or sed for Windows).