summaryrefslogtreecommitdiff
path: root/tests/msdos-overlap
blob: b2b03e61619144881b033b3abbcf61743637e1fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/python3
"""
    Write an overlapping partition to a msdos disk

    Call with disk image/device to mangle
"""
import sys

BAD_ENTRY = (0x72, 0xf5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
             0x01, 0x10, 0x83, 0x03, 0x20, 0x4f, 0x00, 0x08,
             0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
             0x00, 0x50, 0x83, 0x00, 0x0a, 0x7a, 0xff, 0x27,
             0x00, 0x00, 0x0a, 0x15, 0x00, 0x00, 0x00, 0x00 )
OFFSET = 0x1b8

if len(sys.argv) < 2:
    print("%s: <image or device>" % sys.argv[0])
    sys.exit(1)

with open(sys.argv[1], "rb+") as f:
    f.seek(OFFSET, 0)
    f.write(bytes(bytearray(BAD_ENTRY)))

sys.exit(0)