示例#1
0
    def read_addr(self, addr, block_count=8, read_type=0):

        cdb = _scsi_read10(addr, block_count, reserved_byte=read_type)

        data = py_sg.read(self.dev, cdb, self.BLOCK_SIZE * block_count)

        return array.array('B', data)
def read_handy_store(page):
	cdb = [0xD8,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x01,0x00]
	i = 2
	for c in htonl(page):
		cdb[i] = ord(c)
		i+=1
	data = py_sg.read(dev, _scsi_pack_cdb(cdb), BLOCK_SIZE)
	return data
def get_encryption_status():
	cdb = [0xC0, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00]
	data = py_sg.read(dev, _scsi_pack_cdb(cdb), BLOCK_SIZE)
	if ord(data[0]) != 0x45:
		print fail("Wrong encryption status signature %s" % hex(ord(data[0])))
		sys.exit(1)
	##  SecurityStatus, CurrentChiperID, KeyResetEnabler
	return (ord(data[3]), ord(data[4]), data[8:12])
示例#4
0
    def read_addr(self, addr, block_count=8, read_type=0):


        cdb = _scsi_read10(addr, block_count, reserved_byte=read_type)

        data = py_sg.read(self.dev, cdb, self.BLOCK_SIZE * block_count)

        return array.array('B', data)
def read_handy_store(page):
    cdb = [0xD8, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00]
    i = 2
    for c in htonl(page):
        cdb[i] = ord(c)
        i += 1
    data = py_sg.read(dev, _scsi_pack_cdb(cdb), BLOCK_SIZE)
    return data
def get_encryption_status():
    cdb = [0xC0, 0x45, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00]
    data = py_sg.read(dev, _scsi_pack_cdb(cdb), BLOCK_SIZE)
    if ord(data[0]) != 0x45:
        print fail("Wrong encryption status signature %s" % hex(ord(data[0])))
        sys.exit(1)
    ##  SecurityStatus, CurrentChiperID, KeyResetEnabler
    return (ord(data[3]), ord(data[4]), data[8:12])
示例#7
0
def read_serial(dev):
    """
    SCSI Read(10) command with byte nr. 7 set to 0x03
    will return empty data with the the serial at the end.
    """

    cmd = [0x28, 0, 0, 0, 0, 0, 0x03, 0, 0, 0]

    s = struct.pack('>H', 4)

    cmd[7] = ord(s[0])
    cmd[8] = ord(s[1])

    return py_sg.read(dev, pack_scsi_cmd(cmd), 2048)[-16:]
示例#8
0
def read_serial(dev):
    """
    SCSI Read(10) command with byte nr. 7 set to 0x03
    will return empty data with the the serial at the end.
    """

    cmd = [0x28, 0, 0, 0, 0, 0, 0x03, 0, 0, 0]

    s = struct.pack('>H', 4)

    cmd[7] = ord(s[0])
    cmd[8] = ord(s[1])


    return py_sg.read(dev, pack_scsi_cmd(cmd), 2048)[-16:]
示例#9
0
def read_block(dev, addr):
    """
    SCSI Read(10) command with byte nr. 7 set to 0x10
    will return the data on the device in blocks of 4096 bytes.
    """

    cmd = [0x28, 0, 0, 0, 0, 0, 0x10, 0, 0, 0]

    blocks = 8

    a = struct.pack('>I', addr)
    cmd[2] = ord(a[0])
    cmd[3] = ord(a[1])
    cmd[4] = ord(a[2])
    cmd[5] = ord(a[3])

    s = struct.pack('>H', blocks)

    cmd[7] = ord(s[0])
    cmd[8] = ord(s[1])

    return py_sg.read(dev, pack_scsi_cmd(cmd), 512 * blocks)
示例#10
0
def read_block(dev, addr):
    """
    SCSI Read(10) command with byte nr. 7 set to 0x10
    will return the data on the device in blocks of 4096 bytes.
    """

    cmd = [0x28, 0, 0, 0, 0, 0, 0x10, 0, 0, 0]

    blocks = 8

    a = struct.pack('>I', addr)
    cmd[2] = ord(a[0])
    cmd[3] = ord(a[1])
    cmd[4] = ord(a[2])
    cmd[5] = ord(a[3])

    s = struct.pack('>H', blocks)

    cmd[7] = ord(s[0])
    cmd[8] = ord(s[1])



    return py_sg.read(dev, pack_scsi_cmd(cmd), 512 * blocks)