Skip to content

Instantly share code, notes, and snippets.

@AvasDream
Last active September 7, 2022 20:59
Show Gist options
  • Save AvasDream/386de32ca0ecfb3726a0ae69e7b2ca3a to your computer and use it in GitHub Desktop.
Save AvasDream/386de32ca0ecfb3726a0ae69e7b2ca3a to your computer and use it in GitHub Desktop.
Config file usage preview

Module options

single-hardcoded.yaml

Command:

root@2badad6374c1:/minerva# minerva squad-execute -m definitions/execution/single-hardcoded.yaml -p marion
[+] Executed command 'echo hello $(date) && echo world' on marion7
hello Sun Feb 7 11:57:09 UTC 2021
world

Module definitions/execution/single-hardcoded.yaml

strategy: single
output:
  type: cli
command:
  raw: echo hello $(date) && echo world
  type: hardcoded

single-dynamic.yaml

Command:

root@2badad6374c1:/minerva# minerva squad-execute -m definitions/execution/single-dynamic.yaml -p marion -i "'I am argument one ' 'I am argument \$(echo two)'"
[+] Executed command 'echo I am argument one  $(date) && echo I am argument $(echo two)' on marion5
I am argument one Sun Feb 7 12:02:10 UTC 2021
I am argument two

47.65 Mb

Module definitions/execution/single-dynamic.yaml

strategy: single
output:
  type: cli
command:
  raw: echo $1 $(date) && echo $2
  type: dynamic

single-hardcoded-upload-hardcoded.yaml

Command:

root@2badad6374c1:/minerva# minerva squad-execute -m definitions/execution/single-hardcoded-upload-hardcoded.yaml -p marion 
[+] Executed command 'for i in $(cat hello.txt); do echo $i;done;' on marion0
hello
world
I
am
a
test
file

Module definitions/execution/single-hardcoded-upload-hardcoded.yaml

strategy: single
output:
  type: cli
command:
  raw: for i in $(cat hello.txt); do echo $i;done;
  type: hardcoded
uploads:
  - type: hardcoded
    source: test.txt
    destination: hello.txt

single-dynamic-upload-hardcoded.yaml

Command

root@2badad6374c1:/minerva# minerva squad-execute -m definitions/execution/single-dynamic-upload-hardcoded.yaml -p marion -i "'Argument one'"
[+] Executed command 'for i in $(cat hello.txt); do echo $i;echo Argument one;done;' on marion6
hello
Argument one
world
Argument one
I
Argument one
am
Argument one
a
Argument one
test
Argument one
file
Argument one

Module definitions/execution/single-dynamic-upload-hardcoded.yaml

strategy: single
output:
  type: cli
command:
  raw: for i in $(cat hello.txt); do echo $i;echo $1;done;
  type: dynamic
uploads:
  - type: hardcoded
    source: test.txt
    destination: hello.txt

single-dynamic-upload-dynamic.yaml

Command

root@2badad6374c1:/minerva# minerva squad-execute -m definitions/execution/single-dynamic-upload-dynamic.yaml -p marion -i "'argument-one'" -f "'test.txt' 'test2.txt'"
[+] Executed command 'for i in $(cat hello.txt); do echo $i;echo argument-one;done; cat hello2.txt' on marion2
hello
argument-one
world
argument-one
I
argument-one
am
argument-one
a
argument-one
test
argument-one
file
argument-one
hello
world
I
am
a 
test 
file

Module definitions/execution/single-dynamic-upload-dynamic.yaml

strategy: single
output:
  type: cli
command:
  raw: for i in $(cat hello.txt); do echo $i;echo $1;done; cat hello2.txt
  type: dynamic
uploads:
  - type: dynamic
    source: $1
    destination: hello.txt
  - type: dynamic
    source: $2
    destination: hello2.txt

Multi Execution Dynamic command Dynamic Files

Command

root@4fb58d13b8dc:/minerva# minerva module -p marion -m definitions/execution/multi-dynamic-upload-dynamic.yaml -f "'data/test.txt''data/test2.txt'" -i "'argument_one'"
[+] Executed command 'for i in $(cat hello.txt); do echo $i;echo argument_one;done; cat hello2.txt' on marion0
hello
argument_one
world
argument_one
I
argument_one
am
argument_one
a
argument_one
test
argument_one
file
argument_one
hello
world
I
am
a 
test 
file

[+] Executed command 'for i in $(cat hello.txt); do echo $i;echo argument_one;done; cat hello2.txt' on marion3
hello
argument_one
world
argument_one
I
argument_one
am
argument_one
a
argument_one
test
argument_one
file
argument_one
hello
world
I
am
a 
test 
file

....

Module

strategy: multi
output:
  type: cli
command:
  raw: for i in $(cat hello.txt); do echo $i;echo $1;done; cat hello2.txt
  type: dynamic
uploads:
  - type: dynamic
    strategy: upload_to_all
    source: $1
    destination: hello.txt
  - type: dynamic
    strategy: upload_to_all
    source: $2
    destination: hello2.txt
  

Split file and distribute

  • Split a file in equal parts per worker and execute commands which contain the splitted files
  • Only one splitted file currently supported

Command:

root@4fb58d13b8dc:/minerva# minerva module -p marion -m definitions/execution/multi-dynamic-upload-hardcoded-split.yaml -i "'argument_one'"
[+] Executed command 'for i in $(cat tmp_out0.txt); do echo $i-argument_one;done;' on marion0
dsdsd

[+] Executed command 'for i in $(cat tmp_out1.txt); do echo $i-argument_one;done;' on marion3
dsdsd

[+] Executed command 'for i in $(cat tmp_out2.txt); do echo $i-argument_one;done;' on marion2
dsdsd

[+] Executed command 'for i in $(cat tmp_out3.txt); do echo $i-argument_one;done;' on marion1
dsds

Module:

  • $file is replaced with the name of the splitted file on the specific instance.
strategy: multi
output:
  type: cli
command:
  raw: for i in $(cat $file); do echo $i-$1;done;
  type: dynamic
uploads:
  - type: hardcoded
    strategy: split
    source: data/subfinder.txt

Real world examples

Subfinder

Command

root@8f0ceb536f83:/minerva# minerva module -p marion -m definitions/execution/subfinder.yaml -i "'aa.ch'" 
[+] Saved output to data/subfinder_12.02.2021-17:02_aaa.txt

Module

Note: the $date marker resolves to the current date in the filename. $1 is the first argument supplied in the command line

name: subfinder
strategy: single
output:
  type: file
  path: data/subfinder_$date_$1.txt
command:
  raw: docker run --rm avasdream/subfinder:minerva $1
  type: dynamic

Module restrictions and assumptions:

  • The config file is valid.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment