Skip to content

Commit

Permalink
Merge tag '1.14.3' into develop
Browse files Browse the repository at this point in the history
Closes #352
  • Loading branch information
ninSmith committed Nov 28, 2018
2 parents 93148b8 + 2d5034e commit 3c7787b
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion analyzers/EmlParser/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import magic
import binascii
import hashlib
import base64
from pprint import pprint

class EmlParserAnalyzer(Analyzer):
Expand Down Expand Up @@ -80,7 +81,21 @@ def parseEml(filepath):
result['topic'] = ', '.join(parsed_eml.get('header', '').get('header', '').get('thread-topic', ''))
result['bcc'] = parsed_eml.get('header', '').get('header', '').get('bcc', '')
result['displayto'] = ', '.join(parsed_eml.get('header', '').get('header', '').get('to', ''))
result['body'] = parsed_eml['body'][0]['content']

#for some emails, the body field is empty because the email body is
#identified as an attachment
if parsed_eml['body']:
#normal case
result['body'] = parsed_eml['body'][0]['content']
else:
#email body is in attachment
#from what I've seen, there are 2 attachments
#one with the email body as text
#and one with the email body as text but wrapped in html
#let's arbitrary take the one wrapped in html as body
for attachment in parsed_eml['attachment']:
if 'HTML text' in attachment['content_header']['content-description']:
result['body'] = base64.b64decode(attachment['raw']).decode('utf-8')

#attachments
try:
Expand Down

0 comments on commit 3c7787b

Please sign in to comment.