make-verify.sh 1.3 KB

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. # Regenerate verify.exe (verify-only sandbox binary) from a.exe.
  3. #
  4. # a.exe is the prebuilt harness from uunicorn/synaWudfBioUsb-sandbox whose flow
  5. # is hardcoded to enroll()+identify(). Two byte patches turn it into a
  6. # verify-only binary:
  7. # - 0x4048b8 call enroll -> NOP x5
  8. # - 0x4048e1 mov $0x2710,%ecx (10s) -> mov $0,%ecx
  9. # If a future upstream a.exe differs, this script fails loudly (signatures).
  10. set -eu
  11. SANDBOX=${1:-/home/nebulon/projects/fingerprint/work/synaWudfBioUsb-sandbox}
  12. cd "$SANDBOX"
  13. [ -f a.exe ] || { echo "a.exe not found in $SANDBOX" >&2; exit 1; }
  14. cp -f a.exe verify.exe
  15. python3 - <<'EOF'
  16. data = bytearray(open('verify.exe', 'rb').read())
  17. sigA = bytes.fromhex('b902000000e81fe4ffffe802d8ffff') # mov ecx,2; call setMode; call enroll
  18. sigB = bytes.fromhex('b910270000488b054b9c0100ffd0e816ceffff') # mov ecx,0x2710; ...; call identify
  19. i = data.find(sigA)
  20. assert i >= 0, "signature A not found - a.exe changed upstream?"
  21. data[i + 10:i + 15] = b'\x90' * 5
  22. j = data.find(sigB)
  23. assert j >= 0, "signature B not found - a.exe changed upstream?"
  24. data[j + 1:j + 3] = b'\x00\x00'
  25. open('verify.exe', 'wb').write(bytes(data))
  26. print("patched: call enroll -> NOP, Sleep(10000) -> Sleep(0)")
  27. EOF
  28. chmod +x verify.exe
  29. echo "verify.exe ready in $SANDBOX"