Difference between revisions of "TruxtonChildFileIO newrelation"
Jump to navigation
Jump to search
(Created page with "This create new relationship sourced from a file in Truxton. It automatically associates the parent file and media identifiers used in the Relation table....") |
(→Sample) |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
This create new relationship sourced from a file in Truxton. | This create new relationship sourced from a file in Truxton. | ||
| − | It automatically associates the parent file and media identifiers used in the [[Relation Table | Relation table. | + | It automatically associates the parent file and media identifiers used in the <code><nowiki>[</nowiki>[[Relation Table|Relation]]<nowiki>]</nowiki></code> table. |
=Syntax= | =Syntax= | ||
| − | < | + | <source lang="Python"> |
object newrelation(); | object newrelation(); | ||
| − | </ | + | </source> |
=Return value= | =Return value= | ||
| − | A Relation object | + | A [[TruxtonRelation|Relation]] object |
=Sample= | =Sample= | ||
| − | + | <source lang="Python" highlight="46"> | |
| − | < | ||
import truxton | import truxton | ||
import shutil | import shutil | ||
| Line 70: | Line 69: | ||
if __name__ == "__main__": | if __name__ == "__main__": | ||
| − | main() | + | sys.exit(main()) |
| − | </ | + | </source> |
Latest revision as of 10:08, 3 February 2024
This create new relationship sourced from a file in Truxton.
It automatically associates the parent file and media identifiers used in the [Relation] table.
Syntax
object newrelation();
Return value
A Relation object
Sample
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 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:/Events/Relations.txt")
imsi = child.newartifact()
imsi.type = truxton.ENTITY_TYPE_IMSI
imsi.value = "310120265624299"
imsi.datatype = truxton.DATA_TYPE_ASCII
imsi.length = 15
imsi.offset = 1
imsi.save()
mac = child.newartifact()
mac.type = truxton.ENTITY_TYPE_MAC_ADDRESS
mac.value = "001422012345"
mac.datatype = truxton.DATA_TYPE_ASCII
mac.length = 12
mac.offset = 111
mac.save()
relationship = child.newrelation()
relationship.a = imsi.id
relationship.b = mac.id
relationship.typea = truxton.OBJECT_TYPE_ENTITY
relationship.typeb = truxton.OBJECT_TYPE_ENTITY
relationship.relation = truxton.RELATION_RELATED
if relationship.save() is True:
print( "New relationship established" )
if __name__ == "__main__":
sys.exit(main())