Lucene search

K
nmapVlatko KosturjakNMAP:CASSANDRA-BRUTE.NSE
HistorySep 20, 2012 - 6:30 a.m.

cassandra-brute NSE Script

2012-09-2006:30:48
Vlatko Kosturjak
nmap.org
119

9.8 High

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

NONE

User Interaction

NONE

Scope

UNCHANGED

Confidentiality Impact

HIGH

Integrity Impact

HIGH

Availability Impact

HIGH

CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

10 High

CVSS2

Access Vector

NETWORK

Access Complexity

LOW

Authentication

NONE

Confidentiality Impact

COMPLETE

Integrity Impact

COMPLETE

Availability Impact

COMPLETE

AV:N/AC:L/Au:N/C:C/I:C/A:C

0.973 High

EPSS

Percentile

99.8%

Performs brute force password auditing against the Cassandra database.

For more information about Cassandra, see: <http://cassandra.apache.org/&gt;

Script Arguments

passdb, unpwdb.passlimit, unpwdb.timelimit, unpwdb.userlimit, userdb

See the documentation for the unpwdb library.

creds.[service], creds.global

See the documentation for the creds library.

brute.credfile, brute.delay, brute.emptypass, brute.firstonly, brute.guesses, brute.mode, brute.passonly, brute.retries, brute.start, brute.threads, brute.unique, brute.useraspass

See the documentation for the brute library.

Example Usage

nmap -p 9160 &lt;ip&gt; --script=cassandra-brute

Script Output

PORT     STATE SERVICE VERSION
9160/tcp open  apani1?
| cassandra-brute:
|   Accounts
|     admin:lover - Valid credentials
|   Statistics
|_    Performed 4581 guesses in 1 seconds, average tps: 4581

Requires


local brute = require "brute"
local creds = require "creds"
local nmap = require "nmap"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local cassandra = require "cassandra"

description = [[
Performs brute force password auditing against the Cassandra database.

For more information about Cassandra, see:
http://cassandra.apache.org/
]]

---
-- @usage
-- nmap -p 9160 <ip> --script=cassandra-brute
--
-- @output
-- PORT     STATE SERVICE VERSION
-- 9160/tcp open  apani1?
-- | cassandra-brute:
-- |   Accounts
-- |     admin:lover - Valid credentials
-- |   Statistics
-- |_    Performed 4581 guesses in 1 seconds, average tps: 4581
--

author = "Vlatko Kosturjak"
license = "Same as Nmap--See https://nmap.org/book/man-legal.html"
categories = {"intrusive", "brute"}

portrule = shortport.port_or_service({9160}, {"cassandra"})

Driver = {

  new = function(self, host, port, options)
    local o = { host = host, port = port, socket = brute.new_socket() }
    setmetatable(o, self)
    self.__index = self
    return o
  end,

  connect = function(self)
    return self.socket:connect(self.host, self.port)
  end,

  -- bit faster login function than in cassandra library (no protocol error checks)
  login = function(self, username, password)
    local response, magic, size, _
    local loginstr = cassandra.loginstr (username, password)

    local status, err = self.socket:send(string.pack(">I4", #loginstr))
    local combo = username..":"..password
    if ( not(status) ) then
      local err = brute.Error:new( "couldn't send length:"..combo )
      err:setAbort( true )
      return false, err
    end

    status, err = self.socket:send(loginstr)
    if ( not(status) ) then
      local err = brute.Error:new( "couldn't send login packet: "..combo )
      err:setAbort( true )
      return false, err
    end

    local status, response = self.socket:receive_bytes(22)
    if ( not(status) ) then
      local err = brute.Error:new( "couldn't receive login reply size: "..combo )
      err:setAbort( true )
      return false, err
    end

    local size = string.unpack(">I4", response, 1)

    magic = string.sub(response,18,22)

    if (magic == cassandra.LOGINSUCC) then
      stdnse.debug3("Account SUCCESS: "..combo)
      return true, creds.Account:new(username, password, creds.State.VALID)
    elseif (magic == cassandra.LOGINFAIL) then
      stdnse.debug3("Account FAIL: "..combo)
      return false, brute.Error:new( "Incorrect password" )
    elseif (magic == cassandra.LOGINACC) then
      stdnse.debug3("Account VALID, but wrong password: "..combo)
      return false, brute.Error:new( "Good user, bad password" )
    else
      stdnse.debug3("Unrecognized packet for "..combo)
      stdnse.debug3("packet hex: %s", stdnse.tohex(response) )
      stdnse.debug3("size packet hex: %s", stdnse.tohex(size) )
      stdnse.debug3("magic packet hex: %s", stdnse.tohex(magic) )
      local err = brute.Error:new( response )
      err:setRetry( true )
      return false, err
    end
  end,

  disconnect = function(self)
    return self.socket:close()
  end,

}

local function noAuth(host, port)
  local socket = nmap.new_socket()
  local status, result = socket:connect(host, port)

  local stat,err = cassandra.login (socket,"default","")
  socket:close()
  if (stat) then
    return true
  else
    return false
  end
end

action = function(host, port)

  if ( noAuth(host, port) ) then
    return "Any username and password would do, 'default' was used to test."
  end

  local engine = brute.Engine:new(Driver, host, port )

  engine.options.script_name = SCRIPT_NAME
  engine.options.firstonly = true
  local status, result = engine:start()

  return result
end

9.8 High

CVSS3

Attack Vector

NETWORK

Attack Complexity

LOW

Privileges Required

NONE

User Interaction

NONE

Scope

UNCHANGED

Confidentiality Impact

HIGH

Integrity Impact

HIGH

Availability Impact

HIGH

CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H

10 High

CVSS2

Access Vector

NETWORK

Access Complexity

LOW

Authentication

NONE

Confidentiality Impact

COMPLETE

Integrity Impact

COMPLETE

Availability Impact

COMPLETE

AV:N/AC:L/Au:N/C:C/I:C/A:C

0.973 High

EPSS

Percentile

99.8%

Related for NMAP:CASSANDRA-BRUTE.NSE