Wanted: Python module allowing direct access to raw sectors of harddrives (MFT, boot sector, etc.) i

Discussion in 'Python' started by jepler@unpythonic.net, Oct 10, 2005.

  1. Guest

    Re: Wanted: Python module allowing direct access to raw sectors ofharddrives (MFT, boot sector, etc.) in MS Windows

    I took the advice from this web page:
    http://support.microsoft.com/kb/q100027/
    (I don't know how this extends to floppies, and the 9x family of OSes isn't
    listed in "applies to", so this may not help your case)

    Here, I open "physical drive 0" and see that the magic number indicates a valid
    boot record. I believe it is the MBR.

    >>> f = open('\\\\.\\PhysicalDrive0', 'rb')
    >>> f.read(512)[-2:]

    'U\xaa' # that is, hex 55 AA

    I don't know much about low-level filesystem or partition details--I got the
    tidbit about the 55 AA magic number from
    http://www-uxsup.csx.cam.ac.uk/pub/doc/suse/sles9/adminguide-sles9/ch08.html

    Jeff

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.1 (GNU/Linux)

    iD8DBQFDSut+Jd01MZaTXX0RAj7hAKCWr19nOx/wK0nUVJN1jjfUjBbVnQCfUnhd
    tY09o+WnHwALynIt5PCN7F0=
    =Jf1D
    -----END PGP SIGNATURE-----
     
    , Oct 10, 2005
    #1
    1. Advertising

  2. sam Guest

    Re: Wanted: Python module allowing direct access to raw sectors ofharddrives (MFT, boot sector, etc.) in MS Windows

    The following site contains my routines to access information from the
    Microsoft SCSIPASSTHROUGH layer under windows. These routines allow you
    to access the storage devices mounted under windows using SCSI
    commands. The dll that I provide will work with Python 2.3

    http://starship.python.net/crew/samschul/

    Sam Schulenburg

    Claudio Grondi wrote:
    > Thank you Jeff very much for your quick reply.
    > It saved me really much time of digging in the wrong direction.
    >
    > <> wrote in
    > news:<>...
    > >> I took the advice from this web page:
    > >> http://support.microsoft.com/kb/q100027/

    > Ok, I had found this page myself during Googling, but I have missed just
    > to try to use the described way of addressing physical devices with file
    > opening in Python.
    > It works as expected with harddrives so you are right that you are getting
    > the MBR with the proposed code.
    >
    > After some not always happy end adventures with Python
    > scripting I am impressed by the power of the concept behind
    > the language once again.
    >
    > Claudio
    >
    > >>(I don't know how this extends to floppies, and the 9x family of OSes

    > isn't
    > >>listed in "applies to", so this may not help your case)
    > >>Here, I open "physical drive 0" and see that the magic number indicates a

    > valid
    > >>boot record. I believe it is the MBR.
    > >>>>> f = open('\\\\.\\PhysicalDrive0', 'rb')
    > >>>>> f.read(512)[-2:]
    > >>'U\xaa' # that is, hex 55 AA
    > >>I don't know much about low-level filesystem or partition details--I got

    > the
    > >>tidbit about the 55 AA magic number from
    > >>http://www-uxsup.csx.cam.ac.uk/pub/doc/suse/sles9/adminguide-sles9/ch08.ht

    > ml
    > >>Jeff
    > >><> schrieb im Newsbeitrag

    > news:...
     
    sam, Oct 11, 2005
    #2
    1. Advertising

  3. Googling for keywords like
    "direct access sector harddrive Python module Windows"
    seems to give no useful results.

    Any hints(best if cross-platform)?

    Claudio
     
    Claudio Grondi, Oct 11, 2005
    #3
  4. Re: Wanted: Python module allowing direct access to raw sectors ofharddrives (MFT, boot sector, etc.) in MS Windows

    Thank you Jeff very much for your quick reply.
    It saved me really much time of digging in the wrong direction.

    <> wrote in
    news:<>...
    >> I took the advice from this web page:
    >> http://support.microsoft.com/kb/q100027/

    Ok, I had found this page myself during Googling, but I have missed just
    to try to use the described way of addressing physical devices with file
    opening in Python.
    It works as expected with harddrives so you are right that you are getting
    the MBR with the proposed code.

    After some not always happy end adventures with Python
    scripting I am impressed by the power of the concept behind
    the language once again.

    Claudio

    >>(I don't know how this extends to floppies, and the 9x family of OSes

    isn't
    >>listed in "applies to", so this may not help your case)
    >>Here, I open "physical drive 0" and see that the magic number indicates a

    valid
    >>boot record. I believe it is the MBR.
    >>>>> f = open('\\\\.\\PhysicalDrive0', 'rb')
    >>>>> f.read(512)[-2:]

    >>'U\xaa' # that is, hex 55 AA
    >>I don't know much about low-level filesystem or partition details--I got

    the
    >>tidbit about the 55 AA magic number from
    >>http://www-uxsup.csx.cam.ac.uk/pub/doc/suse/sles9/adminguide-sles9/ch08.ht

    ml
    >>Jeff
    >><> schrieb im Newsbeitrag

    news:...
     
    Claudio Grondi, Oct 11, 2005
    #4
  5. Re: Wanted: Python module allowing direct access to raw sectors ofharddrives (MFT, boot sector, etc.) in MS Windows

    Thank you for your reply, even if currently not
    that interesting for me because after the first
    CD writer for IDE were available I stopped to
    use SCSI and didn't come back to it since then.

    Does the Python open() command not work the
    same way for SCSI drives as for IDE or USB
    drives (I can't try it myself, because of above)?

    Claudio
    P.S. for those who are interested I have uploaded a
    Python script I wrote for myself to have a reference to
    this subject to:
    http://people.freenet.de/AiTI-IT/Python/HowTo_AccessRawSectorsOfPhysicalDrives.py
    :)

    "sam" <> schrieb im Newsbeitrag
    news:...
    > The following site contains my routines to access information from the
    > Microsoft SCSIPASSTHROUGH layer under windows. These routines allow you
    > to access the storage devices mounted under windows using SCSI
    > commands. The dll that I provide will work with Python 2.3
    >
    > http://starship.python.net/crew/samschul/
    >
    > Sam Schulenburg
    >
    > Claudio Grondi wrote:
    > > Thank you Jeff very much for your quick reply.
    > > It saved me really much time of digging in the wrong direction.
    > >
    > > <> wrote in
    > > news:<>...
    > > >> I took the advice from this web page:
    > > >> http://support.microsoft.com/kb/q100027/

    > > Ok, I had found this page myself during Googling, but I have missed just
    > > to try to use the described way of addressing physical devices with file
    > > opening in Python.
    > > It works as expected with harddrives so you are right that you are

    getting
    > > the MBR with the proposed code.
    > >
    > > After some not always happy end adventures with Python
    > > scripting I am impressed by the power of the concept behind
    > > the language once again.
    > >
    > > Claudio
    > >
    > > >>(I don't know how this extends to floppies, and the 9x family of OSes

    > > isn't
    > > >>listed in "applies to", so this may not help your case)
    > > >>Here, I open "physical drive 0" and see that the magic number

    indicates a
    > > valid
    > > >>boot record. I believe it is the MBR.
    > > >>>>> f = open('\\\\.\\PhysicalDrive0', 'rb')
    > > >>>>> f.read(512)[-2:]
    > > >>'U\xaa' # that is, hex 55 AA
    > > >>I don't know much about low-level filesystem or partition details--I

    got
    > > the
    > > >>tidbit about the 55 AA magic number from

    > >
    >>http://www-uxsup.csx.cam.ac.uk/pub/doc/suse/sles9/adminguide-sles9/ch08.ht
    > > ml
    > > >>Jeff
    > > >><> schrieb im Newsbeitrag

    > > news:...

    >
     
    Claudio Grondi, Oct 11, 2005
    #5
  6. On 2005-10-10, Claudio Grondi <> wrote:
    > Googling for keywords like
    > "direct access sector harddrive Python module Windows"
    > seems to give no useful results.
    >
    > Any hints(best if cross-platform)?
    >
    > Claudio
    >
    >
    >



    --
    Grant Edwards grante Yow! Maybe we could paint
    at GOLDIE HAWN a rich PRUSSIAN
    visi.com BLUE --
     
    Grant Edwards, Oct 11, 2005
    #6
  7. sam Guest

    Re: Wanted: Python module allowing direct access to raw sectors ofharddrives (MFT, boot sector, etc.) in MS Windows

    The main use of my SCSI routines,is that by using the SCSIPASSTHROUGH
    layer under Windows gives the user absolute control of the storage
    device. For example copying data from and IDE drive to a SCSI drive
    becomes transparent using SCSI commands. I.e Logical block 0 remains
    consistant. I had an PHD clam that using fopen(),and fread(),along with
    fwrite() with an offset of 0 would always get you sector zero,head
    zero on a drive. I was able to prove that this was not the case. When
    using the SCSIPASSTHROUGH layer LBA 0 will always return the first user
    accessable sector. Using Python open() behaves the same as the C
    functions,thus you would have the same problem.
     
    sam, Oct 11, 2005
    #7
  8. Claudio Grondi, Oct 13, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    971
    Pascal Bourguignon
    Nov 6, 2005
  2. thefritz_j
    Replies:
    16
    Views:
    910
  3. Gnurto
    Replies:
    3
    Views:
    1,261
    Victor Bazarov
    Dec 5, 2005
  4. vrushali662
    Replies:
    0
    Views:
    285
    vrushali662
    Jun 29, 2011
  5. Gary Hasson
    Replies:
    15
    Views:
    333
    Gary Hasson
    Nov 30, 2009
Loading...

Share This Page