Created
April 29, 2021 22:40
-
-
Save Tarliton/617e1d418ffc1f232fe72a0f25402157 to your computer and use it in GitHub Desktop.
open processes hashes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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