Skip to content

Instantly share code, notes, and snippets.

@charsyam
Created July 9, 2018 06:44
Show Gist options
  • Save charsyam/9dfb9053ae5d37b864595065de33a0fe to your computer and use it in GitHub Desktop.
Save charsyam/9dfb9053ae5d37b864595065de33a0fe to your computer and use it in GitHub Desktop.
import sys
import struct
def read_sectors(fd, sector, count = 1):
fd.seek(sector * 512)
return fd.read(count * 512)
def print_table_entry(table):
print("=======================================")
print("Active: ", table[0])
print("CHS1 : ", table[1], table[2], table[3])
print("FileSystem : ", table[4])
print("CHS2 : ", table[5], table[6], table[7])
print("Starting LBA : ", struct.unpack_from("<I", table, 8)[0])
print("size : ", struct.unpack_from("<I", table, 12)[0])
print("")
filename = sys.argv[1]
f = open(filename, "rb")
data = read_sectors(f, 0)
if data[-2] != 0x55 and \
data[-1] != 0xAA:
print("이 파티션은 Boot Record가 아닙니다.")
partition_data = data[446:446+64]
table1 = partition_data[0:16]
table2 = partition_data[16:32]
table3 = partition_data[32:48]
table4 = partition_data[48:64]
print_table_entry(table1)
print_table_entry(table2)
print_table_entry(table3)
print_table_entry(table4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment