Difference between revisions of "TruxtonArtifact"

From truxwiki.com
Jump to navigation Jump to search
(Created page with "This class lets you add to the Entity table in Truxton. =Attributes and Methods= ==<code>account</code>== The optional account name associated with the URL...")
 
 
(17 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>account</code>==
+
==<code>datatype: int</code>==
The optional account name associated with the URL.
+
The raw [[DATA_TYPE|data type]] of the representation of the entity.
Many browsers will record the operating system user that did the surfing.
+
This corresponds to the <code>[DataTypeID]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table.
  
==<code>accountoffset</code>==
+
==<code>fileid: str</code>==
The offset into the parent file where the account was found.
+
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 <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table.
  
==<code>fileid</code>==
+
==<code>id: str</code>==
The [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the file this [https://en.wikipedia.org/wiki/URL URL] came from.
+
This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the record.
This corresponds to the <code>FileID</code> column of the <code>WebsiteVisit</code> table.
+
It becomes non-zero after <code>save()</code> has been called.
 +
This corresponds to the <code>[ID]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table.
  
==<code>format</code>==
+
==<code>length: int</code>==
The format of the raw URL.
+
The number of bytes in the raw representation of the artifact.
This can be <code>URL_FORMAT_ASCII</code> (1) or <code>URL_FORMAT_UNICODE</code> (2)
+
This corresponds to the <code>[Length]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table.
  
==<code>id</code>==
+
==<code>mediaid: 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 media this artifact came from.
It becomes non-zero after <code>save()</code> has been called.
+
This corresponds to the <code>[MediaID]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table.
 +
 
 +
==<code>objectid: str</code>==
 +
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.
 +
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>localfilename</code>==
+
==<code>objecttype: int</code>==
The path to the file the browser uses to cache the contents of the page retrieved by the URL.
+
The type of the object.
 +
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>mediaid</code>==
+
==<code>offset: int</code>==
This is the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the media this visit came from.
+
The offset from the beginning of the file where this artifact begins.
This identifier corresponds to the <code>MediaID</code> of the <code>WebsiteVisit</code> table.
 
  
==<code>method</code>==
+
==<code>type: int</code>==
The reason this URL was retrieved.
+
The type of the artifact is.
It corresponds to the <code>WebsiteMethodID</code> column of the <code>WebsiteVisit</code> table.
+
This corresponds to the <code>[EntityTypeID]</code> column of the <code><nowiki>[</nowiki>[[Entity Table|Entity]]<nowiki>]</nowiki></code> table.
The value must match a value in the <code>ID</code> column in the <code>WebsiteMethod</code> table.
+
It must be a value listed in the <code>[ID]</code> column of the <code>[EntityType]</code> table.
You can also use one of the [[URL Methods | predefined constants.]]
+
You can also use a [[Entity Types|predefined constant.]]
  
==<code>offset</code>==
+
==<code>value: str</code>==
The offset in the file where this URL was found.
+
The string representation of the artifact.
It should be the offset of the first character in the URL.
+
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 <code>WebsiteVisit</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.
 
 
==<code>type</code>==
 
The type of URL.
 
It corresponds to the <code>URLTypeID</code> column of the <code>WebsiteVisit</code> table.
 
The value must match a value in the <code>ID</code> column in the <code>URLType</code> table.
 
You can also use one of the [[URL Types | predefined constants.]]
 
 
 
==<code>url</code>==
 
The URL string.
 
This corresponds to the <code>URL</code> column of the <code>URL</code> table.
 
 
 
==<code>when</code>==
 
When the URL was seen in [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] ticks.
 
This corresponds to the <code>When</code> column of the <code>WebsiteVisit</code> table.
 
  
 
=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 76: 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 87: 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 95: 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 118: 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 129: 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()
+
   artifact.addnote('I think this was the filing that mentioned dead squirrels')
  
   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 )
+
   return None
  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 )
 
  
 
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 153: 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())