From 5ea6fe675da4a07840f302e4fa800657ea5b9e17 Mon Sep 17 00:00:00 2001 From: djalal Date: Wed, 9 Nov 2011 12:31:48 +0000 Subject: [PATCH] o [NSE] check script arguments in the prerule to avoid running the script if they are missing. --- scripts/bittorrent-discovery.nse | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/bittorrent-discovery.nse b/scripts/bittorrent-discovery.nse index b8abc1ead..4b223f640 100755 --- a/scripts/bittorrent-discovery.nse +++ b/scripts/bittorrent-discovery.nse @@ -44,7 +44,14 @@ require "stdnse" require "target" prerule = function() - return true + if not stdnse.get_script_args(SCRIPT_NAME..".torrent") and + not stdnse.get_script_args(SCRIPT_NAME..".magnet") then + stdnse.print_debug(3, + "Skipping '%s' %s, No magnet link or torrent file arguments.", + SCRIPT_NAME, SCRIPT_TYPE) + return false + end + return true end action = function() @@ -53,10 +60,6 @@ action = function() local magnet = stdnse.get_script_args(SCRIPT_NAME..".magnet") local include_nodes = stdnse.get_script_args(SCRIPT_NAME..".include-nodes") - if not (magnet or filename) then - stdnse.print_debug(SCRIPT_NAME.." not running. No magnet link or torrent file specified") - return - end t = bittorrent.Torrent:new() if filename then t:load_from_file(filename) @@ -126,4 +129,3 @@ action = function() return stdnse.format_output( print_out , output) end -