diff --git a/reset.py b/reset.py index f86c7f8..682036b 100755 --- a/reset.py +++ b/reset.py @@ -9,6 +9,17 @@ firmadyne_path = config["DEFAULT"].get("firmadyne_path", "") sudo_pass = config["DEFAULT"].get("sudo_password", "") +print ("[+] Checking if filesystem is still mounted...") +child = pexpect.spawn("/bin/sh" , ["-c", "sudo findmnt -l | grep " + os.path.join(firmadyne_path, "scratch/*/image")]) +child.sendline(sudo_pass) +child.expect_exact(pexpect.EOF) +if bytes(firmadyne_path.encode()) in child.before: + loop_dev = child.before.split(b' ')[1].decode() + print ("[+] Unmounting filesystem...") + child = pexpect.spawn("/bin/sh" , ["-c", "sudo umount " + loop_dev]) + child.sendline(sudo_pass) + child.expect_exact(pexpect.EOF) + print ("[+] Cleaning previous images and created files by firmadyne") child = pexpect.spawn("/bin/sh" , ["-c", "sudo rm -rf " + os.path.join(firmadyne_path, "images/*.tar.gz")]) child.sendline(sudo_pass)