Difference between revisions of "TruxtonFileIO newrelation"

From truxwiki.com
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 17: Line 17:
 
def main():
 
def main():
 
   t = truxton.create()
 
   t = truxton.create()
   file = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")
+
   file_in_truxton = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")
  
   imsi = file.newartifact()
+
   imsi = file_in_truxton .newartifact()
  
 
   imsi.type = truxton.ENTITY_TYPE_IMSI
 
   imsi.type = truxton.ENTITY_TYPE_IMSI
Line 28: Line 28:
 
   imsi.save()
 
   imsi.save()
  
   mac = file.newartifact()
+
   mac = file_in_truxton .newartifact()
  
 
   mac.type = truxton.ENTITY_TYPE_MAC_ADDRESS
 
   mac.type = truxton.ENTITY_TYPE_MAC_ADDRESS
Line 37: Line 37:
 
   mac.save()
 
   mac.save()
  
   relationship = file.newrelation()
+
   relationship = file_in_truxton .newrelation()
  
 
   relationship.a = imsi.id
 
   relationship.a = imsi.id
Line 51: Line 51:
  
 
if __name__ == "__main__":
 
if __name__ == "__main__":
   main()
+
   sys.exit(main())
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 10:04, 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

def main():
  t = truxton.create()
  file_in_truxton = t.getfileid("5ec2a123-74d6-5da7-0653-4e6800000000")

  imsi = file_in_truxton .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 = file_in_truxton .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 = file_in_truxton .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" )

  return None

if __name__ == "__main__":
  sys.exit(main())