diff --git a/README.md b/README.md index e316cf7..79ed7cc 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ unmounted hard drive containing another OS, you should provide the root path/mou + **This is not a backup tool**: the data will be unrecoverable, so **be sure to backup all the files you want to keep before wipe it**. + You can **wipe single/multiple files** and **wipe free space** by manual selection. + Auto-search mode is able to **scan and suggest sensitive paths that are tipically candidates to wipe**. -+ It **overwrites existing data or free space** with one-pass pseudo-random bytes. ++ It **overwrites existing data or free space** with one-pass **pseudo-random/ones/zeros** bytes and also combine them. + **Paths** provided **can be absolute or relative**, but **don't allow wildcards**. + Be careful **when you overwrite whole partitions** (like wipe swaps feature), the **device block** (info like partitions UUID) **will be destroyed**. @@ -48,6 +48,7 @@ unmounted hard drive containing another OS, you should provide the root path/mou + wmi (if you want to use auto-search mode booted on a Windows OS) ## Changelist ++ One-pass overwrite methods already implemented: random, ones and zeros. + Fixing menu bug and updating usage. + Added auto-search personal dirs platform independent. Added arguments for all interactive options (everything can be run from CLI or inside interactive mode) ##### 0.6~beta version notes (20/06/2020) @@ -60,9 +61,7 @@ unmounted hard drive containing another OS, you should provide the root path/mou ## TODO list + Implement temp, home_all and temp_all features. -+ Add **other one-pass overwriting methods** to: - + choose between them in a **single-pass mode** - + combine them in a **multi-pass mode** ++ Write the logic to switch between different overwrite methods already implemented (ones, zeros and random) and allow user to combines it. ## Legal disclaimer diff --git a/img/wiper-0.5.gif b/img/wiper-0.5.gif deleted file mode 100644 index 5816dc3..0000000 Binary files a/img/wiper-0.5.gif and /dev/null differ diff --git a/img/wiper-0.6.gif b/img/wiper-0.6.gif deleted file mode 100644 index a2fd32e..0000000 Binary files a/img/wiper-0.6.gif and /dev/null differ diff --git a/img/wiper-0.9.gif b/img/wiper-0.9.gif new file mode 100644 index 0000000..411900e Binary files /dev/null and b/img/wiper-0.9.gif differ diff --git a/r3ntlib/wiper_ops.py b/r3ntlib/wiper_ops.py index 312e8ca..faaf081 100644 --- a/r3ntlib/wiper_ops.py +++ b/r3ntlib/wiper_ops.py @@ -22,14 +22,16 @@ ################################################################################ -def random_wipe(path, mode, size_to_write): +def wipe_bytes(path, mode, size_to_write, method='r'): """Overwrite the given path with n random bytes (n is the size given in bytes) Returns a status code: 0 - OK, 1-Space wasn't even filled randomly, 2-Space wasn't secure delete Arguments: - path -- root directory where it begins to search. - mode -- 'ab+' for wipe free space in the given path, - 'wb' to overwrite an existing file + path -- root directory where it begins to search. + mode -- 'ab+' for wipe free space in the given path, + 'wb' to overwrite an existing file + size-to-write -- size in bytes to overwrite + methods -- if tuple contains: r -> random, z -> zeros, o -> ones """ status = 0 try: @@ -38,10 +40,15 @@ def random_wipe(path, mode, size_to_write): color.PURPLE, size_to_write, color.END)) print(u' {}[+]{} Starting one-pass random wipe...'.format(color.ORANGE, color.END)) pointer = 0 + if method == 'z': + overwritebyte = b'\x00' + elif method == 'o': + overwritebyte = b'\xff' with open(path, mode) as dummy_file: while size_to_write > 0: - randbyte = bytearray(getrandbits(8) for _ in range(1)) - dummy_file.write(randbyte) + if method == 'r': + overwritebyte = bytearray(getrandbits(8) for _ in range(1)) + dummy_file.write(overwritebyte) size_to_write -= 1 if mode == 'wb': pointer += 1 @@ -62,7 +69,7 @@ def random_wipe(path, mode, size_to_write): print('{} [!]{} ERROR: {}'.format(color.RED,color.END,exception)) return status -def dd_random_wipe(linux_path): +def dd_linux_wipe(linux_path, method='r'): '''Random wipe using dd tool on Linux OS. Returns 6 if uncompatible operative system is detected Returns 4 if error triggered trying to run subprocess @@ -71,11 +78,19 @@ def dd_random_wipe(linux_path): status = 6 if os.name == 'posix': try: + bs = '1024' + if method == 'r': + src = '/dev/zero' + elif method == 'z': + src = "<(yes $'\\ff' | tr -d \"\\n\")" + else: + src = '/dev/urandom' + bs = '4096' bytes_to_write = disk_usage(linux_path)[2] print(' {}[+]{} Starting to wipe {}{}{} ({}{}{} bytes) with dd tool...\r\n'.format(color.ORANGE, color.END, color.ORANGE,linux_path,color.END, color.PURPLE,bytes_to_write,color.END)) - command = 'dd if=/dev/urandom of={} bs=4096 status=progress'.format(linux_path) + command = 'dd if={} of={} bs={} status=progress'.format(src,linux_path,bs) status = run_command(command) except Exception as exception: status = 4 @@ -97,7 +112,7 @@ def wipe_free_space(path): tempfile = os.path.join(path,'00000001') try: free_space = disk_usage(path)[2] - random_wipe(tempfile, 'ab+', free_space) + wipe_bytes(tempfile, 'ab+', free_space) except Exception as exception: print('{} [!]{} ERROR: {}'.format(color.RED, color.END, exception)) finally: @@ -113,7 +128,7 @@ def wipe_file(path): """ try: bytesize_to_write = os.stat(path).st_size - random_wipe(path, 'wb', bytesize_to_write) + wipe_bytes(path, 'wb', bytesize_to_write) status = True except Exception as exception: print('{} [!]{} ERROR: {}'.format(color.RED, color.END, exception)) diff --git a/wiper.py b/wiper.py index 2ecc075..e307fdc 100644 --- a/wiper.py +++ b/wiper.py @@ -210,7 +210,8 @@ def main(): wipe(path) elif (opt == '3' or wipe_temp_arg): - pass + print(u' {}[x]{} This feature is not still implemented.'.format(color.ORANGE, color.END)) + continue # Wipes user personal dir elif (opt == '4' or wipe_home_arg): personal_dirs = os_ops.get_personal_dirs() @@ -235,9 +236,11 @@ def main(): continue # Back to menu wipe(pdir) elif (opt == '5' or wipe_temp_all_arg): - pass + print(u' {}[x]{} This feature is not still implemented.'.format(color.ORANGE, color.END)) + continue elif (opt == '6' or wipe_home_all_arg): - pass + print(u' {}[x]{} This feature is not still implemented.'.format(color.ORANGE, color.END)) + continue # Wipes swaps/pagefiles elif (opt == '7' or wipe_swaps_arg): print(u' {}[-]{} Searching swap/pagefiles...'.format(color.ORANGE, color.END)) @@ -259,7 +262,7 @@ def main(): wipe(swaplist) elif (os.name == 'posix'): for swap in swaplist: - status = wiper_ops.dd_random_wipe(swap) + status = wiper_ops.dd_linux_wipe(swap) if str(status) == '0': print(u' {}[+]{} {}{}{} was succesfully wiped.'.format(color.GREEN,color.END, color.PURPLE,swap,color.END))