Difference between revisions of "TruxtonFileIO"

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.
  
* [[TruxtonFileIO_newartifact | newartifact()]] - Creates a record in the [[Entity Table | entity table.]]
+
* [[TruxtonFileIO_newartifact | newartifact()]] - Used to create a record in the [[Entity Table | entity table]] and associated with this file.
 
* [[TruxtonFileIO_newchild | newchild()]] - Creates a writable file that will be a child of this file.
 
* [[TruxtonFileIO_newchild | newchild()]] - Creates a writable file that will be a child of this file.
* [[TruxtonFileIO_newevent | newevent()]] -  
+
* [[TruxtonFileIO_newevent | newevent()]] - Used to create a record in the [[Event Table | Event table]] and associated with this file.
* [[TruxtonFileIO_newexif | newexif()]]
+
* [[TruxtonFileIO_newexif | newexif()]] - Used to create a record in the [[EXIF Table | EXIF table]] and associated with this file.
* [[TruxtonFileIO_newlocation | newlocation()]]
+
* [[TruxtonFileIO_newlocation | newlocation()]] - Used to create a record in the [[Location Table | Location table]] and associated with this file.
* [[TruxtonFileIO_newrelation | newrelation()]]
+
* [[TruxtonFileIO_newrelation | newrelation()]] - Used to create a record in the [[Relation Table | Relation table]] and associated with this file.
* [[TruxtonFileIO_newurl | newurl()]]
+
* [[TruxtonFileIO_newurl | newurl()]] - Used to create a record in the [[WebsiteVisit Table | WebsiteVisit table]] and associated with this file.
* [[TruxtonFileIO_newusb | newusb()]]
+
* [[TruxtonFileIO_newusb | newusb()]] - Used to create a record in the [[USBDevice Table | USBDevice table]] and associated with this file.
 
 
  
 
=Sample=
 
=Sample=

Revision as of 14:08, 25 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.

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