Giter Club home page Giter Club logo

libsmdev's Introduction

libsmdev's People

Contributors

joachimmetz avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

libsmdev's Issues

"Can't Open Configure" in build

~/libsmdev$ sudo python setup.py build
running build
running build_ext
Traceback (most recent call last):
File "setup.py", line 348, in
data_files=[(PYTHON_LIBRARY_DIRECTORY, LIBRARY_DATA_FILES)],
File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
dist.run_commands()
File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
self.run_command(cmd)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run
self.run_command(cmd_name)
File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
self.distribution.run_command(command)
File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
cmd_obj.run()
File "setup.py", line 92, in run
output = self._RunCommand(command)
File "setup.py", line 73, in _RunCommand
command, error))
RuntimeError: Running: sh configure --disable-shared-libs failed with error:
sh: 0: Can't open configure

Segfault when calling pysmdev.check_device()

$ python3 -c 'import pysmdev; print(pysmdev.get_version()); pysmdev.check_device()'
20181227
Segmentation fault
$ python2 -c 'import pysmdev; print(pysmdev.get_version()); pysmdev.check_device()'
20181227
Segmentation fault
$ dpkg -l libsmdev-python
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  libsmdev-pytho 20181227-1   amd64        Python 2 bindings for libsmdev
$ dpkg -l libsmdev-python3
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
ii  libsmdev-pytho 20181227-1   amd64        Python 3 bindings for libsmdev

libsmdev_handle_read_buffer: offset exceeds media size.

I think this is the right repository for this issue. I was having an issue in DFVFS where volume shadows are not being opened for some logical volumes and think I have narrowed it down to this library. Here is the exact pysmdev error as shown in the following example (Python 2.7 and 3.6 both produce it):

pyvshadow_volume_open_file_object: unable to open volume. pyvshadow_file_object_read_buffer: unable to read from file object with error: 'pysmdev_handle_read_buffer: unable to read data. libsmdev_handle_read_buffer: offset exceeds media size.'.
 pyvshadow_file_object_io_handle_read: unable to read from file object.
 libbfio_handle_read_buffer: unable to read from handle.
 libvshadow_io_handle_read_ntfs_volume_header: unable to read NTFS backup volume header data.
 libvshadow_volume_open_read: unable to read NTFS volume header.
 libvshadow_volume_open_file_io_handle: unable to read from file IO handle.

with libsmdev_handle_read_buffer: offset exceeds media size. being the issue.

This is the same error I am seeing when trying the open the VShadow object in dfvfs.

I understand this will be difficult to reproduce because it is specific to my logical volume and I have not found a test image where the resulting error is reproduced. Maybe you can formulate a hypothesis by seeing what I did, and what the output was?

Whats weird is it works on my D: but not C:.
C: is on a SSD with bitlocker turned on.
D: is on a HD with bitlocker turned on.
More fs and drive info can be found at the bottom of this comment.

Below is the code I used to produce the error followed by the results of it being ran on my system:

import pysmdev
import pyvshadow


def main():
    ######################################################
    # using normal file handle
    ######################################################
    print("Test 1: VShadow from C as file handle")
    with open('\\\\.\\C:', "rb") as volume_handle:
        vshadow_volume = pyvshadow.volume()
        try:
            vshadow_volume.open_file_object(
                volume_handle
            )
            print("VSS Found for C: Store count -> {}".format(
                vshadow_volume.get_number_of_stores()
            ))
        except Exception as error:
            error_str = str(error).replace("\r", "\n")
            print("Error Opening VShadow using <file> on [C:]")
            print(error_str)
    print("\n")

    print("Test 2: VShadow from D as file handle")
    # As regular file.
    with open('\\\\.\\D:', "rb") as volume_handle:
        vshadow_volume = pyvshadow.volume()
        try:
            vshadow_volume.open_file_object(
                volume_handle
            )
            print("VSS Found for D: Store count -> {}".format(
                vshadow_volume.get_number_of_stores()
            ))
        except Exception as error:
            error_str = str(error).replace("\r", "\n")
            print("Error Opening VShadow using <file> on [D:]")
            print(error_str)
    print("\n")

    ######################################################
    # using pysmdev handle
    ######################################################
    print("Test 3: VShadow from C as pymsdev.handle")
    smdev_handle = pysmdev.handle()
    smdev_handle.open("\\\\.\\C:")

    vshadow_volume = pyvshadow.volume()
    try:
        vshadow_volume.open_file_object(
            smdev_handle
        )
        print("VSS Found for C: Store count -> {}".format(
            vshadow_volume.get_number_of_stores()
        ))
    except Exception as error:
        error_str = str(error).replace("\r", "\n")
        print("Error Opening VShadow using <pysmdev.handle> on [C:]")
        print(error_str)
    print("\n")

    print("Test 4: VShadow from D as pymsdev.handle")
    smdev_handle = pysmdev.handle()
    smdev_handle.open("\\\\.\\D:")

    vshadow_volume = pyvshadow.volume()
    try:
        vshadow_volume.open_file_object(
            smdev_handle
        )
        print("VSS Found for D: Store count -> {}".format(
            vshadow_volume.get_number_of_stores()
        ))
    except Exception as error:
        error_str = str(error).replace("\r", "\n")
        print("Error Opening VShadow using <pysmdev.handle> on [D:]")
        print(error_str)
    print("\n")


if __name__ == "__main__":
    main()
Test 1: VShadow from C as file handle
VSS Found for C: Store count -> 11


Test 2: VShadow from D as file handle
VSS Found for D: Store count -> 11


Test 3: VShadow from C as pymsdev.handle
Error Opening VShadow using <pysmdev.handle> on [C:]
pyvshadow_volume_open_file_object: unable to open volume. pyvshadow_file_object_read_buffer: unable to read from file object with error: 'pysmdev_handle_read_buffer: unable to read data. libsmdev_handle_read_buffer: offset exceeds media size.'.
 pyvshadow_file_object_io_handle_read: unable to read from file object.
 libbfio_handle_read_buffer: unable to read from handle.
 libvshadow_io_handle_read_ntfs_volume_header: unable to read NTFS backup volume header data.
 libvshadow_volume_open_read: unable to read NTFS volume header.
 libvshadow_volume_open_file_io_handle: unable to read from file IO handle.


Test 4: VShadow from D as pymsdev.handle
VSS Found for D: Store count -> 11

Python 2.6 x64 - Library Versions:

>>> import pysmdev
>>> pysmdev.get_version()
u'20171112'
>>> import pyvshadow
>>> pyvshadow.get_version()
u'20170902'

Python 3.6 x64 - Library Versions:

>>> import pysmdev
>>> pysmdev.get_version()
'20171112'
>>> import pyvshadow
>>> pyvshadow.get_version()
'20170902'

Not sure if the following helps or not. But I thought I would include it just in case.

C: Volume info:

NTFS Version   :                   3.1
LFS Version    :                   2.0
Number Sectors :                   0x0000000037c60f44
Total Clusters :                   0x0000000006f8c1e8
Free Clusters  :                   0x00000000050b7fa9
Total Reserved :                   0x000000000000233f
Bytes Per Sector  :                512
Bytes Per Physical Sector :        512
Bytes Per Cluster :                4096
Bytes Per FileRecord Segment    :  1024
Clusters Per FileRecord Segment :  0
Mft Valid Data Length :            0x000000005b140000
Mft Start Lcn  :                   0x00000000000c0000
Mft2 Start Lcn :                   0x0000000000000002
Mft Zone Start :                   0x0000000003729ce0
Mft Zone End   :                   0x0000000003736500
Max Device Trim Extent Count :     0
Max Device Trim Byte Count :       0x0
Max Volume Trim Extent Count :     62
Max Volume Trim Byte Count :       0x40000000

---DRIVE INFO---
PSComputerName              : DESKTOP
ConfigManagerErrorCode      : 0
LastErrorCode               :
NeedsCleaning               :
Status                      : OK
DeviceID                    : \\.\PHYSICALDRIVE0
StatusInfo                  :
Partitions                  : 3
BytesPerSector              : 512
ConfigManagerUserConfig     : False
DefaultBlockSize            :
Index                       : 0
InstallDate                 :
InterfaceType               : SCSI
MaxBlockSize                :
MaxMediaSize                :
MinBlockSize                :
NumberOfMediaSupported      :
SectorsPerTrack             : 63
Size                        : 480101368320
TotalCylinders              : 58369
TotalHeads                  : 255
TotalSectors                : 937697985
TotalTracks                 : 14884095
TracksPerCylinder           : 255
__GENUS                     : 2
__CLASS                     : Win32_DiskDrive
__SUPERCLASS                : CIM_DiskDrive
__DYNASTY                   : CIM_ManagedSystemElement
__RELPATH                   : Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"
__PROPERTY_COUNT            : 51
__DERIVATION                : {CIM_DiskDrive, CIM_MediaAccessDevice, CIM_LogicalDevice, CIM_LogicalElement...}
__SERVER                    : DESKTOP
__NAMESPACE                 : root\cimv2
__PATH                      : \\DESKTOP\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"
Availability                :
Capabilities                : {3, 4}
CapabilityDescriptions      : {Random Access, Supports Writing}
Caption                     : ATA INTEL SSDSC2BP48 SCSI Disk Device
CompressionMethod           :
CreationClassName           : Win32_DiskDrive
Description                 : Disk drive
ErrorCleared                :
ErrorDescription            :
ErrorMethodology            :
FirmwareRevision            : 0420
Manufacturer                : (Standard disk drives)
MediaLoaded                 : True
MediaType                   : Fixed hard disk media
Model                       : ATA INTEL SSDSC2BP48 SCSI Disk Device
Name                        : \\.\PHYSICALDRIVE0
PNPDeviceID                 : SCSI\DISK&VEN_ATA&PROD_INTEL_SSDSC2BP48\5&ADA8C50&0&000000
PowerManagementCapabilities :
PowerManagementSupported    :
SCSIBus                     : 0
SCSILogicalUnit             : 0
SCSIPort                    : 0
SCSITargetId                : 0
SerialNumber                : x
Signature                   : 809290414
SystemCreationClassName     : Win32_ComputerSystem
SystemName                  : DESKTOP
Scope                       : System.Management.ManagementScope
Path                        : \\DESKTOP\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE0"
Options                     : System.Management.ObjectGetOptions
ClassPath                   : \\DESKTOP\root\cimv2:Win32_DiskDrive
Properties                  : {Availability, BytesPerSector, Capabilities, CapabilityDescriptions...}
SystemProperties            : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}
Qualifiers                  : {dynamic, Locale, provider, UUID}
Site                        :
Container                   :

D: Volume info:

NTFS Volume Serial Number :        0xaad2d584d2d55563
NTFS Version   :                   3.1
LFS Version    :                   2.0
Number Sectors :                   0x00000000e8e077ff
Total Clusters :                   0x000000001d1c0eff
Free Clusters  :                   0x000000001a528d1d
Total Reserved :                   0x00000000000013ef
Bytes Per Sector  :                512
Bytes Per Physical Sector :        512
Bytes Per Cluster :                4096
Bytes Per FileRecord Segment    :  1024
Clusters Per FileRecord Segment :  0
Mft Valid Data Length :            0x0000000008d80000
Mft Start Lcn  :                   0x00000000000c0000
Mft2 Start Lcn :                   0x0000000000000002
Mft Zone Start :                   0x00000000000c8d80
Mft Zone End   :                   0x00000000000cc840
Max Device Trim Extent Count :     0
Max Device Trim Byte Count :       0x0
Max Volume Trim Extent Count :     62
Max Volume Trim Byte Count :       0x40000000

---DRIVE INFO---
PSComputerName              : DESKTOP
ConfigManagerErrorCode      : 0
LastErrorCode               :
NeedsCleaning               :
Status                      : OK
DeviceID                    : \\.\PHYSICALDRIVE1
StatusInfo                  :
Partitions                  : 1
BytesPerSector              : 512
ConfigManagerUserConfig     : False
DefaultBlockSize            :
Index                       : 1
InstallDate                 :
InterfaceType               : SCSI
MaxBlockSize                :
MaxMediaSize                :
MinBlockSize                :
NumberOfMediaSupported      :
SectorsPerTrack             : 63
Size                        : 2000396321280
TotalCylinders              : 243201
TotalHeads                  : 255
TotalSectors                : 3907024065
TotalTracks                 : 62016255
TracksPerCylinder           : 255
__GENUS                     : 2
__CLASS                     : Win32_DiskDrive
__SUPERCLASS                : CIM_DiskDrive
__DYNASTY                   : CIM_ManagedSystemElement
__RELPATH                   : Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE1"
__PROPERTY_COUNT            : 51
__DERIVATION                : {CIM_DiskDrive, CIM_MediaAccessDevice, CIM_LogicalDevice, CIM_LogicalElement...}
__SERVER                    : DESKTOP
__NAMESPACE                 : root\cimv2
__PATH                      : \\DESKTOP\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE1"
Availability                :
Capabilities                : {3, 4}
CapabilityDescriptions      : {Random Access, Supports Writing}
Caption                     : ATA WDC WD2003FZEX-0 SCSI Disk Device
CompressionMethod           :
CreationClassName           : Win32_DiskDrive
Description                 : Disk drive
ErrorCleared                :
ErrorDescription            :
ErrorMethodology            :
FirmwareRevision            : 1A01
Manufacturer                : (Standard disk drives)
MediaLoaded                 : True
MediaType                   : Fixed hard disk media
Model                       : ATA WDC WD2003FZEX-0 SCSI Disk Device
Name                        : \\.\PHYSICALDRIVE1
PNPDeviceID                 : SCSI\DISK&VEN_ATA&PROD_WDC_WD2003FZEX-0\5&ADA8C50&0&000100
PowerManagementCapabilities :
PowerManagementSupported    :
SCSIBus                     : 0
SCSILogicalUnit             : 0
SCSIPort                    : 0
SCSITargetId                : 1
SerialNumber                :      xxxxxxxxxxxxxxxx
Signature                   : 1619285509
SystemCreationClassName     : Win32_ComputerSystem
SystemName                  : DESKTOP
Scope                       : System.Management.ManagementScope
Path                        : \\DESKTOP\root\cimv2:Win32_DiskDrive.DeviceID="\\\\.\\PHYSICALDRIVE1"
Options                     : System.Management.ObjectGetOptions
ClassPath                   : \\DESKTOP\root\cimv2:Win32_DiskDrive
Properties                  : {Availability, BytesPerSector, Capabilities, CapabilityDescriptions...}
SystemProperties            : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}
Qualifiers                  : {dynamic, Locale, provider, UUID}
Site                        :
Container                   ๐Ÿ‘ 

AppVeyor build failed

I have a pull requests ,but AppVeyor build failed . Please help what happend?
I think it is not a code problem.

make more error tollerant

In combination with libewf don't make this error blocking:

Device information:
Unable to print media information.
libsmdev_string_trim_copy_from_byte_stream: string too small.
libsmdev_internal_handle_determine_media_information: unable to set serial number.
libsmdev_handle_get_bus_type: unable to determine media information.
device_handle_media_information_fprint: unable to retrieve bus type.
Unable to retrieve media type from device.
libsmdev_string_trim_copy_from_byte_stream: string too small.
libsmdev_internal_handle_determine_media_information: unable to set serial number.
libsmdev_handle_get_media_type: unable to determine media information.
device_handle_get_media_type: unable to retrieve media type.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.