From 01f3eba28242b901df2a1c8816a159b721f996fb Mon Sep 17 00:00:00 2001 From: david Date: Thu, 8 Mar 2012 21:21:48 +0000 Subject: [PATCH] Make an iterator to read the data file in http-wordpress-plugins. --- scripts/http-wordpress-plugins.nse | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/http-wordpress-plugins.nse b/scripts/http-wordpress-plugins.nse index e893f2300..b7e53c0c1 100644 --- a/scripts/http-wordpress-plugins.nse +++ b/scripts/http-wordpress-plugins.nse @@ -47,6 +47,13 @@ local DEFAULT_PLUGINS_SEARCH = 100 portrule = shortport.service("http") +local function read_data_file(file) + return coroutine.wrap(function() + for line in file:lines(file) do + coroutine.yield(line) + end + end) +end action = function(host, port) @@ -104,12 +111,7 @@ action = function(host, port) --build a table of both directories to brute force and the corresponding WP plugins' name local plugin_count = 0 - while true do - local line = file:read() - if not line then - break - end - + for line in read_data_file(file) do if plugins_search and plugin_count >= plugins_search then break end