Пример #1
0
def getFolderInfo(foi_binary):
    RectVec = unpack_from(">hhhh", foi_binary)
    Flag = unpack_from(">H", foi_binary, 8)[0]
    Location = unpack_from(">hh", foi_binary, 10)
    reserved = unpack_from(">H", foi_binary, 14)[0]
    vec = [ss.Rect(*RectVec), Flag, ss.Point(*Location), reserved]
    return ss.FolderInfo(*vec)
Пример #2
0
def getCatalogThread(cth_binary):
    cth_0 = cth_binary[:10]
    cth_1 = cth_binary[10:]
    recordType, reserved, parID, nameLen = unpack(">hhIH", cth_0)
    nodeUnicode = "".join(map(unichr, unpack_from(">" + nameLen * "H", cth_1)))

    return ss.CatalogThread(recordType, reserved, parID,
                            ss.UniChar(nameLen, nodeUnicode))
Пример #3
0
def getAttributesExtents(ae_binary):
    recordType, res = unpack_from(">II", ad_binary)
    rec_binary = ad_binary[8:]
    ext = []
    for i in range(8):
        temp = rec_binary[16 + 8 * i:16 + 8 * (i + 1)]
        e = getExtentDescriptor(temp)
        ext.append(e)
    return ss.AttrExtents(recordType, res, ss.ExtentsDataRec(*ext))
Пример #4
0
def getExtentsLeafRec(elf_binary):
    extKey = getExtentsKey(elf_binary[:12])
    rec_binary = elf_binary[12:]
    ext = []
    for i in range(8):
        temp = rec_binary[16 + 8 * i:16 + 8 * (i + 1)]
        e = getExtentDescriptor(temp)
        ext.append(e)

    return ss.BTRecord(extKey, ss.ExtentsDataRec(*ext))
Пример #5
0
def getForkData(fd_binary):
    fd_0 = fd_binary[:16]
    ext = []
    for i in range(8):
        temp = fd_binary[16 + 8 * i:16 + 8 * (i + 1)]
        e = getExtentDescriptor(temp)
        ext.append(e)
    vec = list(unpack_from('>QII', fd_binary))
    vec.append(ss.ExtentsDataRec(*ext))
    return ss.ForkData(*vec)
Пример #6
0
def getCatalogLeafRecord(clk_binary):
    keyLen = unpack_from(">H", clk_binary)[0]
    catalKey = getCatalogKey(clk_binary[2:2 + keyLen])
    Key = ss.BTKey(keyLen, catalKey)
    rec_binary = clk_binary[len(Key):]
    recordType = unpack_from(">H", rec_binary)[0]
    typeList = [
        0, getCatalogFolder, getCatalogFile, getCatalogThread, getCatalogThread
    ]
    Record = typeList[recordType](rec_binary)
    return ss.CatalogLeafRec(Key, Record)
Пример #7
0
def getAttributesKey(ak_binary):
    vec = list(unpack_from(">HHIIH", ak_binary))
    nameLen = vec[-1]
    nameUni = "".join(
        map(unichr, unpack_from(">" + nameLen * "H", ak_binary[14:])))
    vec.append(nameUni)
    return ss.AttrKey(*vec)
Пример #8
0
def getHeaderNode(ch_binary):
    ch_buf = memoryview(ch_binary)
    nd = getNodeDescriptor(ch_buf)
    hr = getBTHeaderRec(ch_buf[14:])
    ch_buf = ch_buf[120:]
    udr = Binary(ch_buf[:128], "userDataRecord")
    mr = Binary(ch_buf[128:-8], "mapRecord")
    return ss.HeaderNode(nd, hr, udr, mr)
Пример #9
0
def getHeaderNode(ch_binary):
    ch_buf = memoryview(ch_binary)
    nd = getNodeDescriptor(ch_buf)
    hr = getBTHeaderRec(ch_buf[14:])
    ch_buf = ch_buf[120:]
    udr = ch_buf[:128]
    mr = ch_buf[128:-8]
    return ss.HeaderNode(nd, hr, udr, mr)
Пример #10
0
def getCatalogHeader(ch_binary):  # require bounded-ness
    ch_buf = memoryview(ch_binary)
    nd = getNodeDescriptor(ch_buf)
    hr = getBTHeaderRec(ch_buf[14:])
    ch_buf = ch_buf[120:]
    udr = ch_buf[:128]
    mr = ch_buf[128:]

    return ss.CatalogHeader(nd, hr, udr, mr)
Пример #11
0
def getMapNode(mn_binary):
    mn_buf = memoryview(mn_binary)
    nd = getNodeDescriptor(mn_buf)
    offsetList = [14]
    for i in range(nd.numRecords):
        offset = unpack(">H", mn_buf[-2 * i - 4:-2 * i - 2])[0]
        offsetList.append(offset)
    mr = mn_buf[14:offsetList[1]]
    return ss.MapNode(nd, mr)
Пример #12
0
def getAttributesData(ad_binary):
    vec = list(unpack_from(">IQI", ad_binary))
    attrSize = vec[-1]
    temp = []
    for i in ad_binary[16:16 + attrSize]:
        temp.append(i)
    attrData = tuple(temp)
    vec.append(attrData)
    return ss.AttrData(*vec)
Пример #13
0
def getExtentsLeaf(el_binary):
    el_buf = memoryview(el_binary)
    nd = getNodeDescriptor(el_binary)
    leafRecList = []
    el_buf = el_buf[14:]
    for i in range(nd.numRecords):
        lr = getExtentsLeafRec(el_buf)
        leafRecList.append(lr)
        el_buf = el_buf[len(lr):]
    return ss.LeafNode(nd, leafRecList)
Пример #14
0
def getAttributesLeafRec(alr_binary):
    keyLen = unpack_from(">H", alr_binary)[0]
    attKey = getAttributesKey(alr_binary[:2 + keyLen])
    rec_binary = alr_binary[2 + keyLen:]
    recordType = unpack_from(">I", rec_binary)[0]
    typeList = [
        0, getAttributesData, getAttributesForkData, getAttributesExtents
    ]
    Record = typeList[recordType / 0x10](rec_binary)
    return ss.BTRecord(attKey, Record)
Пример #15
0
def getCatalogLeaf(cl_binary):
    cl_buf = memoryview(cl_binary)
    nd = getNodeDescriptor(cl_binary)
    leafRecList = []

    cl_buf = cl_buf[14:]
    for i in range(nd.numRecords):
        lr = getCatalogLeafRec(cl_buf)
        leafRecList.append(lr)
        cl_buf = cl_buf[len(lr):]

    return ss.LeafNode(nd, leafRecList)
Пример #16
0
def getAttributesLeaf(al_binary):
    al_buf = memoryview(al_binary)
    nd = getNodeDescriptor(al_binary)
    leafRecList = []

    al_buf = al_buf[14:]
    for i in range(nd.numRecords):
        lr = getAttributesLeafRec(al_buf)
        leafRecList.append(lr)
        al_buf = al_buf[len(lr):]

    return ss.LeafNode(nd, leafRecList)
Пример #17
0
def getExtentsIndex(ei_binary):
    ei_buf = memoryview(ei_binary)
    nd = getNodeDescriptor(ei_buf)
    offsetList = [14]
    PointerRecList = []
    for i in range(nd.numRecords):
        offset = unpack(">H", ei_buf[-2 * i - 4:-2 * i - 2])[0]
        offsetList.append(offset)
    for i in range(len(offsetList) - 1):
        temp = ei_buf[offsetList[i]:offsetList[i + 1]]
        epr = getExtentsPointerRec(temp)
        PointerRecList.append(epr)
    return ss.IndexNode(nd, PointerRecList)
Пример #18
0
def getAttributesIndex(ai_binary):
    ai_buf = memoryview(ai_binary)
    nd = getNodeDescriptor(ai_buf)
    offsetList = [14]
    PointerRecList = []
    for i in range(nd.numRecords):
        offset = unpack(">H", ai_buf[-2 * i - 4:-2 * i - 2])[0]
        offsetList.append(offset)
    for i in range(len(offsetList) - 1):
        temp = ai_buf[offsetList[i]:offsetList[i + 1]]
        apr = getAttributesPointerRec(temp)
        PointerRecList.append(apr)
    return ss.IndexNode(nd, PointerRecList)
Пример #19
0
def getCatalogIndex(ci_binary):
    ci_buf = memoryview(ci_binary)
    nd = getNodeDescriptor(ci_buf)
    offsetList = [14]
    PointerRecList = []
    for i in range(nd.numRecords):
        offset = unpack(">H", ci_buf[-2 * i - 4:-2 * i - 2])[0]
        offsetList.append(offset)
    for i in range(len(offsetList) - 1):
        temp = ci_buf[offsetList[i]:offsetList[i + 1]]
        cpr = getCatalogPointerRec(temp)
        PointerRecList.append(cpr)
    return ss.IndexNode(nd, PointerRecList)
Пример #20
0
def getVolumeHeader(vh_binary):
    vh_0 = vh_binary[:80]
    vh_1 = vh_binary[80:112]
    vh_sp = []
    for i in range(5):
        t = vh_binary[112 + 80 * i:112 + 80 * (i + 1)]
        vh_sp.append(t)

    vec = list(unpack('>HHIIIIIIIIIIIIIIIIIQ', vh_0))

    fI = unpack('>IIIIIIII', vh_1)
    vec.append(fI)

    for i in range(5):
        vec.append(getForkData(vh_sp[i]))
    return ss.VolumeHeader(*vec)
Пример #21
0
def getCatalogFolder(cfo_binary):
    cfo_0 = cfo_binary[:32]
    cfo_1 = cfo_binary[32:48]  # BSDInfo
    cfo_2 = cfo_binary[48:64]  # userInfo
    cfo_3 = cfo_binary[64:80]  # finderInfo
    cfo_4 = cfo_binary[80:]  # textEncoding, reserved

    vec0 = list(unpack('>hHIIIIIII', cfo_0))
    BSDInfo = getBSDInfo(cfo_1)
    userInfo = getFolderInfo(cfo_2)
    finderInfo = getExtendedFolderInfo(cfo_3)
    textEncoding, reserved = unpack_from(">II", cfo_4)
    vec1 = [BSDInfo, userInfo, finderInfo, textEncoding, reserved]

    vec0.extend(vec1)
    return ss.CatalogFolder(*vec0)
Пример #22
0
def getCatalogFile(cfi_binary):
    cfi_0 = cfi_binary[:32]
    cfi_1 = cfi_binary[32:48]  # BSDInfo
    cfi_2 = cfi_binary[48:64]  # userInfo
    cfi_3 = cfi_binary[64:80]  # finderInfo
    cfi_4 = cfi_binary[80:88]  # textEncoding, reserved
    cfi_5 = cfi_binary[88:168]  # dataFork
    cfi_6 = cfi_binary[168:]  # resourceFork

    vec0 = list(unpack('>hHIIIIIII', cfi_0))
    BSDInfo = getBSDInfo(cfi_1)
    userInfo = getFileInfo(cfi_2)
    finderInfo = getExtendedFileInfo(cfi_3)
    textEncoding, reserved2 = unpack(">II", cfi_4)
    dataFork = getForkData(cfi_5)
    resourceFork = getForkData(cfi_6)
    vec1 = [
        BSDInfo, userInfo, finderInfo, textEncoding, reserved2, dataFork,
        resourceFork
    ]

    vec0.extend(vec1)
    return ss.CatalogFile(*vec0)
Пример #23
0
def getAttributesPointerRec(apr_binary):
    keyLen = unpack_from(">H", apr_binary)[0]
    attKey = getAttributesKey(apr_binary[:2 + keyLen])
    nodeNum = unpack_from(">I", apr_binary[2 + keyLen:])[0]
    return ss.BTRecord(attKey, ss.BTPointer(nodeNum))
Пример #24
0
def getExtendedFileInfo(efi_binary):
    res1 = unpack_from(">hhhh", efi_binary)
    vec = list(unpack_from(">Hhi", efi_binary, 8))
    vec.insert(0, res1)
    return ss.ExtendedFileInfo(*vec)
Пример #25
0
def getFileInfo(fii_binary):
    vec = list(unpack_from(">IIH", fii_binary))
    Location = unpack_from(">hh", fii_binary, 10)
    res = unpack_from(">H", fii_binary, 14)[0]
    vec.extend([ss.Point(*Location), res])
    return ss.FileInfo(*vec)
Пример #26
0
def getExtendedFolderInfo(efi_binary):
    scrPosVec = unpack_from(">hh", efi_binary)
    vec = list(unpack_from(">iHhi", efi_binary, 4))
    vec.insert(0, ss.Point(*scrPosVec))
    return ss.ExtendedFolderInfo(*vec)
Пример #27
0
def getBSDInfo(bsd_binary):
    vec = unpack_from(">IIBBHI", bsd_binary)
    return ss.BSDInfo(*vec)
Пример #28
0
def getNodeDescriptor(nd_binary):
    vec = unpack_from('>IIbBHH', nd_binary)
    return ss.NodeDescriptor(*vec)
Пример #29
0
def getExtentDescriptor(ed_binary):
    vec = unpack_from('>II', ed_binary)
    return ss.ExtentDescriptor(*vec)
Пример #30
0
def getBTHeaderRec(hr_binary):
    vec = unpack_from('>HIIIIHHIIHIBBI', hr_binary)  # reserved3 field omited
    return ss.BTHeaderRec(*vec)