[Moto Z2 Force  Guides, News, & Discussion] Knuxyl:
Updated 7.30.20

I have a server up and running and thought it would be perfect to go back to this. I noticed some problems with the original code. After a while, the oem unlock command would hang, so I made it reboot the bootloader ever 1024 keys. I also added an initial oem unlock check because the first time you do the command it asks are you sure. This script should work forever.

I did notice that the screen will get burn in if left on for a long time. I cannot seem to find a way around this, no fastboot command can turn the screen off and keep fastboot running. I figured a $40 screen is worth reviving a $700 phone. This phone has been sitting in a box for years because verizon's anti everyone policies on bootloaders. I will be running this until it cracks the bootloader.

There is an automatic saving/restoring feature in case the computers gets turned off or I need to restart it. I also made the script not repeat characters more than 3 times in a row. I know chances are this won't work, but to me it's worth a try considering I don't have to do anything.

#!/bin/bash
restore() {
echo "Restoring Previous Session..."
crunch 20 20 ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -d 3 -s "${file}" | while read line; do
iter=$((iter + 1))
echo "Testing key ${line} - ${iter}"
line2=$((sudo fastboot oem unlock "${line}") 2>&1)
check=$(echo "${line2}" | sed -n 2p)
echo "${check}"
if [ "${check}" != "(bootloader) Code validation failure" ]; then
echo "${line}" >> key
finished
fi
echo "${line}" > current
if [ $iter -eq 1024 ]; then
echo "--------------------"
echo "Rebooting to bootloader"
echo "--------------------"
sudo fastboot reboot bootloader
echo "--------------------"
echo "Sleeping 5 seconds"
echo "--------------------"
sleep 5s
iter=0
echo "--------------------"
echo "Running initial oem unlock"
echo "--------------------"
sudo fastboot oem unlock aaaaaaaaaaaaaaaaaaaa
fi
done
}

new() {
echo "Running New Session..."
crunch 20 20 ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 -d 3 | while read line; do
iter=$((iter + 1))
echo "Testing key ${line} - ${iter}"
line2=$((sudo fastboot oem unlock "${line}") 2>&1)
check=$(echo "${line2}" | sed -n 2p)
echo "${check}"
if [ "${check}" != "(bootloader) Code validation failure" ]; then
echo "${line}" >> key
finished
fi
echo "${line}" > current
if [ $iter -eq 1024 ]; then
echo "--------------------"
echo "Rebooting to bootloader"
echo "--------------------"
sudo fastboot reboot bootloader
echo "--------------------"
echo "Sleeping 5 seconds"
echo "--------------------"
sleep 5s
iter=0
echo "--------------------"
echo "Running initial oem unlock"
echo "--------------------"
sudo fastboot oem unlock aaaaaaaaaaaaaaaaaaaa
fi
done
}
finished() {
echo ""
echo "------------------------------------"
echo ""
echo "A different output was given, probably bootloader key found"
echo "Last checked key was"
echo "${line}"
echo "Key is also stored in a file called key"
echo "${line}" >> key
chmod 555 key
echo ""
echo "------------------------------------"
echo ""
echo "Press enter to close the terminal"
read var
exit 1
}
testresult() {
if [ -f "current" ]; then
file=$(cat current)
if [ "${file}" == "" ]; then
rm current
new
else
restore
fi
else
new
fi
}
testkey() {
if [ -f "key" ]; then
file=$(cat key)
if [ "${file}" == "" ]; then
chmod 775 key
rm key
testresult
else
echo "Key from last run was found, it is"
echo "${file}"
echo "Backing up to key.old"
chmod 775 key
cat key >> key.old
rm key
testresult
fi
else
testresult
fi
}
iter=0
sudo fastboot oem unlock aaaaaaaaaaaaaaaaaaaa
testkey