Beispiel #1
0
 def add_attr(self, attribute):
     logger.debug("Attachment attr name: 0x%4.4x" % attribute.name)
     if attribute.name == TNEF.ATTATTACHMODIFYDATE:
         logger.debug("No date support yet!")
     elif attribute.name == TNEF.ATTATTACHMENT:
         self.mapi_attrs += decode_mapi(attribute.data)
     elif attribute.name == TNEF.ATTATTACHTITLE:
         self.name = attribute.data.strip(chr(0))  # remove any NULLs
     elif attribute.name == TNEF.ATTATTACHDATA:
         self.data = attribute.data
     else:
         logger.debug("Unknown attribute name: %s" % attribute)
Beispiel #2
0
 def add_attr(self, attribute):
    logger.debug("Attachment attr name: 0x%4.4x" % attribute.name)
    if attribute.name == TNEF.ATTATTACHMODIFYDATE:
       logger.debug("No date support yet!")
    elif attribute.name == TNEF.ATTATTACHMENT:
       self.mapi_attrs += decode_mapi(attribute.data)
    elif attribute.name == TNEF.ATTATTACHTITLE:
       self.name = attribute.data.strip(chr(0))  # remove any NULLs
    elif attribute.name == TNEF.ATTATTACHDATA:
       self.data = attribute.data
    else:
       logger.debug("Unknown attribute name: %s" % attribute)
Beispiel #3
0
 def add_attr(self, attribute):
     logger.debug("Attachment attr name: 0x%4.4x" % attribute.name)
     if attribute.name == TNEF.ATTATTACHMODIFYDATE:
         logger.debug("No date support yet!")
     elif attribute.name == TNEF.ATTATTACHMENT:
         attrs = decode_mapi(attribute.data)
         attr_names = [attr.name for attr in attrs]
         self.mapi_attrs.update(zip(attr_names, attrs))
     elif attribute.name == TNEF.ATTATTACHTITLE:
         self.name = attribute.data
     elif attribute.name == TNEF.ATTATTACHDATA:
         self.data = attribute.data
     else:
         logger.debug("Unknown attribute name: %s" % attribute)
Beispiel #4
0
 def add_attr(self, attribute):
    logger.debug("Attachment attr name: 0x%4.4x" % attribute.name)
    if attribute.name == TNEF.ATTATTACHMODIFYDATE:
       logger.debug("No date support yet!")
    elif attribute.name == TNEF.ATTATTACHMENT:
       attrs = decode_mapi(attribute.data)
       attr_names = [attr.name for attr in attrs]
       self.mapi_attrs.update(zip(attr_names, attrs))
    elif attribute.name == TNEF.ATTATTACHTITLE:
       self.name = attribute.data
    elif attribute.name == TNEF.ATTATTACHDATA:
       self.data = attribute.data
    else:
       logger.debug("Unknown attribute name: %s" % attribute)
Beispiel #5
0
    def __init__(self, data, do_checksum=True):
        self.signature = bytes_to_int(data[0:4])
        if self.signature != TNEF.TNEF_SIGNATURE:
            sys.exit("Wrong TNEF signature: 0x%2.8x" % self.signature)
        self.key = bytes_to_int(data[4:6])
        self.objects = []
        self.attachments = []
        self.mapi_attrs = {}
        offset = 6

        if not do_checksum:
            logger.info("Skipping checksum for performance")

        while (offset < len(data)):
            obj = TNEFObject(data[offset:offset + len(data)], do_checksum)
            offset += obj.length
            self.objects.append(obj)

            # handle attachments
            if obj.name == TNEF.ATTATTACHRENDDATA:
                attachment = TNEFAttachment()
                self.attachments.append(attachment)
            elif obj.level == TNEF.LVL_ATTACHMENT:
                attachment.add_attr(obj)

            # handle MAPI properties
            elif obj.name == TNEF.ATTMAPIPROPS:
                attrs = decode_mapi(obj.data)
                attr_names = [attr.name for attr in attrs]
                self.mapi_attrs.update(zip(attr_names, attrs))

                # handle BODY property
                if TNEFMAPI_Attribute.MAPI_BODY in self.mapi_attrs:
                    p = self.mapi_attrs[TNEFMAPI_Attribute.MAPI_BODY]
                    self.body = p.data
                else:
                    self.body = None

                # handle BODY_HTML property
                if TNEFMAPI_Attribute.MAPI_BODY_HTML in self.mapi_attrs:
                    p = self.mapi_attrs[TNEFMAPI_Attribute.MAPI_BODY_HTML]
                    self.htmlbody = p.data
                else:
                    self.htmlbody = None
            else:
                logger.warn("Unknown TNEF Object: %s" % obj)
Beispiel #6
0
   def __init__(self, data, do_checksum = True):
      self.signature = bytes_to_int(data[0:4])
      if self.signature != TNEF.TNEF_SIGNATURE:
         sys.exit("Wrong TNEF signature: 0x%2.8x" % self.signature)
      self.key = bytes_to_int(data[4:6])
      self.objects = []
      self.attachments = []
      self.mapi_attrs = {}
      offset = 6

      if not do_checksum:
         logger.info("Skipping checksum for performance")

      while (offset < len(data)):
         obj = TNEFObject(data[offset: offset+len(data)], do_checksum)
         offset += obj.length
         self.objects.append(obj)

         # handle attachments
         if obj.name == TNEF.ATTATTACHRENDDATA:
            attachment = TNEFAttachment()
            self.attachments.append(attachment)
         elif obj.level == TNEF.LVL_ATTACHMENT:
            attachment.add_attr(obj)

         # handle MAPI properties
         elif obj.name == TNEF.ATTMAPIPROPS:
            attrs = decode_mapi(obj.data)
            attr_names = [attr.name for attr in attrs]
            self.mapi_attrs.update(zip(attr_names, attrs))

            # handle BODY property
            if TNEFMAPI_Attribute.MAPI_BODY in self.mapi_attrs:
               p = self.mapi_attrs[TNEFMAPI_Attribute.MAPI_BODY]
               self.body = p.data
            else:
               self.body = None

            # handle BODY_HTML property
            if TNEFMAPI_Attribute.MAPI_BODY_HTML in self.mapi_attrs:
               p = self.mapi_attrs[TNEFMAPI_Attribute.MAPI_BODY_HTML]
               self.htmlbody = p.data
            else:
               self.htmlbody = None
         else:
            logger.warn("Unknown TNEF Object: %s" % obj)
Beispiel #7
0
   def __init__(self, data, do_checksum = True):
      self.signature = bytes_to_int(data[0:4])
      if self.signature != TNEF.TNEF_SIGNATURE:
         raise Exception('Wrong TNEF signature: 0x%2.8x' % self.signature)
      self.key = bytes_to_int(data[4:6])
      self.objects = []
      self.attachments = []
      self.mapiprops = []
      offset = 6

      if not do_checksum:
         logger.info("Skipping checksum for performance")

      while (offset < len(data)):
         obj = TNEFObject(data[offset: offset+len(data)], do_checksum)
         offset += obj.length
         self.objects.append(obj)

         # handle attachments
         if obj.name == TNEF.ATTATTACHRENDDATA:
            attachment = TNEFAttachment()
            self.attachments.append(attachment)
         elif obj.level == TNEF.LVL_ATTACHMENT:
            attachment.add_attr(obj)

         # handle MAPI properties
         elif obj.name == TNEF.ATTMAPIPROPS:
            self.mapiprops = decode_mapi(obj.data)

            # handle BODY property
            for p in self.mapiprops:
               if p.name == TNEFMAPI_Attribute.MAPI_BODY:
                  self.body = p.data
               elif p.name == TNEFMAPI_Attribute.MAPI_BODY_HTML:
                  self.htmlbody = p.data
         elif obj.name == TNEF.ATTSUBJECT:
		    self.subject = obj.data	 
         elif obj.name == TNEF.ATTDATESENT:
            self.date_sent = obj.data
         elif obj.name == TNEF.ATTMESSAGEID:
            self.messageid = obj.data
         else:
            logger.warn("Unknown TNEF Object: %s" % obj)
Beispiel #8
0
    def __init__(self, data, do_checksum=True):
        self.signature = bytes_to_int(data[0:4])
        if self.signature != TNEF.TNEF_SIGNATURE:
            raise TNEFSignatureError(
                "Wrong TNEF signature: 0x%2.8x" % self.signature,
                self.signature)
        self.key = bytes_to_int(data[4:6])
        self.objects = []
        self.attachments = []
        self.mapiprops = []
        offset = 6

        if not do_checksum:
            logger.info("Skipping checksum for performance")

        while (offset < len(data)):
            obj = TNEFObject(data[offset:offset + len(data)], do_checksum)
            offset += obj.length
            self.objects.append(obj)

            # handle attachments
            if obj.name == TNEF.ATTATTACHRENDDATA:
                attachment = TNEFAttachment()
                self.attachments.append(attachment)
            elif obj.level == TNEF.LVL_ATTACHMENT:
                attachment.add_attr(obj)

            # handle MAPI properties
            elif obj.name == TNEF.ATTMAPIPROPS:
                self.mapiprops = decode_mapi(obj.data)

                # handle BODY property
                for p in self.mapiprops:
                    if p.name == TNEFMAPI_Attribute.MAPI_BODY:
                        self.body = p.data
                    elif p.name == TNEFMAPI_Attribute.MAPI_BODY_HTML:
                        self.htmlbody = p.data
            else:
                logger.warn("Unknown TNEF Object: %s" % obj)