Skip to content

Commit

Permalink
v0.9: zeros,ones and random one-pass overwrite methods already implem…
Browse files Browse the repository at this point in the history
…ented (TODO: logic to select between and/or combine them)
  • Loading branch information
r3nt0n committed Jun 29, 2020
1 parent 521f240 commit 3330bfa
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 18 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**.

Expand All @@ -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)
Expand All @@ -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
Expand Down
Binary file removed img/wiper-0.5.gif
Binary file not shown.
Binary file removed img/wiper-0.6.gif
Binary file not shown.
Binary file added img/wiper-0.9.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 25 additions & 10 deletions r3ntlib/wiper_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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))
Expand Down
11 changes: 7 additions & 4 deletions wiper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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))
Expand All @@ -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))
Expand Down

0 comments on commit 3330bfa

Please sign in to comment.