Difference between revisions of "TruxtonChildFileIO"

From truxwiki.com
Jump to navigation Jump to search
Line 40: Line 40:
 
* [[TruxtonChildFileIO_newusb | newusb()]]
 
* [[TruxtonChildFileIO_newusb | newusb()]]
 
* [[TruxtonChildFileIO tag | tag()]]
 
* [[TruxtonChildFileIO tag | tag()]]
 +
 +
=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>created</code>==
 +
When the file was created in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 +
 +
==<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>parentid</code>==
 +
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the parent of this file.
 +
 +
==<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>attributes</code>==
 +
The attributes of the file.
 +
 +
==<code>size</code>==
 +
The size, in bytes, of the file.
 +
 +
==<code>origin</code>==
 +
Where the file came from.
 +
It should be one of the [[Origin | origin values.]]
 +
 +
==<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.
 +
 +
==<code>hash</code>==
 +
The MD5 hash of the contents of the file.
 +
 +
==<code>entropy</code>==
 +
[[Truxton_child_file_get_entropy | Shannon's entropy]] of the contents of the file.
 +
==<code>diskoffset</code>==
 +
The offset, in bytes, of the first byte of the contents of the file on the physical disk.
  
 
=Sample=
 
=Sample=

Revision as of 17:11, 27 May 2020

This class provides a writable file to add to Truxton.

IOBase Methods

From IOBase it implements:

RawIOBase Methods

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.

created

When the file was created in FILETIME ticks.

id

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

mediaid

The GUID of the media the child file came from.

parentid

The GUID of the parent of this file.

modified

When the file was last written in FILETIME ticks.

name

The name of the file.

attributes

The attributes of the file.

size

The size, in bytes, of the file.

origin

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

status

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

type

The type of the file.

hash

The MD5 hash of the contents of the file.

entropy

Shannon's entropy of the contents of the file.

diskoffset

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

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 shutil
from pathlib import Path

def add_file(parent_truxton_file, filename):
  source_file = open(filename, "rb")
  child = parent_truxton_file.newchild()
  child.name = Path(filename).name
  shutil.copyfileobj(source_file, child)
  source_file.close()
  child.save()
  return child

def main():
  t = truxton.create()
  file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")
  child = add_file(file, "C:\decrypts\PlainText.txt")

if __name__ == "__main__":
  main()