OTA firmware: checksum-patch
OTA (Over-The-Air) firmware update packets often use a simple additive checksum for integrity checking — not a cryptographic signature, just a sum of bytes/words. Here, a simplified version of the 16-bit "one's complement" checksum used in real network protocols (IP/TCP/UDP) is applied:
def fold16(total):
while total >> 16:
total = (total & 0xFFFF) + (total >> 16)
return total & 0xFFFF
def checksum(words): # words - 16-bitli sonlar ro'yxati
return fold16(sum(words)) ^ 0xFFFF
# TEKSHIRISH XOSSASI: agar CHECKSUM to'g'ri hisoblangan bo'lsa,
# fold16(sum(words + [CHECKSUM])) == 0xFFFF (barcha bitlar 1)
The problem: this checksum is linear — if there is a "reserve" (PATCH) word in the packet that the attacker controls, the attacker can restore the checksum to its valid state (bypass it) by just choosing this one word correctly, without recalculating the entire packet — this is a classic vulnerability of additive checksums (since they are not cryptographic hashes).
The attached ota_packages.txt file contains 6 independent packet fragments. Each contains 3 known 16-bit DATA words, an unknown PATCH word (????), and the original (unmodified) CHECKSUM. Find the PATCH value for each fragment — it must pass the integrity check.
Convert each found PATCH word into 2 ASCII bytes (high byte — first character, low byte — second character) and combine them in the order of the fragments: BAYROQ{IOT_OTA_<SOZ>}