Foremost.py is a Python program designed for file recovery and data extraction. It uses the Foremost tool in a WSL (Windows Subsystem for Linux) environment to analyze disk images or raw data and recover files based on their headers, footers, and internal structures.
- π Automatically runs Foremost via WSL to recover files.
- π Supports various file formats (images, documents, videos, etc.).
- ποΈ Organizes recovered files into structured directories.
- β‘ Lightweight, automated, and easy to use.
- π Python 3.x
- π₯οΈ WSL (Windows Subsystem for Linux) installed and configured
- π¦ Foremost installed in the WSL environment
- Clone the repository:
git clone https://github.com/FSTHTW/ForemostAuto
- Navigate to the project directory:
cd foremost.py - Ensure WSL is installed and Foremost is available in the WSL environment:
wsl sudo apt update && sudo apt install foremost
- βοΈ Modify the Python script to specify the paths to your
.imgfile and the output folder:wsl_command = "foremost -i /mnt/../../to your .img file -o /mnt/../../recup_img"
βΆοΈ Run the Python script:python foremost.py
- π The recovered files will be available in the specified output folder.
Here is an excerpt from the main script:
import subprocess
def open_wsl_and_run_command():
wsl_command = "foremost -i /mnt/../../to your .img file -o /mnt/../../recup_img"
try:
print("Opening WSL and executing the command...")
subprocess.run(["wsl", "bash", "-c", wsl_command], check=True)
print("Analysis complete! Files are recovered in the specified folder.")
except subprocess.CalledProcessError as e:
print(f"Error while executing the command: {e}")
except FileNotFoundError:
print("Error: wsl.exe not found. Ensure WSL is properly installed.")
except Exception as e:
print(f"Unexpected error: {e}")
if __name__ == "__main__":
open_wsl_and_run_command()- β Ensure the paths specified in the WSL command are correct and accessible.
- π Refer to the official Foremost documentation for advanced options.
This project is licensed under the MIT License.