Difference between revisions of "TruxtonArtifact"
(→Sample) |
|||
| (14 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
| − | This class lets you add to the [[Entity Table | Entity]] table in Truxton. | + | This class lets you add to the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table in Truxton. |
=Attributes and Methods= | =Attributes and Methods= | ||
| − | ==<code>datatype</code>== | + | ==<code>datatype: int</code>== |
| − | The raw [[DATA_TYPE | data type]] of the representation of the entity. | + | The raw [[DATA_TYPE|data type]] of the representation of the entity. |
| − | This corresponds to the <code>DataTypeID</code> column of the [[Entity Table | < | + | This corresponds to the <code>[DataTypeID]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table. |
| − | ==<code>fileid</code>== | + | ==<code>fileid: str</code>== |
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the file this artifact came from. | The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the file this artifact came from. | ||
| − | This corresponds to the <code>FileID</code> column of the [[Entity Table | < | + | This corresponds to the <code>[FileID]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table. |
| − | ==<code>id</code>== | + | ==<code>id: str</code>== |
This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the record. | This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the record. | ||
It becomes non-zero after <code>save()</code> has been called. | It becomes non-zero after <code>save()</code> has been called. | ||
| − | This corresponds to the <code>ID</code> column of the [[Entity Table | < | + | This corresponds to the <code>[ID]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table. |
| − | ==<code>length</code>== | + | ==<code>length: int</code>== |
The number of bytes in the raw representation of the artifact. | The number of bytes in the raw representation of the artifact. | ||
| − | This corresponds to the <code>Length</code> column of the [[Entity Table | < | + | This corresponds to the <code>[Length]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table. |
| − | ==<code>mediaid</code>== | + | ==<code>mediaid: str</code>== |
This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the media this artifact came from. | This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the media this artifact came from. | ||
| − | This corresponds to the <code>MediaID</code> column of the [[Entity Table | < | + | This corresponds to the <code>[MediaID]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table. |
| − | ==<code>objectid</code>== | + | ==<code>objectid: str</code>== |
This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the object this artifact came from. | This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the object this artifact came from. | ||
This combined with <code>objecttype</code> allows Truxton to track derivative entities such as a search term coming from a URL found in a browser cache. | This combined with <code>objecttype</code> allows Truxton to track derivative entities such as a search term coming from a URL found in a browser cache. | ||
| − | In this example, <code>fileid</code> would point to the browser cache | + | In this example, <code>fileid</code> would point to the browser cache <code><nowiki>[</nowiki>[[File Table|File]]<nowiki>]</nowiki></code> record and <code>objectid</code> would point to the record in the <code><nowiki>[</nowiki>[[WebsiteVisit Table|WebsiteVisit]]<nowiki>]</nowiki></code> table. |
| − | ==<code>objecttype</code>== | + | ==<code>objecttype: int</code>== |
The type of the object. | The type of the object. | ||
| − | This corresponds to the <code>ObjectTypeID</code> column of the [[Entity Table | < | + | This corresponds to the <code>[ObjectTypeID]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table. |
| + | It should contain one of the [[Object Types|predefined constants]]. | ||
| − | ==<code>offset</code>== | + | ==<code>offset: int</code>== |
| − | The offset from the beginning of the file where this | + | The offset from the beginning of the file where this artifact begins. |
| − | ==<code>type</code>== | + | ==<code>type: int</code>== |
The type of the artifact is. | The type of the artifact is. | ||
| − | This corresponds to the <code>EntityTypeID</code> column of the [[Entity Table | < | + | This corresponds to the <code>[EntityTypeID]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table. |
| − | It must be a value listed in the <code>ID</code> column of the <code>EntityType</code> table. | + | It must be a value listed in the <code>[ID]</code> column of the <code>[EntityType]</code> table. |
| − | You can also use a [[Entity Types | predefined constant.]] | + | You can also use a [[Entity Types|predefined constant.]] |
| − | ==<code>value</code>== | + | ==<code>value: str</code>== |
The string representation of the artifact. | The string representation of the artifact. | ||
| − | This corresponds to the <code>Value</code> column of the <code>EntityString</code> table. | + | This corresponds to the <code>[Value]</code> column of the <code>[EntityString]</code> table. |
| − | ==<code>save()</code>== | + | ==<code>save() -> boolean</code>== |
| − | This will commit the information to the [[Entity Table | < | + | This will commit the information to the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table. |
It will return [https://docs.python.org/3/library/constants.html#True True] if the record was saved to the database, [https://docs.python.org/3/library/constants.html#False False] if there was an error. | It will return [https://docs.python.org/3/library/constants.html#True True] if the record was saved to the database, [https://docs.python.org/3/library/constants.html#False False] if there was an error. | ||
| − | ==<code>tag(tag, reason, origin)</code>== | + | ==<code>addnote(text: str) -> boolean</code>== |
| − | This creates a tag associated with this | + | This adds an investigator's note. |
| + | The <code>text</code> parameter is the contents of the note. | ||
| + | It will return | ||
| + | [https://docs.python.org/3.10/library/constants.html?highlight=false#True True] if the tag was associated with the artifact, [https://docs.python.org/3.10/library/constants.html?highlight=false#False False] on failure. | ||
| + | |||
| + | ==<code>tag(tag: str, reason: str, origin: int) -> boolean</code>== | ||
| + | This creates a tag associated with this artifact in Truxton. | ||
The <code>tag</code> parameter is a short, one or two word, bit of text that will be displayed in the UI. | The <code>tag</code> parameter is a short, one or two word, bit of text that will be displayed in the UI. | ||
| − | The <code>reason</code> a sentence explaining why this | + | The <code>reason</code> a sentence explaining why this artifact was tagged. |
The <code>origin</code> is either <code>TAG_ORIGIN_AUTOMATIC</code> (1) or <code>TAG_ORIGIN_HUMAN</code> (2). | The <code>origin</code> is either <code>TAG_ORIGIN_AUTOMATIC</code> (1) or <code>TAG_ORIGIN_HUMAN</code> (2). | ||
It will return | It will return | ||
| − | [https://docs.python.org/3.8/library/constants.html?highlight=false#True True] if the tag was associated with the | + | [https://docs.python.org/3.8/library/constants.html?highlight=false#True True] if the tag was associated with the artifact, [https://docs.python.org/3.8/library/constants.html?highlight=false#False False] on failure. |
=Sample= | =Sample= | ||
| − | + | Sample Code | |
| − | < | + | <source lang="Python" highlight="50-55,57"> |
| + | import sys | ||
| + | sys.path.append('C:/Program Files/Truxton/SDK') | ||
import truxton | import truxton | ||
import shutil | import shutil | ||
| Line 69: | Line 78: | ||
EPOCH_AS_FILETIME = 116444736000000000 | EPOCH_AS_FILETIME = 116444736000000000 | ||
HUNDREDS_OF_NANOSECONDS = 10000000 | HUNDREDS_OF_NANOSECONDS = 10000000 | ||
| − | |||
| − | |||
def date_to_filetime(dt): | def date_to_filetime(dt): | ||
| Line 80: | Line 87: | ||
event_type.name = name | event_type.name = name | ||
event_type.save() | event_type.save() | ||
| + | return None | ||
def add_file(parent_truxton_file, filename): | def add_file(parent_truxton_file, filename): | ||
| Line 88: | Line 96: | ||
source_file.close() | source_file.close() | ||
child.save() | child.save() | ||
| + | |||
return child | return child | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
def add_media(t): | def add_media(t): | ||
media = t.newmedia() | media = t.newmedia() | ||
| − | |||
media.name = "Public Documents" | media.name = "Public Documents" | ||
media.description = "Publicly available documents" | media.description = "Publicly available documents" | ||
| Line 111: | Line 109: | ||
media.longitude = -77.036458 | media.longitude = -77.036458 | ||
media.type = truxton.MEDIA_TYPE_LOGICAL_FILES | media.type = truxton.MEDIA_TYPE_LOGICAL_FILES | ||
| − | + | media.save() | |
| − | |||
| − | |||
| − | |||
| − | |||
return media | return media | ||
| Line 122: | Line 116: | ||
child_file = add_file(parent_file, "JW-v-DOJ-reply-02743.pdf") | child_file = add_file(parent_file, "JW-v-DOJ-reply-02743.pdf") | ||
| − | + | artifact = child_file.newartifact() | |
| − | + | artifact.type = truxton.ENTITY_TYPE_AUTHOR | |
| − | + | artifact.value = "Bob Smith" | |
| − | + | artifact.datatype = truxton.DATA_TYPE_ASCII | |
| − | + | artifact.length = 9 | |
| − | + | artifact.save() | |
| − | |||
| − | |||
| − | + | artifact.addnote('I think this was the filing that mentioned dead squirrels') | |
| − | + | ||
| − | + | return None | |
def main(): | def main(): | ||
t = truxton.create() | t = truxton.create() | ||
| − | |||
| − | |||
media = add_media(t) | media = add_media(t) | ||
| Line 146: | Line 136: | ||
add_ec(root_file) | add_ec(root_file) | ||
| + | |||
| + | return None | ||
if __name__ == "__main__": | if __name__ == "__main__": | ||
| − | main() | + | sys.exit(main()) |
| − | </ | + | </source> |
Latest revision as of 15:06, 27 January 2024
This class lets you add to the [Entity] table in Truxton.
Contents
Attributes and Methods
datatype: int
The raw data type of the representation of the entity.
This corresponds to the [DataTypeID] column of the [Entity] table.
fileid: str
The GUID of the file this artifact came from.
This corresponds to the [FileID] column of the [Entity] table.
id: str
This is the GUID of the record.
It becomes non-zero after save() has been called.
This corresponds to the [ID] column of the [Entity] table.
length: int
The number of bytes in the raw representation of the artifact.
This corresponds to the [Length] column of the [Entity] table.
mediaid: str
This is the GUID of the media this artifact came from.
This corresponds to the [MediaID] column of the [Entity] table.
objectid: str
This is the GUID of the object this artifact came from.
This combined with objecttype allows Truxton to track derivative entities such as a search term coming from a URL found in a browser cache.
In this example, fileid would point to the browser cache [File] record and objectid would point to the record in the [WebsiteVisit] table.
objecttype: int
The type of the object.
This corresponds to the [ObjectTypeID] column of the [Entity] table.
It should contain one of the predefined constants.
offset: int
The offset from the beginning of the file where this artifact begins.
type: int
The type of the artifact is.
This corresponds to the [EntityTypeID] column of the [Entity] table.
It must be a value listed in the [ID] column of the [EntityType] table.
You can also use a predefined constant.
value: str
The string representation of the artifact.
This corresponds to the [Value] column of the [EntityString] table.
save() -> boolean
This will commit the information to the [Entity] table.
It will return True if the record was saved to the database, False if there was an error.
addnote(text: str) -> boolean
This adds an investigator's note.
The text parameter is the contents of the note.
It will return
True if the tag was associated with the artifact, False on failure.
tag(tag: str, reason: str, origin: int) -> boolean
This creates a tag associated with this artifact in Truxton.
The tag parameter is a short, one or two word, bit of text that will be displayed in the UI.
The reason a sentence explaining why this artifact was tagged.
The origin is either TAG_ORIGIN_AUTOMATIC (1) or TAG_ORIGIN_HUMAN (2).
It will return
True if the tag was associated with the artifact, False on failure.
Sample
Sample Code
import sys
sys.path.append('C:/Program Files/Truxton/SDK')
import truxton
import shutil
from datetime import datetime
from calendar import timegm
from pathlib import Path
EPOCH_AS_FILETIME = 116444736000000000
HUNDREDS_OF_NANOSECONDS = 10000000
def date_to_filetime(dt):
return EPOCH_AS_FILETIME + (timegm(dt.timetuple()) * HUNDREDS_OF_NANOSECONDS)
def create_event_type(t, id, name):
event_type = t.neweventtype()
event_type.id = id
event_type.name = name
event_type.save()
return None
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 add_media(t):
media = t.newmedia()
media.name = "Public Documents"
media.description = "Publicly available documents"
media.case = "DC-SNAFU-2016.2020"
media.evidencebag = "EV-0937459386623-a"
media.originator = "Jeffrey Jensen"
media.latitude = 38.897661
media.longitude = -77.036458
media.type = truxton.MEDIA_TYPE_LOGICAL_FILES
media.save()
return media
def add_ec(parent_file ):
child_file = add_file(parent_file, "JW-v-DOJ-reply-02743.pdf")
artifact = child_file.newartifact()
artifact.type = truxton.ENTITY_TYPE_AUTHOR
artifact.value = "Bob Smith"
artifact.datatype = truxton.DATA_TYPE_ASCII
artifact.length = 9
artifact.save()
artifact.addnote('I think this was the filing that mentioned dead squirrels')
return None
def main():
t = truxton.create()
media = add_media(t)
root_file = media.addroot()
root_file.save()
add_ec(root_file)
return None
if __name__ == "__main__":
sys.exit(main())