Skip to content

Commit

Permalink
#260 add attachments hashes information
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromeleonard committed Jul 26, 2018
1 parent 6963e81 commit a52f1ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
5 changes: 4 additions & 1 deletion analyzers/EmlParser/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from cortexutils.analyzer import Analyzer
import magic
import binascii
import hashlib
from pprint import pprint

class EmlParserAnalyzer(Analyzer):
Expand Down Expand Up @@ -84,6 +85,7 @@ def parseEml(filepath):
#attachments
try:
for attachment in parsed_eml['attachment']:
sha256 = hashlib.sha256()
attachmentSumUp = dict()
attachmentSumUp['filename'] = attachment.get('filename', '')

Expand All @@ -92,7 +94,8 @@ def parseEml(filepath):
#it has to be calculated, the attachment is in base64
attachmentSumUp['mime'] = magic.from_buffer(binascii.a2b_base64(attachment['raw']))
attachmentSumUp['extension'] = attachment.get('extension', '')

sha256.update(attachment['raw'])
attachmentSumUp['sha256'] = sha256.hexdigest()
result['attachments'].append(attachmentSumUp)

except KeyError as e:
Expand Down
28 changes: 16 additions & 12 deletions thehive-templates/Eml_Parser_1_0/long.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,24 @@
<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-hover">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Filename</th>
<th>Mime Type</th>
<th>Extension</th>
</tr>
<tr>
<th class="col-md-2" >Filename</th>
<th >File information</th>

</tr>
</thead>
<tbody>
<tr ng-repeat="a in content.attachments">
<td class="wrap">{{a.filename}}</td>
<td class="wrap">{{a.mime}}</td>
<td>{{a.extension}}</td>
</tr>
<tbody ng-repeat="a in content.attachments">
<tr>
<td rowspan=2>{{a.filename}}</td>
<td>[SHA256]: {{a.sha256}}</td>
</tr>
<tr>
<td>
{{a.mime}}
</td>
</tr>
</tbody>
</table>
</dd>
Expand Down

0 comments on commit a52f1ff

Please sign in to comment.