Difference between revisions of "TruxtonArtifact"

From truxwiki.com
Jump to navigation Jump to search
 
(13 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 | <code>Entity</code>]] 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 | <code>Entity</code>]] 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 | <code>Entity</code>]] 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 | <code>Entity</code>]] 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 | <code>Entity</code>]] 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 <code>File</code> record and <code>objectid</code> would point to the record in the [[WebsiteVisit Table | <code>WebsiteVisit</code>]] table.
+
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 | <code>Entity</code>]] 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 entity begins.
+
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 | <code>Entity</code>]] 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 | <code>Entity</code>]] 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 visit in Truxton.
+
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 visit was tagged.
+
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 file, [https://docs.python.org/3.8/library/constants.html?highlight=false#False False] on failure.
+
[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
<syntaxhighlight lang="Python" highlight="63-70">
+
<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
 
EVENT_TYPE_FBI = 20001
 
  
 
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_event(parent_file, start, end, title, description, type):
 
  event = parent_file.newevent()
 
  event.start = date_to_filetime(datetime.fromisoformat(start))
 
  event.end = date_to_filetime(datetime.fromisoformat(end))
 
  event.title = title
 
  event.description = description
 
  event.type = type
 
  event.save()
 
  return event
 
  
 
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()
   if media.save():
 
    print("Media saved")
 
  else:
 
    print("Media not saved")
 
  
 
   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")
  
   url = child_file.newurl()
+
   artifact = child_file.newartifact()
   url.url = "https://www.judicialwatch.org/documents/jw-v-doj-reply-02743/"
+
   artifact.type = truxton.ENTITY_TYPE_AUTHOR
   url.localfilename = "JW-v-DOJ-reply-02743.pdf"
+
   artifact.value = "Bob Smith"
   url.type = truxton.URL_TYPE_FIREFOX
+
   artifact.datatype = truxton.DATA_TYPE_ASCII
  url.method = truxton.URL_METHOD_TYPE_CLICKED_ON_A_LINK
+
   artifact.length = 9
   url.format = truxton.URL_FORMAT_ASCII
+
   artifact.save()
  url.when = date_to_filetime(datetime.fromisoformat("2020-05-20T00:00:00-05:00"))
 
   url.save()
 
  
   add_event( child_file, "2016-07-31T12:00:00-05:00", "2016-07-31T12:00:00-05:00", "Crossfire Hurricane Created", "At FBI HQ", EVENT_TYPE_FBI )
+
   artifact.addnote('I think this was the filing that mentioned dead squirrels')
  add_event( child_file, "2016-07-27T12:00:00-05:00", "2016-07-27T12:00:00-05:00", "Legat called needing to meet US ambassador", "In London", EVENT_TYPE_FBI )
+
 
   add_event( child_file, "2016-07-29T12:00:00-05:00", "2016-07-29T12:00:00-05:00", "FBI Receives Downer Info from Legat", "Probably legat London", EVENT_TYPE_FBI )
+
   return None
  
 
def main():
 
def main():
 
   t = truxton.create()
 
   t = truxton.create()
 
  create_event_type(t, EVENT_TYPE_FBI, "FBI Actions" )
 
  
 
   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())
</syntaxhighlight>
+
</source>

Latest revision as of 15:06, 27 January 2024

This class lets you add to the [Entity] table in Truxton.

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