Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EmlParser - Fixed headers and displayTo #486

Merged
merged 4 commits into from
Jun 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions analyzers/EmlParser/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def parseEml(filepath):
result['sender'] = str()
result['topic'] = str()
result['bcc'] = str()
result['displayto'] = str()
result['displayTo'] = str()
result['headers'] = str()
result['body'] = str()
result['attachments'] = list()
Expand All @@ -65,9 +65,10 @@ def parseEml(filepath):

#parsing the headers with the email library
#cause eml_parser does not provide raw headers (as far as I know)
#splited string because it was returning the body inside 'Content-Type'
hParser = email.parser.HeaderParser()
h = hParser.parsestr(raw_eml)
result['headers'] = dict(h)
h = str(hParser.parsestr(raw_eml))
result['headers'] = h[:h.index('Content-Type:')]

parsed_eml = eml_parser.eml_parser.decode_email(filepath, include_raw_body=True, include_attachment_data=True)
#parsed_eml['header'].keys() gives:
Expand All @@ -80,7 +81,7 @@ def parseEml(filepath):
result['sender'] = ', '.join(parsed_eml.get('header', '').get('header', '').get('x-env-sender', ''))
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['displayTo'] = ', '.join(parsed_eml.get('header', '').get('header', '').get('to', ''))

#for some emails, the body field is empty because the email body is
#identified as an attachment
Expand Down
175 changes: 82 additions & 93 deletions thehive-templates/EmlParser_1_1/long.html
Original file line number Diff line number Diff line change
@@ -1,96 +1,85 @@
<div class="panel panel-danger" ng-if="!success">
<div class="panel-heading">
<strong>{{(artifact.data || artifact.attachment.name) | fang}}</strong>
</div>
<div class="panel-body">
{{content.errorMessage}}
</div>
<div class="panel-heading">
<strong>{{(artifact.data || artifact.attachment.name) | fang}}</strong>
</div>


<div class="panel panel-info" ng-if="success">
<div class="panel-heading">
Email message details
</div>
<div class="panel-body">
<div ng-show="content.traits.is_anonymous_proxy" class="alert alert-warning">Is anonymous proxy</div>
<div ng-show="content.traits.is_satellite_provider" class="alert alert-warning">Is satellite provider</div>

<dl class="dl-horizontal">
<dt>From</dt>
<dd>{{content.displayFrom}} ({{content.sender}})</dd>
</dl>
<dl class="dl-horizontal">
<dt>To</dt>
<dd>{{content.displayTo}} ({{content.receivers}})</dd>
</dl>
<dl class="dl-horizontal">
<dt>Subject</dt>
<dd>{{content.subject || '-'}}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Topic</dt>
<dd>{{content.topic || '-'}}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Bcc</dt>
<dd>{{content.bcc || '-'}}</dd>
</dl>
<dl class="dl-horizontal" ng-if="content.attachments && content.attachments.length !== 0">
<dt>Attachments</dt>
<dd>
<div class="bm10">This message file includes
<ng-pluralize count="content.attachments.length" when="{'1': '1 attachment', 'other': '{} attachments'}"></ng-pluralize>
</div>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th class="col-md-2" >Filename</th>
<th >File information</th>

</tr>
</thead>
<tbody ng-repeat="a in content.attachments">
<tr>
<td rowspan=4>{{a.filename}}</td>
<td>[MD5]: {{a.md5}}</td>
</tr>
<tr>
<td>[SHA1]: {{a.sha1}}</td>
</tr>
<tr>
<td>[SHA256]: {{a.sha256}}</td>
</tr>
<tr>
<td>
{{a.mime}}
</td>
</tr>
</tbody>
</table>
</dd>
</dl>
<dl class="dl-horizontal">
<dt>Headers</dt>
<dd>
<table class="table table-striped table-bordered">
<tr>
<th class="col-md-2">Header</th>
<th>Content</th>
</tr>
<tr ng-repeat="(k, v) in content.headers">
<td>{{k}}</td>
<td>{{v}}</td>
</tr>
</table>
</dd>
</dl>
<dl class="dl-horizontal">
<dt>Body</dt>
<dd>
<pre>{{content.body}}</pre>
</dd>
</dl>
</div>
<div class="panel-body">
{{content.errorMessage}}
</div>

</div>

<div class="panel panel-info" ng-if="success">
<div class="panel-heading">
Email message details
</div>
<div class="panel-body">
<div ng-show="content.traits.is_anonymous_proxy" class="alert alert-warning">Is anonymous proxy</div>
<div ng-show="content.traits.is_satellite_provider" class="alert alert-warning">Is satellite provider</div>

<dl class="dl-horizontal">
<dt>From</dt>
<dd>{{content.displayFrom}} ({{content.sender}})</dd>
</dl>
<dl class="dl-horizontal">
<dt>To</dt>
<dd>{{content.displayTo}} ({{content.receivers}})</dd>
</dl>
<dl class="dl-horizontal">
<dt>Subject</dt>
<dd>{{content.subject || '-'}}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Topic</dt>
<dd>{{content.topic || '-'}}</dd>
</dl>
<dl class="dl-horizontal">
<dt>Bcc</dt>
<dd>{{content.bcc || '-'}}</dd>
</dl>
<dl class="dl-horizontal" ng-if="content.attachments && content.attachments.length !== 0">
<dt>Attachments</dt>
<dd>
<div class="bm10">This message file includes
<ng-pluralize count="content.attachments.length" when="{'1': '1 attachment', 'other': '{} attachments'}"></ng-pluralize>
</div>
<table class="table table-striped table-bordered">
<thead>
<tr>
<th class="col-md-2">Filename</th>
<th>File information</th>

</tr>
</thead>
<tbody ng-repeat="a in content.attachments">
<tr>
<td rowspan=4>{{a.filename}}</td>
<td>[MD5]: {{a.md5}}</td>
</tr>
<tr>
<td>[SHA1]: {{a.sha1}}</td>
</tr>
<tr>
<td>[SHA256]: {{a.sha256}}</td>
</tr>
<tr>
<td>
{{a.mime}}
</td>
</tr>
</tbody>
</table>
</dd>
</dl>
<dl class="dl-horizontal">
<dt>Headers</dt>
<dd>
<pre>{{content.headers}}</pre>
</dd>
</dl>
<dl class="dl-horizontal">
<dt>Body</dt>
<dd>
<pre>{{content.body}}</pre>
</dd>
</dl>
</div>
</div>