Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down