Difference between revisions of "TruxtonObject"
| Line 2: | Line 2: | ||
=Attributes and Methods= | =Attributes and Methods= | ||
| − | ==<code>adddatabaseid(file_type_id, table_and_column)</code>== | + | ==<code>adddatabaseid(file_type_id: int, table_and_column: str)</code>== |
Creates a record in the <code>[DatabaseTableName]</code> table to help [[Identifying Databases|identify a database file]]. | Creates a record in the <code>[DatabaseTableName]</code> table to help [[Identifying Databases|identify a database file]]. | ||
| − | ==<code>cleandatabase()</code>== | + | ==<code>cleandatabase() -> bool</code>== |
| − | This | + | This send a [[Message Bus Messages#Clean Database|message]] to the maintenance ETL to go through the tables looking for unreferenced (orphaned) records and delete them. |
| + | It will return [https://docs.python.org/3/library/constants.html#True True] if the message was sent, [https://docs.python.org/3/library/constants.html#False False] otherwise. | ||
| − | ==<code>closed</code>== | + | ==<code>closed: bool</code>== |
| − | It will be [https://docs.python.org/3/library/constants.html#True True] if | + | It will be [https://docs.python.org/3/library/constants.html#True True] if the connection to Truxton is closed, [https://docs.python.org/3/library/constants.html#False False] otherwise. |
| − | ==<code>connnectionstring</code>== | + | ==<code>connnectionstring: str</code>== |
This will return the database connection string. | This will return the database connection string. | ||
Use this if you want to query the database directly. | Use this if you want to query the database directly. | ||
| − | ==<code>consolidatedepots()</code>== | + | ==<code>consolidatedepots() -> bool</code>== |
| − | This | + | This send a [[Message Bus Messages#Consolidate Depots|message]] to the maintenance ETL to go through closed depots and merge the smaller ones into the larger ones. What you will be left with is few very large depot files instead of many smaller ones. |
| + | It will return [https://docs.python.org/3/library/constants.html#True True] if the message was sent, [https://docs.python.org/3/library/constants.html#False False] otherwise. | ||
| − | ==<code>createeverythinghashset(output_filename)</code>== | + | ==<code>createeverythinghashset(output_filename: str)</code>== |
Creates a [[Hash Set|hash set]] file from the unique hashes in Truxton. | Creates a [[Hash Set|hash set]] file from the unique hashes in Truxton. | ||
| − | ==<code>createinvestigationhashset(investigation_id, output_filename)</code>== | + | ==<code>createinvestigationhashset(investigation_id: str, output_filename: str)</code>== |
Creates a [[Hash Set|hash set]] file from the unique hashes in the given investigation. | Creates a [[Hash Set|hash set]] file from the unique hashes in the given investigation. | ||
| − | ==<code>createmediahashset(media_id, output_filename)</code>== | + | ==<code>createmediahashset(media_id: str, output_filename: str)</code>== |
Creates a [[Hash Set|hash set]] file from the unique hashes in the given media. | Creates a [[Hash Set|hash set]] file from the unique hashes in the given media. | ||
| − | ==<code>createtag(name, description)</code>== | + | ==<code>createtag(name: str, description: str)</code>== |
This will create a new tag in Truxton. | This will create a new tag in Truxton. | ||
After calling this method, you can tag other items using only the <code>name</code>. | After calling this method, you can tag other items using only the <code>name</code>. | ||
| − | ==<code>deletedepots()</code>== | + | ==<code>deletedepots() -> bool</code>== |
This delete the depot files that have been marked as <code>ToBeDeleted</code>. | This delete the depot files that have been marked as <code>ToBeDeleted</code>. | ||
| − | ==<code>deletemedia(media_id)</code>== | + | ==<code>deletemedia(media_id: str) -> bool</code>== |
This will delete a piece of media from Truxton. | This will delete a piece of media from Truxton. | ||
| + | It will return [https://docs.python.org/3/library/constants.html#True True] on success, [https://docs.python.org/3/library/constants.html#False False] on failure. | ||
| − | ==<code>etlid</code>== | + | ==<code>etlid: str</code>== |
Returns the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the ETL if it is running. | Returns the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the ETL if it is running. | ||
| − | ==<code>fileexists(file_id)</code>== | + | ==<code>fileexists(file_id: str) -> bool</code>== |
This looks in the <code><nowiki>[</nowiki>[[File Table|File]]<nowiki>]</nowiki></code> for a record with the given <code>file_id</code>. | This looks in the <code><nowiki>[</nowiki>[[File Table|File]]<nowiki>]</nowiki></code> for a record with the given <code>file_id</code>. | ||
If a record is found with that globally unique identifier, [https://docs.python.org/3/library/constants.html#True True] is returned. | If a record is found with that globally unique identifier, [https://docs.python.org/3/library/constants.html#True True] is returned. | ||
| − | ==<code>getfilehash(hash)</code>== | + | ==<code>getfilehash(hash: str) -> [[TruxtonFileIO]]</code>== |
This will retrieve a [[TruxtonFileIO|file]] from Truxton based on its [https://en.wikipedia.org/wiki/MD5 MD5] hash. | This will retrieve a [[TruxtonFileIO|file]] from Truxton based on its [https://en.wikipedia.org/wiki/MD5 MD5] hash. | ||
| − | ==<code>getfileid(file_id)</code>== | + | ==<code>getfileid(file_id: str) -> [[TruxtonFileIO]]</code>== |
This will retrieve a [[TruxtonFileIO|file]] from Truxton based on its [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID.] | This will retrieve a [[TruxtonFileIO|file]] from Truxton based on its [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID.] | ||
| − | ==<code>getmediaid(media_id)</code>== | + | ==<code>getmediaid(media_id: str) -> [[TruxtonMedia]]</code>== |
This will retrieve a [[TruxtonMedia|media]] from Truxton based on its [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID.] | This will retrieve a [[TruxtonMedia|media]] from Truxton based on its [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID.] | ||
| − | ==<code>getsensitivesitelistid(list_id)</code>== | + | ==<code>getsensitivesitelistid(list_id: str) -> [[TruxtonSensitiveSiteList]]</code>== |
This will retrieve a [[TruxtonSensitiveSiteList|sensitive site list]] from Truxton based on its [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID.] | This will retrieve a [[TruxtonSensitiveSiteList|sensitive site list]] from Truxton based on its [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID.] | ||
| − | ==<code>machineid</code>== | + | ==<code>machineid: str</code>== |
Returns the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the machine. | Returns the [https://en.wikipedia.org/wiki/Universally_unique_identifier GUID] of the machine. | ||
When Truxton is installed, this identifier is generated with the most significant 64-bits being a Windows [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] and the lower 64-bits being random. | When Truxton is installed, this identifier is generated with the most significant 64-bits being a Windows [https://docs.microsoft.com/en-us/windows/win32/api/minwinbase/ns-minwinbase-filetime FILETIME] and the lower 64-bits being random. | ||
| − | ==<code>newartifact()</code>== | + | ==<code>newartifact() -> [[TruxtonArtifact]]</code>== |
This will create an [[TruxtonArtifact|artifact]] object. | This will create an [[TruxtonArtifact|artifact]] object. | ||
| − | ==<code>newartifacttype()</code>== | + | ==<code>newartifacttype() -> [[TruxtonArtifactType]]</code>== |
This will create an [[TruxtonArtifactType|artifact type]] object. | This will create an [[TruxtonArtifactType|artifact type]] object. | ||
| − | ==<code>newbolo()</code>== | + | ==<code>newbolo() -> [[TruxtonBolo]]</code>== |
This will create a [[TruxtonBolo|BOLO]] object. | This will create a [[TruxtonBolo|BOLO]] object. | ||
| − | ==<code>neweventtype()</code>== | + | ==<code>neweventtype() -> [[TruxtonEventType]]</code>== |
This will create an [[TruxtonEventType|event type]] object. | This will create an [[TruxtonEventType|event type]] object. | ||
| − | ==<code>newexporter()</code>== | + | ==<code>newexporter() -> [[TruxtonExporter]]</code>== |
This will create an [[TruxtonExporter|exporter]] object. | This will create an [[TruxtonExporter|exporter]] object. | ||
| − | ==<code>newfiletype()</code>== | + | ==<code>newfiletype() -> [[TruxtonFileType]]</code>== |
This will create an [[TruxtonFileType|file type]] object. | This will create an [[TruxtonFileType|file type]] object. | ||
| − | ==<code>newinvestigation()</code>== | + | ==<code>newinvestigation() -> [[TruxtonInvestigation]]</code>== |
This will create an [[TruxtonInvestigation|investigation]] object. | This will create an [[TruxtonInvestigation|investigation]] object. | ||
| − | ==<code>newjurisdiction()</code>== | + | ==<code>newjurisdiction() -> [[TruxtonJurisdiction]]</code>== |
This will create a [[TruxtonJurisdiction|jurisdiction]] object. | This will create a [[TruxtonJurisdiction|jurisdiction]] object. | ||
| − | ==<code>newmedia()</code>== | + | ==<code>newmedia() -> [[TruxtonMedia]]</code>== |
This will create a [[TruxtonMedia|media]] object. | This will create a [[TruxtonMedia|media]] object. | ||
| Line 90: | Line 93: | ||
This will create a [[TruxtonMessageAddress|message address]] object. | This will create a [[TruxtonMessageAddress|message address]] object. | ||
| − | ==<code>newrelation()</code>== | + | ==<code>newrelation() -> [[TruxtonRelation]]</code>== |
This will create a [[TruxtonRelation|relation]] object. | This will create a [[TruxtonRelation|relation]] object. | ||
| − | ==<code>newsensitivesitelist()</code>== | + | ==<code>newsensitivesitelist() -> [[TruxtonSensitiveSiteList]]</code>== |
This will create a [[TruxtonSensitiveSiteList|sensitive site list]] object. | This will create a [[TruxtonSensitiveSiteList|sensitive site list]] object. | ||
| − | ==<code>newsubject()</code>== | + | ==<code>newsubject() -> [[TruxtonSubject]]</code>== |
This will create a [[TruxtonSubject|subject]] object. | This will create a [[TruxtonSubject|subject]] object. | ||
| − | ==<code>optimizedatabase()</code>== | + | ==<code>optimizedatabase() -> bool</code>== |
This update the query statistics in the database. | This update the query statistics in the database. | ||
| − | ==<code>reindexmedia(media_id)</code>== | + | ==<code>reindexmedia(media_id: str) -> bool</code>== |
This will send all of the files in a piece of media to the indexer. | This will send all of the files in a piece of media to the indexer. | ||
| − | ==<code>removedatabaseid(file_type_id, table_and_column)</code>== | + | ==<code>removedatabaseid(file_type_id: int, table_and_column: str) -> bool</code>== |
Removes a record in the <code>[DatabaseTableName]</code> table used to [[Identifying Databases|identify a database file]]. | Removes a record in the <code>[DatabaseTableName]</code> table used to [[Identifying Databases|identify a database file]]. | ||
| − | ==<code>taghash(hash, tag, description)</code>== | + | ==<code>taghash(hash: str, tag: str, description: str) -> bool</code>== |
This will add a tag to all files that have contents matching the given hash. | This will add a tag to all files that have contents matching the given hash. | ||
| − | ==<code>updateinvestigationtype(investigation_id, type)</code>== | + | ==<code>updateinvestigationtype(investigation_id: str, type: int) -> bool</code>== |
This will add a tag to all files that have contents matching the given hash. | This will add a tag to all files that have contents matching the given hash. | ||
| − | ==<code>updatemediatype(media_id, type)</code>== | + | ==<code>updatemediatype(media_id: str, type: int) -></code>== |
| − | This | + | Sets the [[Media Types|type]] of the media. |
| + | This update the <code>[MediaTypeID]</code> column of the <code>[Media]</code> table. | ||
| + | It can be one of the [[Media Types|defined constants]] but it must be one of the values in the <code>[ID]</code> column of the <code>[MediaType]</code> table. | ||
| − | ==<code>updatemediaphotohash(media_id, hash)</code>== | + | ==<code>updatemediaphotohash(media_id: str, hash: str) -> bool</code>== |
| − | + | Associates the photo with the given MD5 hash with the Media. | |
| − | ==<code>version</code>== | + | ==<code>version: str</code>== |
Returns the version string. | Returns the version string. | ||
Revision as of 16:12, 27 July 2022
This class gives you access to Truxton at a global level.
Contents
- 1 Attributes and Methods
- 1.1 adddatabaseid(file_type_id: int, table_and_column: str)
- 1.2 cleandatabase() -> bool
- 1.3 closed: bool
- 1.4 connnectionstring: str
- 1.5 consolidatedepots() -> bool
- 1.6 createeverythinghashset(output_filename: str)
- 1.7 createinvestigationhashset(investigation_id: str, output_filename: str)
- 1.8 createmediahashset(media_id: str, output_filename: str)
- 1.9 createtag(name: str, description: str)
- 1.10 deletedepots() -> bool
- 1.11 deletemedia(media_id: str) -> bool
- 1.12 etlid: str
- 1.13 fileexists(file_id: str) -> bool
- 1.14 getfilehash(hash: str) -> TruxtonFileIO
- 1.15 getfileid(file_id: str) -> TruxtonFileIO
- 1.16 getmediaid(media_id: str) -> TruxtonMedia
- 1.17 getsensitivesitelistid(list_id: str) -> TruxtonSensitiveSiteList
- 1.18 machineid: str
- 1.19 newartifact() -> TruxtonArtifact
- 1.20 newartifacttype() -> TruxtonArtifactType
- 1.21 newbolo() -> TruxtonBolo
- 1.22 neweventtype() -> TruxtonEventType
- 1.23 newexporter() -> TruxtonExporter
- 1.24 newfiletype() -> TruxtonFileType
- 1.25 newinvestigation() -> TruxtonInvestigation
- 1.26 newjurisdiction() -> TruxtonJurisdiction
- 1.27 newmedia() -> TruxtonMedia
- 1.28 newmessageaddress()
- 1.29 newrelation() -> TruxtonRelation
- 1.30 newsensitivesitelist() -> TruxtonSensitiveSiteList
- 1.31 newsubject() -> TruxtonSubject
- 1.32 optimizedatabase() -> bool
- 1.33 reindexmedia(media_id: str) -> bool
- 1.34 removedatabaseid(file_type_id: int, table_and_column: str) -> bool
- 1.35 taghash(hash: str, tag: str, description: str) -> bool
- 1.36 updateinvestigationtype(investigation_id: str, type: int) -> bool
- 1.37 updatemediatype(media_id: str, type: int) ->
- 1.38 updatemediaphotohash(media_id: str, hash: str) -> bool
- 1.39 version: str
- 2 Sample
Attributes and Methods
adddatabaseid(file_type_id: int, table_and_column: str)
Creates a record in the [DatabaseTableName] table to help identify a database file.
cleandatabase() -> bool
This send a message to the maintenance ETL to go through the tables looking for unreferenced (orphaned) records and delete them. It will return True if the message was sent, False otherwise.
closed: bool
It will be True if the connection to Truxton is closed, False otherwise.
connnectionstring: str
This will return the database connection string. Use this if you want to query the database directly.
consolidatedepots() -> bool
This send a message to the maintenance ETL to go through closed depots and merge the smaller ones into the larger ones. What you will be left with is few very large depot files instead of many smaller ones. It will return True if the message was sent, False otherwise.
createeverythinghashset(output_filename: str)
Creates a hash set file from the unique hashes in Truxton.
createinvestigationhashset(investigation_id: str, output_filename: str)
Creates a hash set file from the unique hashes in the given investigation.
createmediahashset(media_id: str, output_filename: str)
Creates a hash set file from the unique hashes in the given media.
createtag(name: str, description: str)
This will create a new tag in Truxton.
After calling this method, you can tag other items using only the name.
deletedepots() -> bool
This delete the depot files that have been marked as ToBeDeleted.
deletemedia(media_id: str) -> bool
This will delete a piece of media from Truxton. It will return True on success, False on failure.
etlid: str
Returns the GUID of the ETL if it is running.
fileexists(file_id: str) -> bool
This looks in the [File] for a record with the given file_id.
If a record is found with that globally unique identifier, True is returned.
getfilehash(hash: str) -> TruxtonFileIO
This will retrieve a file from Truxton based on its MD5 hash.
getfileid(file_id: str) -> TruxtonFileIO
This will retrieve a file from Truxton based on its GUID.
getmediaid(media_id: str) -> TruxtonMedia
This will retrieve a media from Truxton based on its GUID.
getsensitivesitelistid(list_id: str) -> TruxtonSensitiveSiteList
This will retrieve a sensitive site list from Truxton based on its GUID.
machineid: str
Returns the GUID of the machine. When Truxton is installed, this identifier is generated with the most significant 64-bits being a Windows FILETIME and the lower 64-bits being random.
newartifact() -> TruxtonArtifact
This will create an artifact object.
newartifacttype() -> TruxtonArtifactType
This will create an artifact type object.
newbolo() -> TruxtonBolo
This will create a BOLO object.
neweventtype() -> TruxtonEventType
This will create an event type object.
newexporter() -> TruxtonExporter
This will create an exporter object.
newfiletype() -> TruxtonFileType
This will create an file type object.
newinvestigation() -> TruxtonInvestigation
This will create an investigation object.
newjurisdiction() -> TruxtonJurisdiction
This will create a jurisdiction object.
newmedia() -> TruxtonMedia
This will create a media object.
newmessageaddress()
This will create a message address object.
newrelation() -> TruxtonRelation
This will create a relation object.
newsensitivesitelist() -> TruxtonSensitiveSiteList
This will create a sensitive site list object.
newsubject() -> TruxtonSubject
This will create a subject object.
optimizedatabase() -> bool
This update the query statistics in the database.
reindexmedia(media_id: str) -> bool
This will send all of the files in a piece of media to the indexer.
removedatabaseid(file_type_id: int, table_and_column: str) -> bool
Removes a record in the [DatabaseTableName] table used to identify a database file.
taghash(hash: str, tag: str, description: str) -> bool
This will add a tag to all files that have contents matching the given hash.
updateinvestigationtype(investigation_id: str, type: int) -> bool
This will add a tag to all files that have contents matching the given hash.
updatemediatype(media_id: str, type: int) ->
Sets the type of the media.
This update the [MediaTypeID] column of the [Media] table.
It can be one of the defined constants but it must be one of the values in the [ID] column of the [MediaType] table.
updatemediaphotohash(media_id: str, hash: str) -> bool
Associates the photo with the given MD5 hash with the Media.
version: str
Returns the version string.
Sample
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()
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")
a = child_file.newartifact()
a.type = truxton.ENTITY_TYPE_ACCOUNT
a.value = "r0cker"
a.datatype = truxton.DATA_TYPE_ASCII
a.length = 6
a.save()
b = child_file.newartifact()
b.type = truxton.ENTITY_TYPE_PERSON
b.value = "Bob Smith"
b.datatype = truxton.DATA_TYPE_ASCII
b.length = 9
b.save()
relation = child_file.newrelation()
relation.a = a.id
relation.atype = truxton.OBJECT_TYPE_ENTITY
relation.b = b.id
relation.btype = truxton.OBJECT_TYPE_ENTITY
relation.relation = truxton.RELATION_LOGON_ACCOUNT
relation.save()
def main():
t = truxton.create()
print(t.version + '\n' );
print("Truxton will write to depot files in: " + t.getstring("datadir") + '\n');
print("The database port is: " + str(t.getint("dbport")) + '\n');
print("Database was created: " + str(t.getbool("CreateTheDatabase")) + '\n');
media = add_media(t)
root_file = media.addroot()
root_file.save()
add_ec(root_file)
if __name__ == "__main__":
main()