Skip to content

Commit

Permalink
Added swap/pagefiles auto-detection system independent and random wip…
Browse files Browse the repository at this point in the history
…es feature (option 7).
  • Loading branch information
r3nt0n committed Jun 22, 2020
1 parent 133047a commit 4341448
Show file tree
Hide file tree
Showing 8 changed files with 1,181 additions and 1,060 deletions.
1,348 changes: 674 additions & 674 deletions LICENSE

Large diffs are not rendered by default.

101 changes: 51 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,51 +1,52 @@
![[Version 0.5~beta](https://github.com/R3nt0n)](http://img.shields.io/badge/version-v0.5~beta-orange.svg)
![[Python 3.2+](https://github.com/R3nt0n)](http://img.shields.io/badge/python-3.2+-blue.svg)
![[GPL-3.0 License](https://github.com/R3nt0n)](https://img.shields.io/badge/license-GPL%203.0-brightgreen.svg)

<p align="center"><img src="https://github.com/R3nt0n/wiper/blob/master/img/wiper-0.5.gif" /></p>

# wiper
Toolkit to perform secure destruction of sensitive virtual data, temporary files and swap memories.

It has been **designed to make tasks about personal data destruction easier**, those which remain on work computers **when employees leave the company**.

## Features
+ **MANUAL wipe selection**. You can wipe single files, whole directories and free space in partitions.
+ **AUTO wipe selection**. Suggests an automatic selection of paths to wipe, relatives to personal/temporary data and swap memories.
**If you run it with the OS target unmounted**, e.g. from a live OS trying to wipe an
unmounted hard drive containing another OS, you should provide the root path/mount point to that system in order to use auto-search mode.

## How it works
+ 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.
+ **Paths** provided **can be absolute or relative**, but **don't allow wildcards**.

## Requirements
+ Python 3
+ wmi (if you want to use auto-search mode booted on a Windows OS)

## Usage
```
-h, --help show this help message and exit
-i, --interactive interactive mode, the script will guide you
-w, --free-space wipe all free space on given path
-p path, --path path path to partition/file you want to wipe (required in non-interactive mode)
```

## Changelist
##### 0.5~beta version notes (20/06/2020)
+ Manual options (wipe free space and wipe single/multiple files) implemented.


## TODO list
+ Add **other one-pass overwriting methods** to:
+ choose between them in a **single-pass mode**
+ combine them in a **multi-pass mode**


## Legal disclaimer
![[Version 0.5~beta](https://github.com/R3nt0n)](http://img.shields.io/badge/version-v0.5~beta-orange.svg)
![[Python 3.2+](https://github.com/R3nt0n)](http://img.shields.io/badge/python-3.2+-blue.svg)
![[GPL-3.0 License](https://github.com/R3nt0n)](https://img.shields.io/badge/license-GPL%203.0-brightgreen.svg)

<p align="center"><img src="https://github.com/R3nt0n/wiper/blob/master/img/wiper-0.5.gif" /></p>

# wiper
Toolkit to perform secure destruction of sensitive virtual data, temporary files and swap memories.

It has been **designed to make tasks about personal data destruction easier**, those which remain on work computers **when employees leave the company**.

## Features
+ **MANUAL wipe selection**. You can wipe single files, whole directories and free space in partitions.
+ **AUTO wipe selection**. Suggests an automatic selection of paths to wipe, relatives to personal/temporary data and swap memories.
**If you run it with the OS target unmounted**, e.g. from a live OS trying to wipe an
unmounted hard drive containing another OS, you should provide the root path/mount point to that system in order to use auto-search mode.

## How it works
+ 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.
+ **Paths** provided **can be absolute or relative**, but **don't allow wildcards**.

## Requirements
+ Python 3
+ wmi (if you want to use auto-search mode booted on a Windows OS)

## Usage
```
Absolute and relative paths are allowed, but no wildcards.
-h, --help show this help message and exit
-i, --interactive interactive mode, the script will guide you
-w, --free-space wipe all free space on given path
-p path, --path path path to partition/file you want to wipe (required in non-interactive mode)
```

## Changelist
##### 0.5~beta version notes (20/06/2020)
+ Manual options (wipe free space and wipe single/multiple files) implemented.


## TODO list
+ Add **other one-pass overwriting methods** to:
+ choose between them in a **single-pass mode**
+ combine them in a **multi-pass mode**


## Legal disclaimer
This tool is created for the sole purpose of security awareness and education, it should not be used against systems that you do not have permission to test/attack. The author is not responsible for misuse or for any damage that you may cause. You agree that you use this software at your own risk.
4 changes: 2 additions & 2 deletions r3ntlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# R3nt0n
32 changes: 16 additions & 16 deletions r3ntlib/color.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# r3nt0n

class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
ORANGE = '\033[33m'
#ORANGEBG = '\033[48;2;255;165;0m'
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# r3nt0n

class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
ORANGE = '\033[33m'
#ORANGEBG = '\033[48;2;255;165;0m'
END = '\033[0m'
92 changes: 69 additions & 23 deletions r3ntlib/os_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
__version__ = '1.0'
__status__ = 'Development'

import os, subprocess
import os, subprocess, shlex
from pathlib import Path

# wmi impoted in OS systems
Expand All @@ -24,14 +24,14 @@ def clear():
os.system(['clear', 'cls'][os.name == 'nt'])


def find_files(root_path, files_to_exclude):
"""Find files recursively from the given root_path. The script absolute path
can be excluded.
def find_files(root_path, files_to_exclude=()):
"""Find files recursively from the given root_path. Special directories/files,
like the script absolute path, can be excluded.
Returns a list of files, including the absolute path of each one.
Arguments:
root -- root directory where it begins to search.
files_to_exclude -- list of absolute path to files that will be excluded
from the return list.
files_to_exclude -- (optional) list of absolute path to files that will
be excluded from the return list
"""
files_list = []
for root, dirs, files in os.walk(root_path, topdown=False):
Expand All @@ -45,32 +45,78 @@ def find_files(root_path, files_to_exclude):
files_list.append(Path(root) / name)
return files_list

def get_default_root_system():
"""Gets the actual root path to the drive which contains the OS that is
mounted, (e.g. 'C:' in Win (tipically), '/' in Linux.
Returns a Path-object pointing to the root system
"""
root = False
if os.name == 'posix':
root = '/'
elif os.name == 'nt':
root = '%SYSTEMDRIVE%'
return Path(root)

def get_variable_paths():
def run_command(command):
process = subprocess.Popen(shlex.split(command), stdout=subprocess.PIPE)
while True:
output = process.stdout.readline()
if output == '' and process.poll() is not None:
break
if output:
print(u'{}'.format(output.strip()))
rc = process.poll()
return rc

def get_swaps(root_system=False):
"""Interacts with mounted/umounted operative systems and search paths
relatives to swap files/partitions.
Returns a list with swap partitions founded (Linux) or pagefile paths (Win)
Returns an empty list (implicit False) in case of any files founded
Returns :ERR: follows by a description in case of error in the arg provide
Arguments:
root_system -- optional arg, if the target OS is umounted, you should
provide a root path to that system
"""
swap_dirs = []
# root_system provided and is a valid path, checking default path in Win (Linux don't supported)
if os.path.isdir(root_system):
default_pagefile_name = 'pagefile.sys'
default_pagefile_path = Path(root_system) / default_pagefile_name
swap_dirs = find_files(default_pagefile_path)
# root_system provided but not a valid path (returns ERROR)
elif root_system:
swap_dirs = ':ERR:root_system should be an accesible dir - check path and permissions.'
# root_system NOT provided, checking booted system info
else:
root_system_path = get_default_root_system()
if os.name == 'posix':
swaps_path = root_system_path / 'proc/swaps'
p = subprocess.run('cat {}'.format(swaps_path), stdout=subprocess.PIPE,
text=True, shell=True, check=True)
swaps = p.stdout.split('\n')[1:-1]
for swap in swaps:
swap_dirs.append(swap.split(' ')[0])
elif os.name == 'nt':
import wmi # Importing WMI only on Windows machines
pagefiles = wmi.WMI()
for pf in pagefiles.Win32_Pagefile():
swap_dirs.append(pf.Caption)
return swap_dirs

def get_personal_dir(root='/'):
"""Interacts with the OS (Win/Linux) to get paths relatives to personal
directories and swap files/partitions.
Returns a tuple ([personal_dirs], [swap_dirs]) and each element is a list.
Returns a list with personal directories founded
"""
personal_dirs = []
swap_dirs = []
if os.name == 'posix':
personal_dirs = ['$HOME']
p = subprocess.run('cat /proc/swaps', stdout=subprocess.PIPE,
text=True, shell=True, check=True)
swaps = p.stdout.split('\n')[1:-1]
for swap in swaps:
swap_dirs.append(swap.split(' ')[0])
elif os.name == 'nt':
import wmi # Importing WMI only in Windows OS
personal_dirs = ['%USERPROFILE%', '%HOMEDRIVE%', '%HOMEPATH%']
pagefiles = wmi.WMI()
for pf in pagefiles.Win32_Pagefile():
swap_dirs.append(pf.Caption)
return personal_dirs, swap_dirs

personal_dirs = ['%USERPROFILE%', '%HOMEDRIVE%', '%HOMEPATH%']

if __name__ == '__main__':
# Tests
files_to_exclude = os.path.abspath(__file__)
filelist = find_files('./*', files_to_exclude)
print(filelist)
print(filelist)

Loading

0 comments on commit 4341448

Please sign in to comment.