Skip to content

Instantly share code, notes, and snippets.

@Tarliton
Created April 29, 2021 22:40
Show Gist options
  • Save Tarliton/617e1d418ffc1f232fe72a0f25402157 to your computer and use it in GitHub Desktop.
Save Tarliton/617e1d418ffc1f232fe72a0f25402157 to your computer and use it in GitHub Desktop.
open processes hashes
import hashlib
import psutil
BUF_SIZE = 65536
exes = set()
for p in psutil.process_iter():
exe = p.exe()
if not exe or p.name() == 'none':
continue
if exe in exes:
continue
exes.add(exe)
sha256 = hashlib.sha256()
with open(exe, 'rb') as f:
while True:
data = f.read(BUF_SIZE)
if not data:
break
sha256.update(data)
print(p.name(), exe, sha256.hexdigest())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment