I would like to get the sha256 digest of the downloaded files that result from a pcap capture file (files that the user downloaded during wireshark packets capture).
This is the pcap I'm using: https://github.com/pan-unit42/wireshark-tutorial-Emotet-traffic/blob/main/Example-1-2021-01-06-Emotet-infection.pcap.zip
at packet 463 (1-indexed, 462 0-indexed) there is a HTTP response with file attachment:
Hypertext Transfer Protocol
HTTP/1.1 200 OK\r\n
Date: Wed, 06 Jan 2021 16:41:45 GMT\r\n
Server: Apache\r\n
X-Powered-By: PHP/7.3.11\r\n
Cache-Control: no-cache, must-revalidate\r\n
Pragma: no-cache\r\n
Expires: Wed, 06 Jan 2021 16:41:45 GMT\r\n
Content-Disposition: attachment; filename="nDUrg8uFD5hl.dll"\r\n
Content-Transfer-Encoding: binary\r\n
Set-Cookie: 5ff5e84994849=1609951305; expires=Wed, 06-Jan-2021 16:42:45 GMT; Max-Age=60; path=/\r\n
Last-Modified: Wed, 06 Jan 2021 16:41:45 GMT\r\n
Keep-Alive: timeout=6, max=100\r\n
Connection: Keep-Alive\r\n
Transfer-Encoding: chunked\r\n
Content-Type: application/octet-stream\r\n
\r\n
[HTTP response 1/1]
[Time since request: 70.452158000 seconds]
[Request in frame: 45]
[Request URI: http://seo.udaipurkart.com/rx-5700-6hnr7/Sgms/]
HTTP chunked response
File Data: 192000 bytes
I wrote this code to get the file hash but it does not provide the correct hash, which should be 8e37a82ff94c03a5be3f9dd76b9dfc335a0f70efc0d8fd3dca9ca34dd287de1b
import pyshark
import hashlib
cap = pyshark.FileCapture('capture1.pcap')
print(hashlib.sha256(cap[462].http.file_data.raw_value.encode()).hexdigest())
Where am I wrong? Which packet.http property should I check to get the downloaded file?