From 2a5b4641588f1a7608d9f3bd43986723b8e894f3 Mon Sep 17 00:00:00 2001 From: dmiller Date: Fri, 28 Jul 2017 04:03:57 +0000 Subject: [PATCH] Small cleanup for irc-info.nse --- scripts/irc-info.nse | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/scripts/irc-info.nse b/scripts/irc-info.nse index 754dfd92e..1f75b38ac 100644 --- a/scripts/irc-info.nse +++ b/scripts/irc-info.nse @@ -1,5 +1,6 @@ local comm = require "comm" local nmap = require "nmap" +local math = require "math" local irc = require "irc" local stdnse = require "stdnse" @@ -52,17 +53,15 @@ local function random_nick () end function action (host, port) - local sd = nmap.new_socket() local nick = random_nick() local output = stdnse.output_table() - local sd, line = comm.tryssl(host, port, "USER nmap +iw nmap :Nmap Wuz Here\nNICK " .. nick .. "\n") + local sd, line = comm.tryssl(host, port, + ("USER nmap +iw nmap :Nmap Wuz Here\nNICK %s\n"):format(nick), + {request_timeout=6000}) if not sd then return "Unable to open connection" end - -- set a healthy banner timeout - sd:set_timeout(banner_timeout * 1000) - local buf = stdnse.make_buffer(sd, "\r?\n") while line do @@ -90,12 +89,6 @@ function action (host, port) sd:send("NICK " .. nick .. "\n") end - info = line:match "^:([%w-_.]+) 433" - if info then - nick = random_nick() - sd:send("NICK " .. nick .. "\n") - end - -- PING/PONG local dummy = line:match "^PING :(.*)" if dummy then @@ -111,7 +104,7 @@ function action (host, port) -- Various bits of info local users, invisible, servers = line:match "^:[%w-_.]+ 251 %w+ :There are (%d+) users and (%d+) invisible on (%d+) servers" if users then - output.users = users + invisible + output.users = math.tointeger(users + invisible) output.servers = servers end