ADNSecure is a collection of command-line utilities written in Dart, designed for the secure management and execution of administrative scripts (PowerShell, Bash) across multiple operating systems. The core of the project is an encryption mechanism that binds scripts to specific workstations, preventing their execution on unauthorized machines.
The project was developed by Massimo Travascio for the Ministry of Justice – Cisia of Turin (2024).
The ADNSecure workflow is based on a two-phase model:
- Encryption (
encryptscr): A script (e.g.,script.ps1orscript.sh) is encrypted for a specific target workstation. The output is a.scrfile that can only be executed on that machine. - Execution (
secscr): Thesecscrutility runs on the target workstation to decrypt and securely execute the script. The script can be loaded from a local file or downloaded from a remote URL.
This approach ensures that even if a .scr file is intercepted, it cannot be decrypted or executed on a computer other than the one it was created for.
ADNSecure is a monorepo containing several specialized utilities:
| Utility | Description |
|---|---|
encryptscr |
Secure Script Encoder: Encrypts PowerShell or Bash scripts for a specific workstation, generating a .scr file. |
secscr |
Secure Script Executor: Decrypts and executes a .scr file on the target workstation, with support for remote execution via HTTP. |
securejoin |
Utility for securely managing the process of joining an Active Directory domain, using double-encrypted credentials. |
encryptjoin |
Encrypts credentials for securejoin using a dual encryption mechanism (AES-256 + RSA-2048). |
rsakey2dart |
Converts RSA keys into Dart array format for embedding into executables. |
netjoindomain |
A low-level implementation for joining Windows domains through direct Win32 API calls. |
System security is built on two key pillars:
-
Strong Encryption: A combination of industry-standard cryptographic algorithms is used.
- RSA (2048-bit): For asymmetric key encryption.
- AES (256-bit): For symmetric encryption of script content.
-
Workstation Binding: Each encrypted script is irrevocably bound to the computer name (on Windows) or hostname (on Linux/macOS) of the target machine. This binding prevents unauthorized execution on other systems.
The utilities are designed to be used from the command line. Below are some basic examples.
To encrypt the file deploy.ps1 for a machine named PC-OFFICE:
encryptscr.exe --wks PC-OFFICE --file deploy.ps1This command will generate a file called PC-OFFICE.scr.
To execute the file PC-OFFICE.scr on the target machine:
secscr.exe --file PC-OFFICE.scr --execTo execute it with administrative privileges:
secscr.exe --file PC-OFFICE.scr --exec --runassecscr.exe --url http://server/scripts/PC-OFFICE.scr --execPrecompiled executables for Windows, Linux, and macOS are available on the repository’s Releases page.
The project relies on well-established Dart libraries for cryptography and system management:
- encrypt and pointycastle: For cryptographic functionality (AES, RSA).
- args: For command-line argument parsing.
- win32: For interacting with native Windows APIs.
- http: For downloading scripts from remote URLs.
Contributions are welcome. Feel free to open an issue to report bugs or suggest new features. If you wish to contribute code, fork the repository and submit a pull request.
This project is released under the MIT License.
ADNSecure è una raccolta di utility a riga di comando, scritte in Dart, progettate per la gestione e l'esecuzione sicura di script amministrativi (PowerShell, Bash) su sistemi operativi multi-piattaforma. Il cuore del progetto è un meccanismo di crittografia che lega gli script a workstation specifiche, impedendone l'esecuzione su macchine non autorizzate.
Il progetto è stato sviluppato da Massimo Travascio per il Ministero della Giustizia - Cisia di Torino (2024).
Il flusso di lavoro di ADNSecure si basa su un modello a due fasi:
- Crittografia (
encryptscr): Uno script (es.script.ps1oscript.sh) viene crittografato per una specifica workstation di destinazione. L'output è un file.scrche può essere eseguito solo su quella macchina. - Esecuzione (
secscr): L'utilitysecscrviene eseguita sulla workstation di destinazione per decifrare ed eseguire lo script in modo sicuro. Lo script può essere letto da un file locale o scaricato da un URL remoto.
Questo approccio garantisce che anche se un file .scr venisse intercettato, non potrebbe essere decifrato o eseguito su un computer diverso da quello per cui è stato creato.
ADNSecure è un monorepo che contiene diverse utility specializzate:
| Utility | Descrizione |
|---|---|
encryptscr |
Secure Script Encoder: Cripta script PowerShell o Bash per una workstation specifica, generando un file .scr. |
secscr |
Secure Script Executer: Decifra ed esegue un file .scr sulla workstation di destinazione, con supporto per l'esecuzione remota via HTTP. |
securejoin |
Utility per la gestione sicura del processo di join a un dominio Active Directory, utilizzando credenziali a doppia crittografia. |
encryptjoin |
Cripta le credenziali per securejoin utilizzando un meccanismo di doppia cifratura (AES-256 + RSA-2048). |
rsakey2dart |
Converte chiavi RSA in un formato array Dart da incorporare negli eseguibili. |
netjoindomain |
Un'implementazione di basso livello per il join a domini Windows tramite chiamate dirette alle API Win32. |
La sicurezza del sistema si basa su due pilastri fondamentali:
- Crittografia Robusta: Viene utilizzata una combinazione di algoritmi crittografici standard di settore.
- RSA (2048-bit): Per la crittografia asimmetrica delle chiavi.
- AES (256-bit): Per la crittografia simmetrica del contenuto degli script.
- Workstation Binding: Ogni script crittografato è indissolubilmente legato al nome del computer (su Windows) o all'hostname (su Linux/macOS) della macchina di destinazione. Questo legame impedisce l'esecuzione non autorizzata su altri sistemi.
Le utility sono progettate per essere usate da riga di comando. Di seguito alcuni esempi di base.
Per criptare il file deploy.ps1 per una macchina chiamata PC-UFFICIO:
encryptscr.exe --wks PC-UFFICIO --file deploy.ps1Questo comando genererà un file PC-UFFICIO.scr.
Per eseguire il file PC-UFFICIO.scr sulla macchina di destinazione:
secscr.exe --file PC-UFFICIO.scr --execPer eseguirlo con privilegi amministrativi:
secscr.exe --file PC-UFFICIO.scr --exec --runassecscr.exe --url http://server/scripts/PC-UFFICIO.scr --execGli eseguibili compilati per Windows, Linux e macOS sono disponibili nella pagina Releases del repository.
Il progetto si affida a librerie Dart consolidate per la crittografia e la gestione del sistema:
- encrypt e pointycastle: Per le funzionalità crittografiche (AES, RSA).
- args: Per il parsing degli argomenti a riga di comando.
- win32: Per l'interazione con le API native di Windows.
- http: Per il download di script da URL remoti.
I contributi sono benvenuti. Sentiti libero di aprire una issue per segnalare bug o proporre nuove funzionalità. Se desideri contribuire al codice, puoi creare una fork del repository e sottomettere una pull request.
Questo progetto è rilasciato sotto la Licenza MIT.