Example #1
0
 def _attributes(self):
     attr = VMap()
     if self.pid != None:
       attr["pid"] = Variant(self.pid)
     if self.active_threads:
       attr["threads"] = Variant(self.active_threads)
     if self.inherited_from:
       attr["ppid"] = Variant(self.inherited_from)
     if self.handle_count:
       attr["handle count"] = Variant(self.handle_count)
     if self.connections:
       attr["connection"] = Variant(self.connections)
     if self.create_time:
      at = vtime() 
      at.thisown = False
      d = datetime.fromtimestamp(self.create_time).timetuple()
      at.year = d[0]
      at.month = d[1]
      at.day = d[2]
      at.hour = d[3]
      at.minute = d[4]
      at.second = d[5]
      at.usecond = 0
      attr["creation"] = Variant(at)
     return attr
Example #2
0
  def attributes(self, node):
    attr = VMap()
    vfile = node.open()
    img = Image.open(vfile) 
    info = img._getexif()
    vfile.close()
    for tag, values in info.items():
      if tag in self.dateTimeTags:
       try:
	decoded = str(TAGS.get(tag, tag))
 	try:
	  dt = strptime(values, "%Y:%m:%d %H:%M:%S") 
        except ValueError:
	  try:
	    dt = strptime(values[:-6], "%Y-%m-%dT%H:%M:%S")
	  except ValueError:
	    dt = strptime(values.rstrip(' '),  "%a %b %d %H:%M:%S")
	vt = vtime(dt.tm_year, dt.tm_mon, dt.tm_mday, dt.tm_hour, dt.tm_min, dt.tm_sec, 0)
        vt.thisown = False
	attr[decoded] = Variant(vt) 	
       except Exception as e:
	attr[decoded] = Variant(str(values))
      else:	
        decoded = str(TAGS.get(tag, tag))
        if isinstance(values, tuple):
	  vl = VList()
	  for value in values:
	     vl.push_back(Variant(value))
          attr[decoded] = vl
        else:
          attr[decoded] = Variant(values)
    return attr
Example #3
0
File: nodes.py Project: kzwkt/dff
 def _attributes(self):
     attr = VMap()
     vt = vtime(self.timestamp, TIME_MS_64)
     vt.thisown = False
     vmodified = Variant(vt)
     attr["modified"] = vmodified
     return attr
Example #4
0
def attributesTypes(values, types):
    if types == vtime:
        val = vtime(*values)  #(X, X) vtime take 2 arguments
        val.thisown = False
    elif (types == int) or (types == long):
        if type(values) == str:  #XXX strange ?
            values = 0
        val = types(values)
    elif (types == dict):
        val = VMap()
        for k, v in values.iteritems():
            vval = Variant(attributesTypes(*v))
            val[k] = vval
    elif (types == list):
        val = VList()
        for v in values:
            vval = Variant(attributesTypes(*v))
            val.append(vval)
    elif (types == str):
        if type(values) == unicode:
            val = values.encode("ascii", "replace")
        else:
            val = str(values)
    elif (types == VLink):  #return node is already created
        val = values
    else:
        val = types(values)
    return val
Example #5
0
 def attributes(self, node):
     attr = VMap()
     vfile = node.open()
     img = Image.open(vfile)
     info = img._getexif()
     vfile.close()
     for tag, values in info.items():
         if tag in self.dateTimeTags:
             try:
                 decoded = str(TAGS.get(tag, tag))
                 try:
                     dt = strptime(values, "%Y:%m:%d %H:%M:%S")
                 except ValueError:
                     try:
                         dt = strptime(values[:-6], "%Y-%m-%dT%H:%M:%S")
                     except ValueError:
                         dt = strptime(values.rstrip(' '),
                                       "%a %b %d %H:%M:%S")
                 vt = vtime(dt.tm_year, dt.tm_mon, dt.tm_mday, dt.tm_hour,
                            dt.tm_min, dt.tm_sec, 0)
                 vt.thisown = False
                 attr[decoded] = Variant(vt)
             except Exception as e:
                 attr[decoded] = Variant(str(values))
         else:
             decoded = str(TAGS.get(tag, tag))
             if isinstance(values, tuple):
                 vl = VList()
                 for value in values:
                     vl.push_back(Variant(value))
                 attr[decoded] = vl
             else:
                 attr[decoded] = Variant(values)
     return attr
Example #6
0
 def _attributes(self):
     attr = VMap()
     if self.pid != None:
         attr["pid"] = Variant(self.pid)
     if self.active_threads:
         attr["threads"] = Variant(self.active_threads)
     if self.inherited_from:
         attr["ppid"] = Variant(self.inherited_from)
     if self.handle_count:
         attr["handle count"] = Variant(self.handle_count)
     if self.connections:
         attr["connection"] = Variant(self.connections)
     if self.create_time:
         at = vtime()
         at.thisown = False
         d = datetime.fromtimestamp(self.create_time).timetuple()
         at.year = d[0]
         at.month = d[1]
         at.day = d[2]
         at.hour = d[3]
         at.minute = d[4]
         at.second = d[5]
         at.usecond = 0
         attr["creation"] = Variant(at)
     return attr
Example #7
0
 def __init__(self, vfile):
     data = unpack('Q', vfile.read(8))[0]
     #MS didn't differentiate absolute and relative time (time/datetime)
     #so use ugly trick heare
     if data >= 116444736000000000:  #a date time should be superior than the lep between unix & ms epoch
         vt = vtime(data, TIME_MS_64)
         vt.thisown = False
         Variant.__init__(self, vt)
     else:
         Variant.__init__(self, data)
Example #8
0
 def __init__(self, vfile):
    data = unpack('Q', vfile.read(8))[0]
    #MS didn't differentiate absolute and relative time (time/datetime) 
    #so use ugly trick heare
    if data >= 116444736000000000: #a date time should be superior than the lep between unix & ms epoch
      vt = vtime(data, TIME_MS_64)
      vt.thisown = False
      Variant.__init__(self, vt) 
    else:
      Variant.__init__(self, data)
Example #9
0
 def __init__(self, data, keyname):
     self.count = 0
     self.lastUpdate = "N/A"
     self.id = 0 
     if len(data) <= 16:
         try:
             self.id = unpack("<I", str(data[0:4]))[0]
             self.count = unpack("<I", str(data[4:8]))[0]
             if self.count > 5:
                 self.count -= 5
             else:
                 self.count = 0
             self.lastUpdate = vtime(unpack("<Q", str(data[8:16]))[0], TIME_MS_64).get_time()
         except :
             pass
     elif len(data) == 72:
         try:
             self.count = unpack("<I", str(data[4:8]))[0]
             self.lastUpdate = vtime(unpack("<Q", str(data[60:68]))[0], TIME_MS_64).get_time()
         except :
             pass
Example #10
0
File: unzip.py Project: kzwkt/dff
 def _attributes(self):
   attr = VMap()
   zipattr = self.reader.zipcontent.getinfo(self.zipfile)
   for key in ZipNode.__slots__:
     val = getattr(zipattr, key)
     if key != "date_time":
       attr[key] = Variant(val)
   vt = vtime()
   vt.thisown = False
   vt.year = zipattr.date_time[0]
   vt.month = zipattr.date_time[1]
   vt.day = zipattr.date_time[2]
   vt.hour = zipattr.date_time[3]
   vt.minute = zipattr.date_time[4]
   vt.second = zipattr.date_time[5]
   attr["create"] = Variant(vt) 
   return attr
Example #11
0
 def __init__(self, data):
     self.data = data
     if type(data) == bytearray:
         self.data = str(vtime(unpack('Q', str(data))[0], TIME_MS_64).get_time())
     else:
         self.data = str(vtime(data, TIME_UNIX).get_time())