md5Changer.py 858 B

12345678910111213141516171819202122232425262728293031323334
  1. import os
  2. import subprocess
  3. import random
  4. from math import floor
  5. paths = []
  6. def hashAttack(file, path):
  7. print("Hashing: " + file)
  8. print(" Old Hash: " + getMd5(path + file))
  9. hashFile(path + file)
  10. print(" New Hash: " + getMd5(path + file))
  11. def getMd5(filePath):
  12. #print("md5sum " + "\"" + filePath + "\"")
  13. return subprocess.check_output("md5sum " + "\"" + filePath + "\"", shell=True, universal_newlines=True)
  14. def hashFile(filePath):
  15. rand = int(floor(random.uniform(11,23)))
  16. cmd = "truncate " + "-s " + "+" + str(rand) + " \"" + filePath + "\""
  17. #print(cmd)
  18. subprocess.call(cmd, shell=True)
  19. def startHashing(path):
  20. for root, dirs, files in os.walk(path):
  21. for file in files:
  22. #print(root + "/" + file)
  23. hashAttack(file, root + "/")
  24. for path in paths:
  25. startHashing(path)