-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmd5Changer.py
34 lines (25 loc) · 858 Bytes
/
md5Changer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import subprocess
import random
from math import floor
paths = []
def hashAttack(file, path):
print("Hashing: " + file)
print(" Old Hash: " + getMd5(path + file))
hashFile(path + file)
print(" New Hash: " + getMd5(path + file))
def getMd5(filePath):
#print("md5sum " + "\"" + filePath + "\"")
return subprocess.check_output("md5sum " + "\"" + filePath + "\"", shell=True, universal_newlines=True)
def hashFile(filePath):
rand = int(floor(random.uniform(11,23)))
cmd = "truncate " + "-s " + "+" + str(rand) + " \"" + filePath + "\""
#print(cmd)
subprocess.call(cmd, shell=True)
def startHashing(path):
for root, dirs, files in os.walk(path):
for file in files:
#print(root + "/" + file)
hashAttack(file, root + "/")
for path in paths:
startHashing(path)