From 0bb3af6aa48925423429840268ef5a4c2341ddf5 Mon Sep 17 00:00:00 2001 From: fjh1997 <549308442@qq.com> Date: Fri, 1 May 2020 21:20:22 +0800 Subject: [PATCH] add IO exception handling --- .gitignore | 1 + MKDecrypt.py | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5509140 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.DS_Store diff --git a/MKDecrypt.py b/MKDecrypt.py index 546dea0..eed6ee3 100644 --- a/MKDecrypt.py +++ b/MKDecrypt.py @@ -160,7 +160,15 @@ def main(): dmsetupcmd = 'dmsetup create ' + dmname + ' ' + ro + ' --table ' + table subprocess.call(dmsetupcmd, shell=True) ## test that the volume has decrypted correctly by reading (part of) the OEM from VBR - test = open(dmslot, 'rb') + try: + test = open(dmslot, 'rb') +## in case dmslot not found error + except IOError: + print("io error! decrypt failed! try another one") + if crypt == ' kuznyechik-xts-plain64 ': +## if all encryption types have been tried then try hidden volumes + tryhiddenvol = True + continue test.seek(3) OEM = test.read(5) test.seek(1024)