Fixed path-event filter
All checks were successful
Build / Build NPM Project (push) Successful in 39s
Build / Tag Version (push) Successful in 8s
Build / Publish Documentation (push) Successful in 36s

This commit is contained in:
Zakary Timson 2024-12-27 22:20:27 -05:00
parent 3bda688b1e
commit cb117273a7
3 changed files with 6 additions and 26 deletions

View File

@ -6,31 +6,11 @@
</head> </head>
<body> <body>
<script type="module"> <script type="module">
import {ArgParser} from './dist/index.mjs'; import {PES, PathEvent} from './dist/index.mjs';
const perm = PES`storage/test/john-flag.png:r`;
const perms = [ 'logs/Momentum:c', 'storage/test:r', 'data/Repos:r', 'email:c' ];
const hostname = 'test'; console.log(PathEvent.filter(perms, perm));
const argParser = new ArgParser('botnet-manager.js', 'Connect & manage a network of servers to launch distributed attacks.', [
new ArgParser('copy', 'Copy file & dependencies to botnet', [
{name: 'file', desc: 'File to copy', default: false},
{name: 'control', desc: 'Copy to master server', flags: ['-c', '--control'], default: false},
{name: 'noDeps', desc: 'Skip copying dependencies', flags: ['-d', '--no-deps'], default: false},
{name: 'slave', desc: 'Copy to slave servers', flags: ['-s', '--slave'], default: false},
]),
new ArgParser('join', 'Connect server as a botnet slave', [
{name: 'device', desc: 'Device to connect, defaults to the current machine', optional: true, default: hostname}
]),
new ArgParser('kill', 'Kill any scripts running on the botnet'),
new ArgParser('leave', 'Disconnect worker node from swarm', [
{name: 'device', desc: 'Device to disconnect, defaults to the current machine', optional: true, default: hostname}
]),
new ArgParser('run', 'Copy & run script on the botnet', [
{name: 'script', desc: 'Script to copy & execute', type: 'string'},
{name: 'args', desc: 'Arguments for script. Forward the current target with: {{TARGET}}', optional: true, extras: true},
]),
new ArgParser('start', 'Start this server as the botnet manager'),
{name: 'silent', desc: 'Suppress program output', flags: ['-s', '--silent'], default: false},
]);
console.log(argParser.help({}));
</script> </script>
</body> </body>
</html> </html>

View File

@ -1,6 +1,6 @@
{ {
"name": "@ztimson/utils", "name": "@ztimson/utils",
"version": "0.23.6", "version": "0.23.7",
"description": "Utility library", "description": "Utility library",
"author": "Zak Timson", "author": "Zak Timson",
"license": "MIT", "license": "MIT",

View File

@ -142,7 +142,7 @@ export class PathEvent {
const parsedFind = makeArray(filter).map(pe => new PathEvent(pe)); const parsedFind = makeArray(filter).map(pe => new PathEvent(pe));
return parsedTarget.filter(t => { return parsedTarget.filter(t => {
if(!t.fullPath && t.all) return true; if(!t.fullPath && t.all) return true;
return !!parsedFind.find(f => t.fullPath.startsWith(f.fullPath) return !!parsedFind.find(f => f.fullPath.startsWith(t.fullPath)
&& (f.all || t.all || t.methods.intersection(f.methods).length)); && (f.all || t.all || t.methods.intersection(f.methods).length));
}); });
} }