Small web interface for DUC - https://duc.zevv.nl/
This Flask application lets you scan your system's disk usage using duc and visualize the results in a graph directly from your web browser. You can also launch new scans and monitor their status.
This application requires the user running Flask to have sudo permissions to execute duc index and duc graph commands without a password.
This poses a significant security risk if not handled properly.
Production Recommendations:
- Restrict
sudocommands to specific paths. - Use a dedicated user with minimal permissions.
- Implement a task queue system (Celery, Redis Queue) that runs commands under a controlled user.
Make sure the following are installed:
-
Python 3
python3 --version
-
Flask
pip install Flask
-
DUC (Disk Usage Checker)
sudo apt-get install duc # Debian/Ubuntu # sudo yum install duc # CentOS/RHEL # sudo pacman -S duc # Arch Linux # brew install duc # macOS (Homebrew)
Edit the sudoers file:
sudo visudoAdd the following line, replacing <your_user> with your Linux username:
<your_user> ALL=(ALL) NOPASSWD: /usr/bin/duc index *, /usr/bin/duc graph *Save and exit:
- In
nano: Ctrl+X, thenYto confirm, and Enter to save.
Verify the configuration (optional but recommended):
sudo duc index /
sudo duc graph -o /tmp/test_duc_graph.png /Create a file called app.py in a directory (e.g., ~/duc_app/) and paste the provided Python code.
.
└── app.py
└── static/
└── graphs/
mkdir -p static/graphsEnsure the user running app.py has write permissions in static/graphs.
cd ~/duc_app/
python app.pyYou will see something like:
Flask app started at http://127.0.0.1:8888
Graph directory: /home/your_user/duc_app/static/graphs
Scan log: /home/your_user/duc_app/scan_log.txt
Open your browser and go to: http://localhost:8888
From another machine: http://192.168.X.X:8888
The most recent graph in static/graphs will be shown automatically.
- Select a path (e.g.,
/,/home, etc.) - Click Start Scan
- It will be added to the scan status list.
- RUNNING: scan in progress
- FINISHED: completed successfully
- ERROR: there was an issue (check logs)
scan_log.txt logs all duc command outputs and errors for debugging.
Esta aplicación Flask te permite escanear el uso de disco de tu sistema usando duc y visualizar los resultados en un gráfico directamente desde tu navegador web. También puedes lanzar nuevos escaneos y ver su estado.
Esta aplicación requiere que el usuario bajo el que se ejecuta Flask tenga permisos sudo para ejecutar los comandos duc index y duc graph sin pedir contraseña.
Esto representa un riesgo de seguridad significativo si no se gestiona adecuadamente.
Recomendaciones para producción:
- Limitar los comandos
sudoa rutas específicas. - Usar un usuario dedicado con permisos mínimos.
- Implementar un sistema de cola de tareas (Celery, Redis Queue) que ejecute los comandos con un usuario controlado.
Antes de empezar, asegúrate de tener instalado:
-
Python 3
python3 --version
-
Flask
pip install Flask
-
DUC (Disk Usage Checker)
sudo apt-get install duc # Debian/Ubuntu # sudo yum install duc # CentOS/RHEL # sudo pacman -S duc # Arch Linux # brew install duc # macOS (Homebrew)
Edita el archivo sudoers:
sudo visudoAñade la siguiente línea, reemplazando <tu_usuario> con tu nombre de usuario:
<tu_usuario> ALL=(ALL) NOPASSWD: /usr/bin/duc index *, /usr/bin/duc graph *Guarda y sal:
- En
nano: Ctrl+X, luegoYpara confirmar, y Enter para guardar.
Verifica la configuración (opcional):
sudo duc index /
sudo duc graph -o /tmp/test_duc_graph.png /Crea un archivo app.py en un directorio (ej. ~/duc_app/) y copia el código Python correspondiente.
.
└── app.py
└── static/
└── graphs/
mkdir -p static/graphscd ~/duc_app/
python app.pyVerás algo como:
Aplicación Flask iniciada en http://127.0.0.1:8888
Directorio de gráficos: /home/tu_usuario/duc_app/static/graphs
Log de escaneos: /home/tu_usuario/duc_app/scan_log.txt
Abre tu navegador en: http://localhost:8888
Desde otra máquina: http://192.168.X.X:8888
Se muestra automáticamente al cargar la página.
- Selecciona una ruta (ej.
/,/home, etc.) - Haz clic en Iniciar Escaneo
- Aparecerá en la lista de estado.
- RUNNING: en curso
- FINISHED: completado correctamente
- ERROR: ha fallado (ver logs)
scan_log.txt contiene resultados y errores para depuración.