File: msdos-overlap

package info (click to toggle)
parted 3.2-17
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 15,860 kB
  • ctags: 13,339
  • sloc: ansic: 69,646; sh: 18,159; makefile: 635; perl: 179; python: 45; asm: 36; sed: 16
file content (25 lines) | stat: -rwxr-xr-x 658 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/python
"""
    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.exit(1)

data = "".join(chr(c) for c in BAD_ENTRY)
with open(sys.argv[1], "rb+") as f:
    f.seek(OFFSET, 0)
    f.write(data)

sys.exit(0)