-
[Python] Hash-result개발 2021. 8. 2. 01:24
파일의 해시를 계산 + 같은 해시를 갖은 파일 검색
함수를 많이 만들어서 코딩을 해야 할 것 같다.
https://github.com/fxploit/hash-result/blob/master/hash.py
import os import hashlib import sys print("============== Select Menu ==============") print("(1) Hash Calculation (2) Hashset (3) Exit") menu = int(input("Select >>> ")) if menu == 1: filename = input('FileName >>> ') f1 = open(filename, 'rb') data = f1.read() f1.close() md5 = hashlib.md5(data).hexdigest() sha1 = hashlib.sha1(data).hexdigest() sha256 = hashlib.sha256(data).hexdigest() print("============== Hash Result ==============") print("MD5: " + md5) print("SHA-1: " + sha1) print("SHA-256: " + sha256) if menu == 2: print("Default Searching Path is C:\\Users\\parj2\\Downloads") hashset = input("MD5 HashSet >>> ") path_dir = "C:/Users/parj2/Downloads/" file_list = os.listdir(path_dir) print(file_list) dic = {} for i in file_list: print(i) f2 = open(path_dir+i,'rb') realdata = f2.read() f2.close() md5 = hashlib.md5(realdata).hexdigest() dic[i] = md5 print("MD5: " + md5, end="\n\n") print("C:\\Users\\parj2\\Downloads ALL File MD5 Result Save!!") print(dic) for key, value in dic.items(): if value == hashset: print("============== Success ==============") print("Detection: "+ path_dir +key) break # else: # print("============== Fail ==============") # print("No matching MD5 HashSet~~") # sys.exit() if menu == 3: print("What The Fuxx!!") sys.exit()
'개발' 카테고리의 다른 글
[Python] 아웃룩 자동화 (0) 2023.12.27 [Python] Snort 위협 탐지 정책 관리 대장 자동화 (0) 2023.12.18 [프로젝트] 침해사고 분석도구 SURFER개발 (0) 2022.01.19 [Python] JPEG-signature-search (0) 2021.08.02 MakeFile 생성 (0) 2021.07.28