Appearance
Overview of the architecture
As said before, nClean is a 3-stage project. Each section defines what each stage does.
PreLauncher
- The PreLauncher is a simple PowerShell5 compatible script that prepares the system for the deployment of the Worker
- Execution tree:
- Check if the script is running as admin, if not, ask the user to launch it as admin
- Create a directory in
C:/nClean, so that only Administrators have access to it - Download the worker script from the locally hosted server,
$HostUrl/int/worker.ps1toC:/nClean/main.ps1 - Check if there is already a task scheduled to run the
nClean-Worker, if yes, remove it, if not, create one. It will run:- Once after the PreLauncher has completed execution
- At login, delayed by 30 seconds
- At startup, delayed by 2 minutes
- After the PreLauncher has completed execution, the Worker will be manually triggered once
Worker
- The worker is a PowerShell5 compatible script that executes the main cleanup tasks defined in a playbook. It is ran as SYSTEM, but it executes the playbook tasks for the currently logged in user
- Execution tree:
- Get the currently logged in user
- Ensure the current folder (
C:/nClean/) has the correct permissions, set it to hidden and set the permissions if it doesn't - Get the host identifier
- If it already exists (a file named
hostidentifier.txtexists), use it - If it doesn't exist, create a new UUIDv4 and save it to
hostidentifier.txt
- If it already exists (a file named
- Check for internet connectivity, the script will try to check for internet for 2 minutes, every 30 seconds, until a connection is available or the timeout is reached.
- If the timeout is reached, the script will exit with code
2001 - If a connection is available, the script will continue execution
- If the timeout is reached, the script will exit with code
- Fetch the configuration from the WebUI server
- If the configuration is not available, the script will exit with code
2002
- If the configuration is not available, the script will exit with code
- Check if playbook execution is disabled, forced, or neither in the configuration
- If it is disabled, exit with code
1001 - If it is forced, skip the last-run-time check
- If neither, proceed to the last-run-time check, that ensures that the worker can only execute once every 24 hours. If there is time remaining until the 24 hours pass, the script will
Sleepfor that duration of time
- If it is disabled, exit with code
- Execute the playbook tasks for the currently logged in user in this order
- Apply browser policies to firefox, chrome, and edge
- Check user directories/file for for files that havent been touched for more than 24 hours
- Clean up browser information if the browser isnt running right now
- Remove all specified APPX packages
- Update the
lastruntime.txtfile with the current timestamp - Send telemetry data and the execution log to the WebUI server
- Exit with the code
0
WebUI
- The WebUI is a fairly simple, yet advanced web interface that allows users to manage the nClean server, including viewing logs, configuring playbooks, or changing the master configuration. It is made in Python, and can be ran from a Docker container, behind cloudflare, using uvicorn (recommended)
- The WebUI communicates with the
WorkerandPreLauncherscripts via a JSON API, it allows the user to quickly, and easily manage nClean without even touching the terminal - Overview of the interface
- Dashboard - It shows the recently connected clients, total amount of clients that have ever connected, amount of clients that had connected to the server today, and the server status. The recent client activity list shows the last 5 clients that connected to the server, alongside their UUID, local IP, and last connection date
- Clients - Shows the whole list of clients, their UUID, local IP, last connection date, note, and a button to view the client's details
- Search - Allows the user to easily filter the client list by the amount of free space, unexpected wallpapers, uptime, flagged apps, amount of ram, and app details
- Settings - Allows the user to configure the nClean worker settings, including the toggle for playbook execution, forced execution, usage of a custom playbook, post-run command, host url (used to generate the
PreLauncherscript), highlighting of apps, and the expected wallpaper hash - Playbooks - A menu to easily configure and manage playbooks according to the specifications
- Generator - A page for creating the
PreLauncherscript, and generating PowerShell commands, and URLs for it. It allows the user to customize the URL used to get and then launch the PreLauncher, and later Worker - Users - Allows administrators to manage users
Collected telemetry
- Amount of RAM installed in the system