exitmap icon indicating copy to clipboard operation
exitmap copied to clipboard

Make modules parameterised

Open NullHypothesis opened this issue 10 years ago • 7 comments

It should be possible to pass parameters to modules. For example, the DNS module could then be invoked with custom domains and their according IP addresses:

exitmap dns -d www.example.com 1.2.3.4

NullHypothesis avatar Feb 25 '15 15:02 NullHypothesis

I'd like to take a crack at this; any suggestions/starting point/hints?

s4chin avatar Mar 08 '16 15:03 s4chin

Python's argparse module allows sub commands, which is probably what we need here: https://docs.python.org/2.7/library/argparse.html#sub-commands

The idea is that modules can define their own sub commands that are then loaded by the main argument parsing code. That's all I have, unfortunately, so you will have to experiment a bit.

NullHypothesis avatar Mar 08 '16 22:03 NullHypothesis

I've run into a problem here. As I understand, this is what the call should look like for parameterised modules(just an example):

./bin/exitmap --first-hop CCEF02AA454C0AB0FE1AC68304F6D8C4220C1912 dns -d www.example.com 1.2.3.4 www.foobar.com 11.22.33.44 checktest

As we want to take multiple values for -d, i.e. multiple custom domains and IP addresses for dns, it takes checktest as a parameter for -d, which is a problem. There is probably no elegant way to do this in the exitmap.py itself using subparsers. It will have to be done like this: ./bin/exitmap dns -d www.example.com 1.2.3.4 www.foo.com 5.6.7.8 -- checktest or by calling the script twice

./bin/exitmap dns -d www.example.com 1.2.3.4 www.foo.com 5.6.7.8
./bin/exitmap checktest

Plus, I then have to name all modules while writing the sub-parsers, and thus the parser will need to be modified every time a module is to be added or deleted. A solution I can think of can be to parse the command-line arguments to the modules in the module itself, i.e. parse_known_args() in exitmap.py, and parse the remaining_argv in their respective modules. What do you think?

s4chin avatar Mar 10 '16 04:03 s4chin

Could you give here a list parameters to the modules? So far you have given only an example and I would like to know the parameters to be able to code them.

s4chin avatar Apr 10 '16 17:04 s4chin

For the DNS module, I think we would certainly like a destination argument. That would also come in handy for the cloudflared module. We could also create an argument for the patchingCheck module, to instruct it to download arbitrary files.

It would be great if we could take the current values as default values, if no module argument is given.

NullHypothesis avatar Apr 11 '16 04:04 NullHypothesis

Can I proceed on this using optparse?

avhvr-zz avatar Dec 20 '17 16:12 avhvr-zz

Can I proceed on this using optparse?

Feel free to give it a shot!

NullHypothesis avatar Dec 21 '17 19:12 NullHypothesis