13 lines
327 B
Bash
Executable File
13 lines
327 B
Bash
Executable File
#!/bin/sh
|
|
|
|
setbyte() {
|
|
printf "\x$3"|dd status=none seek="$2" bs=1 count=1 conv=notrunc of="$1"
|
|
}
|
|
|
|
[ -n "$1" ] || exit 1
|
|
|
|
setbyte "$1" 2 $(stat -c "%s" "$1"|awk '{printf("%02x",$1/512)}')
|
|
|
|
setbyte "$1" 41 00
|
|
checksum=$(xxd -p -c 1 "$1"|sed 's/^/0x/'|awk '{s+=$1} END {printf("%02x\n",256-s%256)}')
|
|
setbyte "$1" 41 "$checksum" |