Difference between revisions of "TruxtonChildFileIO"
| 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. | ||
| + | |||
| + | ==<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>== | ==<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. | ||
| + | |||
| + | ==<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>== | ==<code>id</code>== | ||
| Line 55: | Line 68: | ||
==<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. | ||
| − | |||
| − | |||
| − | |||
==<code>modified</code>== | ==<code>modified</code>== | ||
| Line 65: | Line 75: | ||
The name of the file. | The name of the file. | ||
| − | ==<code> | + | ==<code>origin</code>== |
| − | The | + | 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>== | ==<code>size</code>== | ||
The size, in bytes, of the file. | The size, in bytes, of the file. | ||
| − | |||
| − | |||
| − | |||
| − | |||
==<code>status</code>== | ==<code>status</code>== | ||
| Line 81: | Line 91: | ||
==<code>type</code>== | ==<code>type</code>== | ||
The [[File Types Supported | type ]] of the file. | The [[File Types Supported | type ]] of the file. | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
=Sample= | =Sample= | ||
Revision as of 02:53, 28 May 2020
This class provides a writable file to add to Truxton.
Contents
IOBase Methods
From IOBase it implements:
- close()
- closed
- fileno() - Will return ERROR
- flush()
- isatty()
- readable() - Always returns FALSE
- readline() - Do not use, will return ERROR
- readlines() - Do not use, will return ERROR
- seek() - Will return ERROR
- seekable() - returns FALSE
- tell()
- truncate()
- writable() - returns TRUE
- writelines()
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.
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 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()