Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vladpuz/sandboxie-js
Sandboxie CLI client
https://github.com/vladpuz/sandboxie-js
cli client sandboxie
Last synced: 16 days ago
JSON representation
Sandboxie CLI client
- Host: GitHub
- URL: https://github.com/vladpuz/sandboxie-js
- Owner: vladpuz
- Created: 2022-12-24T11:01:46.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-06-18T12:35:29.000Z (over 1 year ago)
- Last Synced: 2024-10-14T11:04:19.342Z (about 1 month ago)
- Topics: cli, client, sandboxie
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/sandboxie-js
- Size: 390 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# sandboxie-js
Sandboxie CLI client for automated sandbox management. Internally it works with `Sandboxie.ini` and `Start.exe`.
You can check out the official documentation here:
- [Sandboxie.ini](https://github.com/sandboxie-plus/sandboxie-docs/blob/main/Content/SandboxieIni.md)
- [Start.exe](https://github.com/sandboxie-plus/sandboxie-docs/blob/main/Content/StartCommandLine.md)TypeDoc documentation is available on [wiki](https://github.com/vladislav-puzyrev/proxy-string-parser/wiki).
## Requirements
Running [Sandboxie](https://github.com/sandboxie-plus/Sandboxie/releases/latest) in the system. Allowed installed
or portable versions of `Plus` and `Classic`.## Install
```bash
npm install sandboxie-js
```## Usage
```javascript
import Sandboxie from 'sandboxie-js'// Sandboxie constructor accepts optional SandboxieOptions object
// Default values are shown below
const sandboxie = new Sandboxie({
delay: 2000,
classic: false,
portable: false,
clientPath: this.classic ? 'C:/Program Files/Sandboxie' : 'C:/Program Files/Sandboxie-Plus',
configPath: this.portable ? `${this.clientPath}/Sandboxie.ini` : 'C:/Windows/Sandboxie.ini'
})const name = 'TestBox'
const names = Array.from(new Array(5), (item, i) => `TestBox${i + 1}`)
const program = ['/hide_window', 'C:/Windows/System32/notepad.exe']
const settings = `
Enabled=y
BlockNetworkFiles=y
RecoverFolder=%{374DE290-123F-4565-9164-39C4925E467B}%
RecoverFolder=%Personal%
RecoverFolder=%Desktop%
BorderColor=#00FFFF,ttl
Template=OpenBluetooth
Template=SkipHook
Template=FileCopy
Template=qWave
Template=BlockPorts
Template=LingerPrograms
Template=AutoRecoverIgnore
ConfigLevel=9
`// Create sandbox(es)
await sandboxie.create(name, settings)
await sandboxie.createMany(names.map((name) => ({ name, settings })))// List of sandboxes
const sandboxes = await sandboxie.sandboxes()
console.log(sandboxes)// Run the program(s) in the sandbox(es)
await sandboxie.start(name, program)
await sandboxie.startMany(names.map((name) => ({ name, program })))// List of pids
const pids = await sandboxie.pids(name)
console.log(pids)// Stop the program(s) in the sandbox(es)
await sandboxie.stop(name)
await sandboxie.stopAll()// Delete sandbox(es)
await sandboxie.remove(name)
await sandboxie.removeAll()// Manual reload of Sandboxie.ini
// Automatically called inside create(Many) and remove(All)
await sandboxie.reload()
```## Caveats
### Race condition
For some reason, executing the `remove(All)` and `stop(All)` methods without delay causes Sandboxie errors and crashes,
so inside these methods `setTimeout` is used with `delay: 2000` by default.You can remove the delay by setting the `delay: 0` property, or increase it when errors occur.
This is most likely due to the fact that `Start.exe` passes the request to the `SbieSvc.exe` service and returns control
not waiting for his work to finish.### Parallelization
Do not execute the `create(Many)` and `remove(All)` methods in parallel using `Promise.all()`. They work
with `Sandboxie.ini` and this can lead to an error in writing to the `EBUSY` file at the same time.