def get_scsi_standard_inquiry(access_path):
    from infi.asi.coroutines.sync_adapter import sync_wait
    from infi.asi.cdb.inquiry.standard import StandardInquiryCommand, STANDARD_INQUIRY_MINIMAL_DATA_LENGTH

    with asi_context(access_path) as asi:
        command = StandardInquiryCommand(
            allocation_length=STANDARD_INQUIRY_MINIMAL_DATA_LENGTH)
        result = sync_wait(command.execute(asi))
        return result
import sys
from infi.asi import create_platform_command_executer
from infi.asi.cdb.inquiry.standard import StandardInquiryCommand
from infi.asi.coroutines.sync_adapter import sync_wait
from infi.asi import create_os_file
from infi.exceptools import print_exc

if len(sys.argv) != 2:
    sys.stderr.write("usage: %s device_name\n" % sys.argv[0])
    sys.exit(1)

path = sys.argv[1]

f = create_os_file(path)

try:
    executer = create_platform_command_executer(f)

    inquiry = StandardInquiryCommand()
    data = sync_wait(inquiry.execute(executer))

    print(data)

    f.close()
except:
    print_exc()
Exemple #3
0
def do_standard_inquiry(sg_device):
    from infi.asi.cdb.inquiry.standard import StandardInquiryCommand
    cdb = StandardInquiryCommand()
    return do_scsi_cdb(sg_device, cdb)
        ("TimeOutValue", c_ulong),
        # [in] Pointer to the data buffer
        ("DataBuffer", c_void_p),
        # [in] Offset from the beginning of the structure to the request-sense buffer
        ("SenseInfoOffset", c_ulong),
        # [in] CDB to send to the target device
        ("Cdb", c_ubyte * 16),

        # sizeof: 16 + 4 + 8 + 4 + 4 + 1 * 7 + 2 =
        # Our sense buffer
        ("sense_buffer", c_ubyte * SENSE_SIZE)
    ]


try:
    cmd = StandardInquiryCommand()
    cmd_str = cmd.create_datagram()

    f = win32.Win32File(r"\\.\PHYSICALDRIVE0",
                        win32.GENERIC_READ | win32.GENERIC_WRITE,
                        win32.FILE_SHARE_READ | win32.FILE_SHARE_WRITE,
                        win32.OPEN_EXISTING)

    data_buffer = create_string_buffer(96)
    print("[!] SPT length: %d (%d)" %
          (sizeof(SCSIPassThroughDirect) - SENSE_SIZE,
           sizeof(SCSIPassThroughDirect)))
    spt = SCSIPassThroughDirect()
    spt.Length = sizeof(SCSIPassThroughDirect) - SENSE_SIZE
    spt.PathId = 0
    spt.TargetId = 0