Difference between revisions of "TruxtonChildFileIO"

From truxwiki.com
Jump to navigation Jump to search
Line 31: Line 31:
 
The following methods are also present to make tasks of adding items extracted from a file easier.
 
The following methods are also present to make tasks of adding items extracted from a file easier.
  
* [[TruxtonChildFileIO_newartifact | newartifact()]]
+
* [[TruxtonChildFileIO addnote|addnote()]]
* [[TruxtonChildFileIO_newchild | newchild()]]
+
* [[TruxtonChildFileIO newartifact|newartifact()]]
* [[TruxtonChildFileIO newcommunication | newcommunication()]]
+
* [[TruxtonChildFileIO newchild|newchild()]]
* [[TruxtonChildFileIO_newevent | newevent()]]
+
* [[TruxtonChildFileIO newcommunication|newcommunication()]]
* [[TruxtonChildFileIO_newexif | newexif()]]
+
* [[TruxtonChildFileIO newevent|newevent()]]
* [[TruxtonChildFileIO_newlocation | newlocation()]]
+
* [[TruxtonChildFileIO newexif|newexif()]]
* [[TruxtonChildFileIO_newrelation | newrelation()]]
+
* [[TruxtonChildFileIO newlocation|newlocation()]]
* [[TruxtonChildFileIO_newurl | newurl()]]
+
* [[TruxtonChildFileIO newrelation|newrelation()]]
* [[TruxtonChildFileIO_newusb | newusb()]]
+
* [[TruxtonChildFileIO newurl|newurl()]]
* [[TruxtonChildFileIO tag | tag()]]
+
* [[TruxtonChildFileIO newusb|newusb()]]
 +
* [[TruxtonChildFileIO tag|tag()]]
  
 
=Properties=
 
=Properties=

Revision as of 07:08, 1 October 2022

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: int

When the file was last accessed in FILETIME ticks.

attributes: int

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

created: int

When the file was created in FILETIME ticks.

diskoffset: int

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

entropy: float

Shannon's entropy of the contents of the file.

hash: str

The MD5 hash of the contents of the file.

id: str

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

mediaid: str

The GUID of the media the child file came from.

modified: int

When the file was last written in FILETIME ticks.

name: str

The name of the file.

origin: int

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

parentid: str

The GUID of the parent of this file.

save() -> true

This will commit the information to the [File] table. It will return True if the record was saved to the database, False if there was an error.

size: int

The size, in bytes, of the file.

status: int

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

type: int

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 sys
sys.path.append('C:/Program Files/Truxton/SDK')
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()