Linus on Git and SHA-1
Linus on Git and SHA-1
Posted Feb 27, 2017 15:36 UTC (Mon) by joey (guest, #328)In reply to: Linus on Git and SHA-1 by Garak
Parent article: Linus on Git and SHA-1
1. Identify the first instruction run by the firmware at boot. Replace with a jump to 129 bytes after the current end of the firmware. Use the resulting file as the input the the collision generation attack. (If you wan to target this being stored in a git repository, include a git blob header in the data used to generate the collision.)
2. Now you have two 128 byte chunks which when appended to the file in #1, result in two colliding, but different files.
3. At the end of each of the two different files, append the same payload. Since the SHA1 hash function is in the same state at the end of each file in #2, appending identical data to each file yields new files that also collide.
The payload examines the memory in the 128 byte colliding area. If it sees the "good" version, it runs the instruction that was originally replaced with the jump, and jumps back to the second original instruction. If it sees the "bad" version, it runs the remainder of the payload, the exploit.
Obviously there is some trickiness to do with relative addresses and returning registers to the original state when jumping back in the "good" version etc. But this should be very doable for any assembly programmer; it should even be possible to completely automate it.