Difference between revisions of "TruxtonFileIO"

From truxwiki.com
Jump to navigation Jump to search
Line 40: Line 40:
 
* [[TruxtonFileIO_newusb | newusb()]] - Used to create a record in the [[USBDevice Table | USBDevice table]] and associated with this file.
 
* [[TruxtonFileIO_newusb | newusb()]] - Used to create a record in the [[USBDevice Table | USBDevice table]] and associated with this file.
 
* [[TruxtonFileIO_tag | tag()]] - Used to associate a tag with this file.
 
* [[TruxtonFileIO_tag | tag()]] - Used to associate a tag with this file.
 +
 +
=Properties=
 +
 +
==<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.
 +
 +
==<code>attributes</code>==
 +
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.]
 +
 +
==<code>created</code>==
 +
When the file was created in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 +
 +
==<code>diskoffset</code>==
 +
The offset, in bytes, of the first byte of the contents of the file on the physical disk.
 +
 +
==<code>entropy</code>==
 +
[[Truxton_child_file_get_entropy | Shannon's entropy]] of the contents of the file.
 +
 +
==<code>hash</code>==
 +
The MD5 hash of the contents of the file.
 +
 +
==<code>id</code>==
 +
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the file record.
 +
This is valid once <code>save()</code>
 +
 +
==<code>mediaid</code>==
 +
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the media the child file came from.
 +
 +
==<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.
 +
 +
==<code>name</code>==
 +
The name of the file.
 +
 +
==<code>origin</code>==
 +
Where the file came from.
 +
It should be one of the [[Origin | origin values.]]
 +
 +
==<code>parentid</code>==
 +
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the parent of this file.
 +
 +
==<code>size</code>==
 +
The size, in bytes, of the file.
 +
 +
==<code>status</code>==
 +
The status of the contents of the file.
 +
It should be one of the [[Content Status | content status values.]]
 +
 +
==<code>type</code>==
 +
The [[File Types Supported | type ]] of the file.
  
 
=Sample=
 
=Sample=

Revision as of 03:36, 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.

attributes

An integer value representing the attributes of the file. For a Microsoft filesystem, it can be a combination of the file attribute flags.

created

When the file was created in FILETIME ticks.

diskoffset

The offset, in bytes, of the first byte of the contents of the file on the physical disk.

entropy

Shannon's entropy of the contents of the file.

hash

The MD5 hash of the contents of the file.

id

The GUID of the file record. This is valid once save()

mediaid

The GUID of the media the child file came from.

modified

When the file was last written in FILETIME ticks.

name

The name of the file.

origin

Where the file came from. It should be one of the origin values.

parentid

The GUID of the parent of this file.

size

The size, in bytes, of the file.

status

The status of the contents of the file. It should be one of the content status values.

type

The type of the file.

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()