PATH:
usr
/
share
/
nmap
/
nselib
--- A minimalistic Redis (in-memory key-value data store) library. -- -- @author "Patrik Karlsson <patrik@cqure.net>" local match = require "match" local nmap = require "nmap" local stdnse = require "stdnse" local table = require "table" _ENV = stdnse.module("redis", stdnse.seeall) Request = { new = function(self, cmd, ...) local o = { cmd = cmd, args = {...} } setmetatable (o,self) self.__index = self return o end, __tostring = function(self) local output = ("*%s\r\n$%d\r\n%s\r\n"):format(#self.args + 1, #self.cmd, self.cmd) for _, arg in ipairs(self.args) do arg = tostring(arg) output = output .. ("$%s\r\n%s\r\n"):format(#arg, arg) end return output end } Response = { Type = { STATUS = 0, ERROR = 1, INTEGER = 2, BULK = 3, MULTIBULK = 4, }, new = function(self, socket) local o = { socket = socket } setmetatable (o,self) self.__index = self return o end, receive = function(self) local status, data = self.socket:receive_buf("\r\n", false) if ( not(status) ) then return false, "Failed to receive data from server" end -- if we have a status, integer or error message if ( data:match("^[%-%+%:]") ) then local response = { data = data } local t = data:match("^([-+:])") if ( t == "-" ) then response.type = Response.Type.ERROR elseif ( t == "+" ) then response.type = Response.Type.STATUS elseif ( t == ":" ) then response.type = Response.Type.INTEGER end return true, response end -- process bulk reply if ( data:match("^%$") ) then -- non existing key if ( data == "$-1" ) then return true, nil end local len = tonumber(data:match("^%$(%d*)")) -- we should only have a single line, so we can just peel of the length status, data = self.socket:receive_buf(match.numbytes(len), false) if( not(status) ) then return false, "Failed to receive data from server" end return true, { data = data, type = Response.Type.BULK } end -- process multi-bulk reply if ( data:match("^%*%d*") ) then local count = data:match("^%*(%d*)") local results = {} for i=1, count do -- peel of the length local status = self.socket:receive_buf("\r\n", false) if( not(status) ) then return false, "Failed to receive data from server" end status, data = self.socket:receive_buf("\r\n", false) if( not(status) ) then return false, "Failed to receive data from server" end table.insert(results, data) end return true, { data = results, type = Response.Type.MULTIBULK } end return false, "Unsupported response" end, } Helper = { new = function(self, host, port) local o = { host = host, port = port } setmetatable (o,self) self.__index = self return o end, connect = function(self) self.socket = nmap.new_socket() return self.socket:connect(self.host, self.port) end, reqCmd = function(self, cmd, ...) local req = Request:new(cmd, ...) local status, err = self.socket:send(tostring(req)) if (not(status)) then return false, "Failed to send command to server" end return Response:new(self.socket):receive() end, close = function(self) return self.socket:close() end } return _ENV;
[-] iscsi.lua
[edit]
[-] httpspider.lua
[edit]
[-] rmi.lua
[edit]
[-] socks.lua
[edit]
[-] dhcp6.lua
[edit]
[-] sasl.lua
[edit]
[-] drda.lua
[edit]
[+]
data
[-] dhcp.lua
[edit]
[-] omp2.lua
[edit]
[-] ospf.lua
[edit]
[-] ipp.lua
[edit]
[-] pop3.lua
[edit]
[-] netbios.lua
[edit]
[-] pgsql.lua
[edit]
[-] packet.lua
[edit]
[-] rpc.lua
[edit]
[-] xdmcp.lua
[edit]
[-] msrpc.lua
[edit]
[+]
..
[-] eigrp.lua
[edit]
[-] giop.lua
[edit]
[-] afp.lua
[edit]
[-] bjnp.lua
[edit]
[-] match.lua
[edit]
[-] iax2.lua
[edit]
[-] smtp.lua
[edit]
[-] msrpctypes.lua
[edit]
[-] cvs.lua
[edit]
[-] natpmp.lua
[edit]
[-] bitcoin.lua
[edit]
[-] snmp.lua
[edit]
[-] rsync.lua
[edit]
[-] mssql.lua
[edit]
[-] base64.lua
[edit]
[-] ncp.lua
[edit]
[-] base32.lua
[edit]
[-] sip.lua
[edit]
[-] http.lua
[edit]
[-] asn1.lua
[edit]
[-] stun.lua
[edit]
[-] citrixxml.lua
[edit]
[-] nrpc.lua
[edit]
[-] proxy.lua
[edit]
[-] pppoe.lua
[edit]
[-] amqp.lua
[edit]
[-] dns.lua
[edit]
[-] informix.lua
[edit]
[-] tftp.lua
[edit]
[-] sslcert.lua
[edit]
[-] strbuf.lua
[edit]
[-] unpwdb.lua
[edit]
[-] strict.lua
[edit]
[-] vulns.lua
[edit]
[-] jdwp.lua
[edit]
[-] stdnse.lua
[edit]
[-] dnssd.lua
[edit]
[-] mysql.lua
[edit]
[-] rdp.lua
[edit]
[-] mongodb.lua
[edit]
[-] ndmp.lua
[edit]
[-] isns.lua
[edit]
[-] ldap.lua
[edit]
[-] creds.lua
[edit]
[-] tab.lua
[edit]
[-] ftp.lua
[edit]
[-] brute.lua
[edit]
[-] comm.lua
[edit]
[-] ipOps.lua
[edit]
[-] mobileme.lua
[edit]
[-] target.lua
[edit]
[-] rpcap.lua
[edit]
[-] eap.lua
[edit]
[-] cassandra.lua
[edit]
[-] ssh1.lua
[edit]
[-] url.lua
[edit]
[-] datafiles.lua
[edit]
[-] ajp.lua
[edit]
[-] vuzedht.lua
[edit]
[-] nsedebug.lua
[edit]
[-] rtsp.lua
[edit]
[-] shortport.lua
[edit]
[-] bittorrent.lua
[edit]
[-] ssh2.lua
[edit]
[-] msrpcperformance.lua
[edit]
[-] listop.lua
[edit]
[-] dnsbl.lua
[edit]
[-] json.lua
[edit]
[-] redis.lua
[edit]
[-] wsdd.lua
[edit]
[-] tns.lua
[edit]
[-] ike.lua
[edit]
[-] gps.lua
[edit]
[-] versant.lua
[edit]
[-] imap.lua
[edit]
[-] smb.lua
[edit]
[-] smbauth.lua
[edit]
[-] xmpp.lua
[edit]
[-] upnp.lua
[edit]
[-] membase.lua
[edit]
[-] vnc.lua
[edit]
[-] srvloc.lua
[edit]