Difference between revisions of "TruxtonFileIO"

From truxwiki.com
Jump to navigation Jump to search
Line 45: Line 45:
 
==<code>accessed</code>==
 
==<code>accessed</code>==
 
When the file was last accessed in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 
When the file was last accessed in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 +
This corresponds to the <code>LastAccess</code> column of the <code>File</code> table.
  
 
==<code>attributes</code>==
 
==<code>attributes</code>==
 
An integer value representing the attributes of the file.
 
An integer value representing the attributes of the file.
 
For a Microsoft filesystem, it can be a combination of the [https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants file attribute flags.]
 
For a Microsoft filesystem, it can be a combination of the [https://docs.microsoft.com/en-us/windows/win32/fileio/file-attribute-constants file attribute flags.]
 +
This corresponds to the <code>Attributes</code> column of the <code>File</code> table.
  
 
==<code>created</code>==
 
==<code>created</code>==
 
When the file was created in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 
When the file was created in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 +
This corresponds to the <code>Created</code> column of the <code>File</code> table.
  
 
==<code>diskoffset</code>==
 
==<code>diskoffset</code>==
 
The offset, in bytes, of the first byte of the contents of the file on the physical disk.
 
The offset, in bytes, of the first byte of the contents of the file on the physical disk.
 +
This corresponds to the <code>PhysicalDiskOffset</code> column of the <code>File</code> table.
  
 
==<code>entropy</code>==
 
==<code>entropy</code>==
 
[[Truxton_child_file_get_entropy | Shannon's entropy]] of the contents of the file.
 
[[Truxton_child_file_get_entropy | Shannon's entropy]] of the contents of the file.
 +
This corresponds to the <code>RawEntropy</code> column of the <code>File</code> table.
  
 
==<code>hash</code>==
 
==<code>hash</code>==
The MD5 hash of the contents of the file.
+
The [https://en.wikipedia.org/wiki/MD5 MD5] hash of the contents of the file.
 +
This corresponds to the <code>HashID</code> column of the <code>File</code> table.
  
 
==<code>id</code>==
 
==<code>id</code>==
 
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the file record.
 
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the file record.
This is valid once <code>save()</code>
+
This corresponds to the <code>ID</code> column of the <code>File</code> table.
  
 
==<code>mediaid</code>==
 
==<code>mediaid</code>==
 
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the media the child file came from.
 
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the media the child file came from.
 +
This corresponds to the <code>MediaID</code> column of the <code>File</code> table.
  
 
==<code>modified</code>==
 
==<code>modified</code>==
 
When the file was last written in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 
When the file was last written in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 +
This corresponds to the <code>LastWrite</code> column of the <code>File</code> table.
  
 
==<code>name</code>==
 
==<code>name</code>==
Line 78: Line 86:
 
Where the file came from.
 
Where the file came from.
 
It should be one of the [[Origin | origin values.]]
 
It should be one of the [[Origin | origin values.]]
 +
This corresponds to the <code>OriginID</code> column of the <code>File</code> table.
  
 
==<code>parentid</code>==
 
==<code>parentid</code>==
 
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the parent of this file.
 
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the parent of this file.
 +
This corresponds to the <code>ParentFileID</code> column of the <code>File</code> table.
  
 
==<code>size</code>==
 
==<code>size</code>==
 
The size, in bytes, of the file.
 
The size, in bytes, of the file.
 +
This corresponds to the <code>OSLength</code> column of the <code>File</code> table.
  
 
==<code>status</code>==
 
==<code>status</code>==
 
The status of the contents of the file.
 
The status of the contents of the file.
 
It should be one of the [[Content Status | content status values.]]
 
It should be one of the [[Content Status | content status values.]]
 +
This corresponds to the <code>ContentStatusID</code> column of the <code>File</code> table.
  
 
==<code>type</code>==
 
==<code>type</code>==
The [[File Types Supported | type ]] of the file.
+
The [[File Types Supported | type]] of the file.
 +
This corresponds to the <code>FileTypeID</code> column of the <code>File</code> table.
  
 
=Sample=
 
=Sample=

Revision as of 03:53, 28 May 2020

This class provides read-only access to a file's contents in Truxton.

IOBase Methods

From IOBase it implements:

RawIOBase

From RawIOBase it implements:

Truxton Methods

The above methods will let you read from a file in Truxton as if it were any other file in Python. The following methods are also present to make tasks of adding items extracted from a file easier.

Properties

accessed

When the file was last accessed in FILETIME ticks. This corresponds to the LastAccess column of the File table.

attributes

An integer value representing the attributes of the file. For a Microsoft filesystem, it can be a combination of the file attribute flags. This corresponds to the Attributes column of the File table.

created

When the file was created in FILETIME ticks. This corresponds to the Created column of the File table.

diskoffset

The offset, in bytes, of the first byte of the contents of the file on the physical disk. This corresponds to the PhysicalDiskOffset column of the File table.

entropy

Shannon's entropy of the contents of the file. This corresponds to the RawEntropy column of the File table.

hash

The MD5 hash of the contents of the file. This corresponds to the HashID column of the File table.

id

The GUID of the file record. This corresponds to the ID column of the File table.

mediaid

The GUID of the media the child file came from. This corresponds to the MediaID column of the File table.

modified

When the file was last written in FILETIME ticks. This corresponds to the LastWrite column of the File table.

name

The name of the file.

origin

Where the file came from. It should be one of the origin values. This corresponds to the OriginID column of the File table.

parentid

The GUID of the parent of this file. This corresponds to the ParentFileID column of the File table.

size

The size, in bytes, of the file. This corresponds to the OSLength column of the File table.

status

The status of the contents of the file. It should be one of the content status values. This corresponds to the ContentStatusID column of the File table.

type

The type of the file. This corresponds to the FileTypeID column of the File table.

Sample

This will retrieve a file from Truxton, print the name and hash as stored in the database then calculate a hash on the contents and print that.

import truxton
import hashlib

def main():
  t = truxton.create()
  file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")
  print(file.hash + " is the hash in the database for " + file.name )
  bytes = file.readall()
  readable_hash = hashlib.md5(bytes).hexdigest()
  print(readable_hash + " is the calculated hash of the contents")

if __name__ == "__main__":
  main()