Nmap Development mailing list archives

Re: [NSE] new scripts and libraries: brute library


From: David Fifield <david () bamsoftware com>
Date: Wed, 11 Aug 2010 20:20:11 -0600

On Wed, Aug 11, 2010 at 08:16:46PM -0600, David Fifield wrote:
description = ""
categories = {}

require("brute")
require("stdnse")

function portrule(host, port)
  return port.number == 4000
end

local brute_driver = {
  new = function(self, host, port)
    local o = {}
    setmetatable(o, self)
    self.__index = self
    o.host = host
    o.port = port
    return o
  end,
  connect = function(self)
    self.socket = nmap.new_socket()
    return self.socket:connect(self.host.ip, self.port.number, "tcp")
  end,
  disconnect = function(self)
    return self.socket:close()
  end,
  check = function(self)
    return true
  end,
  login = function(self, username, password)
    local status, err, reply
    status, err = self.socket:send(username .. ":" .. password .. "\n")
    if not status then
      -- What?
    end
    status, reply = self.socket:receive_bytes(1)
    if not status then
      -- What?
    end
    if reply == "YES\n" then
      return true, brute.Account:new(username, password, "OPEN")
    else
      return false, brute.Error:new("login failed")
    end
  end
}

function action(host, port)
  local status, accounts
  status, accounts = brute.Engine:new(brute_driver, host, port):start()
  if not status then
    return accounts
  else
    return stdnse.format_output(true, accounts)
  end
end

This is a question for Ithilgore and Ron, mainly. How does this model
(connect/disconnect/check/login) compare to what you created for Ncrack
and smb-brute?

I know that Ncrack in particular is designed to support several
different protocols within a uniform framework.

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: