nmap-completion
nmap-completion copied to clipboard
Closes issue #1
In PR #3 , we were parsing a file every time when the user tries to autocomplete --script-args command, it is very ineffective as we have to access the file frequently, the reason why we can't use this approach is well explained in PR #3 . I developed a new code which doesn't waste its time on I/O operations and instead the new code is directly connected to the kernel.
Working of my code
The script-args.db
file is a db file which contains all the available --script-args options along with script-name.
- Create this folder
$NMAPDIR/scripts/script-args/
which will be storing all the files required by the autocomplete feature. -
script-args.db
is located in"$NMAPDIR/scripts/script-args/script-args.db"
. - Execute the script.sh script.
On executing the above script, it parses the
script-args.db
and creates empty directories for all scripts which are present inscript-args.db
file. The empty directories are created insidescripts/script-args/
folder and name of these empty folders is same as the name of the available scripts.Each folder also contains empty files named with the options available for that script.
Let me illustrate this with an example. Assume there are only two lines in the script-args.db file
$ cat script-args.db
acarsd-info: acarsd-info.timeout acarsd-info.bytes
ajp-auth: ajp-auth.path
Format of the script-args file is as follows,
<scriptname>: <arg1> <arg2> <arg3> ....
On executing the script.sh file, it extracts the script-name and the available options for every script. So the directory structure would be something like this,
|- acarsd-info/
|- acarsd-info.timeout
|- acarsd-info.bytes
|- ajp-auth/
|- ajp-auth.path
So, here I'm using the name of the files to autocomplete --script-args . This is a way faster than the previous method as there are no I/O operations involved and it is directly associated with the kernel itself.