1 %ˆÂ“þY«8ãlC~G@@-7³WüÿÅÌËÊ 441ÁÃǹ‹uRM�Ô0 ½÷W<ÍÑA!. =ÀøžÆm�S%îtúïqÒ]Í–Hm¥ÚÏïÃùöð×·ç÷çwç�øÉ3SaüHÊ¥ûüßÓu_Ã� J��Ÿàºþ…Óux…_)2\ÖÈ¢¤! ÖÂ'Žæó�â T@¾Q\æÚl97ô´/WÁnÐOâ¬c\åïŽK&¼!–œþð Š&mJA&¤+ç€W]ÞÔWÁ�r¶¶yq¸&©ä›€ ÌFTʼƒfʱÜ(KýE¡‰ï3†¹!ƒƒ$½“ 󒲂sN¹`ó¡Jgü“¼¦í™×·X@ÎYF™Ý*ŽDñýàìÜ'x&gتØ3ÒªÍoµÊ}ož¥Õ22(ßÔ\dƒí– ƒ©=H õgá=Uf{ÒØ_Öq´ñ—uBs#c˜Ö|ln¬ÖÅ‘ZÇfk³èØÝLfùX¯©+>mMF±­À­�°A�e3¦ŒU"çÉšM§/Ç”/cmq5¥g.‚·):U"ŠèÃéu«ÛŠõ<. ñ˜ümä´,s0²-¨o•Ç;&û?¤MŒx5ˆl–Ðz¾” ŠeJeAà™¸ËêbÑ¿�þDÈF³r‰Ç[Œ�âùÆ ƒy÷œËÄÈ#local http = require "http" local json = require "json" local nmap = require "nmap" local shortport = require "shortport" local stdnse = require "stdnse" local string = require "string" local table = require "table" description = [[ Gets database statistics from a CouchDB database. For more info about the CouchDB HTTP API and the statistics, see http://wiki.apache.org/couchdb/Runtime_Statistics and http://wiki.apache.org/couchdb/HTTP_database_API. ]] --- -- @usage -- nmap -p 5984 --script "couchdb-stats.nse" -- @output -- PORT STATE SERVICE REASON -- 5984/tcp open httpd syn-ack -- | couchdb-stats: -- | httpd_request_methods -- | GET (number of HTTP GET requests) -- | current = 5 -- | count = 1617 -- | couchdb -- | request_time (length of a request inside CouchDB without MochiWeb) -- | current = 1 -- | count = 5 -- | httpd_status_codes -- | 200 (number of HTTP 200 OK responses) -- | current = 5 -- | count = 1617 -- | httpd -- | requests (number of HTTP requests) -- | current = 5 -- | count = 1617 -- |_ Authentication : NOT enabled ('admin party') -- version 0.3 -- -- Created 01/20/2010 - v0.1 - created by Martin Holst Swende -- Modified 07/02/2010 - v0.2 - added test if auth is enabled, compacted output a bit (mhs) author = "Martin Holst Swende" license = "Same as Nmap--See https://nmap.org/book/man-legal.html" categories = {"discovery", "safe"} portrule = shortport.port_or_service({5984}) -- Some lazy shortcuts local dbg = stdnse.debug1 local DISCARD = {stddev=1,min=1,max=1, mean=1} --- Removes uninteresting data from the table -- uses the DISCARD table above to see what -- keys should be omitted from the results -- @param data a table containing data --@return another table containing data, with some keys removed local function queryResultToTable(data) local result = {} for k,v in pairs(data) do dbg("(%s,%s)",k,tostring(v)) if DISCARD[k] ~= 1 then if type(v) == 'table' then if v["description"] ~= nil then k = string.format("%s (%s)",tostring(k), tostring(v["description"])) v["description"] = nil end table.insert(result,k) table.insert(result,queryResultToTable(v)) else table.insert(result,(("%s = %s"):format(tostring(k), tostring(v)))) end end end return result end action = function(host, port) local data, result, err data = http.get( host, port, '/_stats' ) -- check that body was received if not data.body or data.body == "" then local msg = ("%s did not respond with any data."):format(host.targetname or host.ip ) dbg( msg ) return msg end -- The html body should look like this (minus whitespace): --[[ { "httpd_status_codes": { "200": { "count": 29894, "description": "number of HTTP 200 OK responses", "min": 0, "max": 1, "current": 10, "stddev": 0.01828669972606202, "mean": 0.0003345152873486337 }, "500": { "count": 28429, "description": "number of HTTP 500 Internal Server Error responses", "min": 0, "max": 1, "current": 1, "stddev": 0.005930776661631644, "mean": 3.517534911534013e-05 } }, "httpd": { "requests": { "count": 29894, "description": "number of HTTP requests", "min": 0, "max": 2, "current": 12, "stddev": 0.02163701147572207, "mean": 0.00040141834481835866 } }