OXIESEC PANEL
- Current Dir:
/
/
usr
/
share
/
nmap
/
nselib
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/07/2020 12:36:00 PM
rwxr-xr-x
📄
afp.lua
71.92 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ajp.lua
16.69 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
amqp.lua
10.5 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
anyconnect.lua
4.45 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
asn1.lua
14.57 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
base32.lua
7.33 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
base64.lua
5.67 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bin.lua
12.89 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bit.lua
2.43 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bitcoin.lua
16.99 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bits.lua
1.82 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bittorrent.lua
40.77 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
bjnp.lua
9.45 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
brute.lua
50.04 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
cassandra.lua
5.78 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
citrixxml.lua
16 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
coap.lua
76.24 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
comm.lua
10.75 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
creds.lua
18.22 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
cvs.lua
3.13 KB
04/16/2018 01:11:39 AM
rw-r--r--
📁
data
-
08/07/2020 12:36:00 PM
rwxr-xr-x
📄
datafiles.lua
11.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
datetime.lua
1.16 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dhcp.lua
29.17 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dhcp6.lua
19.87 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dns.lua
51.44 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dnsbl.lua
19.02 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
dnssd.lua
12.57 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
drda.lua
24.2 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
eap.lua
7.64 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
eigrp.lua
14.47 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
formulas.lua
5.35 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ftp.lua
9.03 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
geoip.lua
1.71 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
giop.lua
18.44 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
gps.lua
3.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
http.lua
105.81 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
httpspider.lua
36.15 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
iax2.lua
9.6 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ike.lua
15.02 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
imap.lua
9.59 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
informix.lua
39.76 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ipOps.lua
26.92 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ipmi.lua
10.02 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ipp.lua
12.54 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
irc.lua
757 bytes
04/16/2018 01:11:39 AM
rw-r--r--
📄
iscsi.lua
21.45 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
isns.lua
15.34 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
jdwp.lua
43.57 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
json.lua
11.65 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ldap.lua
31.86 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
lfs.luadoc
1.68 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
libssh2-utility.lua
4.39 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
libssh2.luadoc
4.75 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
listop.lua
4.66 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
lpeg-utility.lua
5.64 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
lpeg.luadoc
351 bytes
04/16/2018 01:11:39 AM
rw-r--r--
📄
ls.lua
10.96 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
match.lua
2.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
membase.lua
9.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mobileme.lua
8.46 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mongodb.lua
21.29 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mqtt.lua
28.95 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
msrpc.lua
179.93 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
msrpcperformance.lua
29.72 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
msrpctypes.lua
167.61 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mssql.lua
110.87 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
multicast.lua
6.1 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
mysql.lua
17.09 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
natpmp.lua
5.04 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ncp.lua
36 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ndmp.lua
11.58 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
netbios.lua
13.9 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
nmap.luadoc
40.34 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
nrpc.lua
4.42 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
nsedebug.lua
3.49 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
omp2.lua
4.77 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
openssl.luadoc
7.08 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ospf.lua
15.29 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
packet.lua
36.65 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pcre.luadoc
6.79 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pgsql.lua
20.61 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pop3.lua
5.7 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
pppoe.lua
29.95 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
proxy.lua
12.04 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rdp.lua
11.05 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
re.lua
8.22 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
redis.lua
3.59 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rmi.lua
47.89 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rpc.lua
106.22 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rpcap.lua
11.19 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rsync.lua
5.19 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
rtsp.lua
8.67 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sasl.lua
16.38 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
shortport.lua
8.01 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sip.lua
30.56 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
slaxml.lua
17.9 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smb.lua
175.85 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smb2.lua
16.32 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smbauth.lua
37.53 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
smtp.lua
19.81 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
snmp.lua
15.99 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
socks.lua
8.26 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
srvloc.lua
12.25 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ssh1.lua
8.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
ssh2.lua
11.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sslcert.lua
33.34 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
sslv2.lua
9.63 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
stdnse.lua
45.93 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
strbuf.lua
4.52 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
strict.lua
2.53 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
stun.lua
11.51 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tab.lua
3.35 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
target.lua
3.93 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tftp.lua
9.38 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tls.lua
56.16 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tn3270.lua
43.75 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
tns.lua
64.17 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
unicode.lua
14.32 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
unittest.lua
12.33 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
unpwdb.lua
10.08 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
upnp.lua
11.18 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
url.lua
12.09 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
versant.lua
8.6 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
vnc.lua
23.3 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
vulns.lua
76.29 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
vuzedht.lua
16.62 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
wsdd.lua
12.03 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
xdmcp.lua
11.9 KB
04/16/2018 01:11:39 AM
rw-r--r--
📄
xmpp.lua
15.88 KB
04/16/2018 01:11:39 AM
rw-r--r--
Editing: giop.lua
Close
--- -- GIOP Library supporting a very limited subset of operations -- -- Summary -- ------- -- The library currently provides functionality to connect and query the -- CORBA naming service for a list of available objects. -- -- -- Overview -- -------- -- The library contains the following classes: -- -- o Packet.* -- - The Packet classes contain specific packets and function to serialize -- them to strings that can be sent over the wire. Each class may also -- contain a function to parse the servers response. -- -- o Comm -- - Implements a number of functions to handle communication over the -- the socket. -- -- o Helper -- - A helper class that provides easy access to the rest of the library -- -- -- Example -- ------- -- The following sample code illustrates how scripts can use the Helper class -- to interface the library: -- -- <code> -- helper = giop.Helper:new(host, port) -- status, err = helper:Connect() -- status, ctx = helper:GetNamingContext() -- status, objs = helper:ListObjects(ctx) -- </code> -- -- Additional information -- ---------------------- -- The implementation is based on packet dumps and the decoding Wireshark -- provides. -- -- This implementation is tested and known to work against: -- x Sun's JAVA orbd -- -- @copyright Same as Nmap--See https://nmap.org/book/man-legal.html -- @author Patrik Karlsson <patrik@cqure.net> -- -- -- Version 0.1 -- Created 08/07/2010 - v0.1 - created by Patrik Karlsson <patrik@cqure.net> -- local bin = require "bin" local match = require "match" local nmap = require "nmap" local stdnse = require "stdnse" local table = require "table" _ENV = stdnse.module("giop", stdnse.seeall) -- A bunch of constants Constants = { SyncScope = { WITH_TARGET = 3, }, ServiceContext = { CODESETS = 1, SENDING_CONTEXT_RUNTIME = 6, NEO_FIRST_SERVICE_CONTEXT = 1313165056, }, ReplyStatus = { SYSTEM_EXCEPTION = 2, }, VERSION_1_0 = 1, VERSION_1_2 = 0x0201, NAMESERVICE = "NameService\0", } Packet = {} Packet.GIOP = { magic = "GIOP", version = 0x0001, byte_order = 0, --- Creates a Packet.GIOP -- -- @param msgtype number containing the message type -- @param data string containing the message data -- @return obj a new Packet.GIOP instance new = function( self, msgtype, data ) local o = {} setmetatable(o, self) self.__index = self o.type = msgtype o.data = data o.size = data and #data or 0 return o end, --- Converts the class to a string suitable to send over the socket -- -- @return string containing the instance data __tostring = function( self ) return bin.pack("<ASCC>IA", self.magic, self.version, self.byte_order, self.type, self.size, self.data ) end, --- Sets the packet version -- -- @param version number containing the version to use setVersion = function( self, version ) self.version = version end, --- Receives the packet over the socket -- -- @param socket containing the already connected socket -- @return status true on success, false on failure -- @return err containing the error message if status is false recv = function( self, socket ) local status, data = socket:receive_buf(match.numbytes(12), true) local pos if ( not(status) ) then return false, "Failed to read Packet.GIOP" end pos, self.magic, self.version, self.byte_order, self.type = bin.unpack("<A4SCC", data ) pos, self.size = bin.unpack( ( self.byte_order == 0 and ">" or "<") .. "I", data, pos ) status, data = socket:receive_buf(match.numbytes(self.size), true) if ( not(status) ) then return false, "Failed to read Packet.GIOP" end self.data = data return true end, } ServiceContext = { --- Creates a ServiceContext -- -- @param id number containing the context id -- @param data the service context data -- @param pad [optional] number used to pad after the service context -- @return obj a new ServiceContext instance new = function( self, id, data, pad ) local o = {} setmetatable(o, self) self.__index = self o.id = id o.data = data or "" o.pad = pad return o end, --- Converts the class to a string suitable to send over the socket -- -- @return string containing the instance data __tostring = function( self ) if ( self.pad ) then return bin.pack(">IIAS", self.id, #self.data, self.data, self.pad) else return bin.pack(">IIA", self.id, #self.data, self.data) end end, } --- Creates a SendingContextRuntime SendingContextRuntime = { --- Creates a SendingContextRuntime -- -- @param lhost string containing the source ip address -- @return obj a new SendingContextRuntime instance new = function(self, lhost ) local o = {} setmetatable(o, self) self.__index = self o.data = bin.pack(">HIAH", [[ 000000000000002849444c3a6f6d672e6f72672f53656e64696e67436f6e746 578742f436f6465426173653a312e300000000001000000000000006e000102 00 ]], #lhost + 1, lhost .. "\0", [[ 00ec5100000019afabcb000000000249765d6900000008000000000000000014 0000000000000200000001000000200000000000010001000000020501000100 01002000010109000000010001010000000026000000020002 ]] ) return o end, --- Converts the class to a string suitable to send over the socket -- -- @return string containing the instance data __tostring = function( self ) return self.data end, } Packet.GIOP.reply = { --- Creates a new Packet.GIOP.reply instance -- -- @return obj a new Packet.GIOP.get instance new = function( self ) local o = {} setmetatable(o, self) self.__index = self self.sc = {} self.GIOP = Packet.GIOP:new() return o end, --- Receives a Packet.GIOP.reply from the socket -- -- @param socket already connected to the server -- @return status true on success, false on failure -- @return err error message if status is false recv = function( self, socket ) local status, err = self.GIOP:recv( socket ) local pos, tmp local bo = ( self.GIOP.byte_order == 0 and ">" or "<") if( not(status) ) then return false, err end if ( self.GIOP.version == Constants.VERSION_1_2 ) then pos, self.request_id, self.reply_status = bin.unpack(bo .. "II", self.GIOP.data, pos ) pos, tmp = bin.unpack( bo .. "I", self.GIOP.data, pos ) elseif ( self.GIOP.version == Constants.VERSION_1_0 ) then pos, tmp = bin.unpack( bo .. "I", self.GIOP.data ) else local err = ("Unknown GIOP version: %s"):format(self.GIOP.version) stdnse.debug2("recv: %s", err) return false, err end for i=1, tmp do local ctx_id, ctx_len, ctx_data pos, ctx_id, ctx_len = bin.unpack( bo .. "II", self.GIOP.data, pos ) pos, ctx_data = bin.unpack("A" .. ctx_len, self.GIOP.data, pos ) if ( i ~= tmp ) then pos = pos + 2 end table.insert( self.sc, ServiceContext:new( ctx_id, ctx_data ) ) end if ( self.GIOP.version == Constants.VERSION_1_0 ) then pos, self.request_id, self.reply_status, self.stub_data = bin.unpack( bo .. "IIA" .. ( #self.GIOP.data - pos - 8 ), self.GIOP.data, pos ) elseif ( pos < #self.GIOP.data ) then pos, self.data = bin.unpack("A" .. (#self.GIOP.data - pos), self.GIOP.data, pos ) end return true end, } Packet.GIOP.get = { resp_expected = 1, key_length = 4, princ_len = 0, --- Creates a new Packet.GIOP._is_a instance -- -- @param id the packet identifier -- @param key number containing the object key -- @param data string containing the stub data -- @return obj a new Packet.GIOP.get instance new = function( self, id, key, data ) local o = {} setmetatable(o, self) self.__index = self o.op = "get\0" o.id = id o.key = key o.data = data o.sc = {} return o end, --- Creates and adds a service context to the packet -- -- @param id number containing the context id -- @param data the service context data -- @param pad [optional] number used to pad after the service context addServiceContext = function( self, id, data, pad ) table.insert( self.sc, ServiceContext:new(id, data, pad) ) end, --- Converts the class to a string suitable to send over the socket -- -- @return string containing the packet data __tostring = function( self ) local data = bin.pack(">I", #self.sc) local pad = 0 for i=1, #self.sc do data = data .. tostring( self.sc[i]) end data = data .. bin.pack( ">ICCCCIIIAIA", self.id, self.resp_expected, pad, pad, pad, self.key_length, self.key, #self.op, self.op, self.princ_len, self.data ) return tostring( Packet.GIOP:new( 0, data ) ) end, } Packet.GIOP._is_a = { --- Creates a new Packet.GIOP._is_a instance -- -- @param id the packet identifier -- @param flags [optional] -- @param keyaddr string containing the keyaddr data -- @return obj a new Packet.GIOP._is_a instance new = function( self, id, flags, key_addr ) local o = {} setmetatable(o, self) self.__index = self o.op = "_is_a\0" o.id = id o.target_addr = 0 -- KeyAddr o.key_addr = key_addr o.flags = flags or Constants.SyncScope.WITH_TARGET -- SyncScope WITH_TARGET o.sc = {} return o end, --- Creates and adds a service context to the packet -- -- @param id number containing the context id -- @param data the service context data -- @param pad [optional] number used to pad after the service context addServiceContext = function( self, id, data, pad ) table.insert( self.sc, ServiceContext:new(id, data, pad) ) end, --- Converts the class to a string suitable to send over the socket -- -- @return string containing the packet data __tostring = function( self ) local TYPE_ID = "IDL:omg.org/CosNaming/NamingContextExt:1.0\0" local RESERVED = 0 local UNKNOWN, UNKNOWN2, UNKNOWN3 = 2, 1, 0 local data = bin.pack(">ICCCCSSIAIASI", self.id, self.flags, RESERVED, RESERVED, RESERVED, self.target_addr, UNKNOWN, #self.key_addr, self.key_addr, #self.op, self.op, UNKNOWN2, #self.sc ) for i=1, #self.sc do data = data .. tostring( self.sc[i]) end data = data .. bin.pack(">IA", #TYPE_ID, TYPE_ID) local packet = Packet.GIOP:new( 0, data ) packet:setVersion( Constants.VERSION_1_2 ) return tostring( packet ) end, } Packet.GIOP.list = { --- Creates a new Packet.GIOP.list instance -- -- @param id the packet identifier -- @param flags [optional] -- @param keyaddr string containing the keyaddr data -- @param how_many string containing the value to retrieve -- @return obj a new Packet.GIOP.list instance new = function( self, id, flags, keyaddr, how_many ) local o = {} setmetatable(o, self) self.__index = self o.op = "list\0" o.id = id o.flags = flags or Constants.SyncScope.WITH_TARGET o.target_addr = 0 -- KeyAddr o.key_addr = keyaddr o.how_many = how_many or 1000 o.sc = {} return o end, --- Creates and adds a service context to the packet -- -- @param id number containing the context id -- @param data the service context data -- @param pad [optional] number used to pad after the service context addServiceContext = function( self, id, data, pad ) table.insert( self.sc, ServiceContext:new(id, data, pad) ) end, --- Converts the class to a string suitable to send over the socket -- -- @return string containing the packet data __tostring = function( self ) local RESERVED = 0 local UNKNOWN, UNKNOWN2, UNKNOWN3 = 2, 1, 6 local data = bin.pack(">ICCCCSSIAIACCCI", self.id, self.flags, RESERVED, RESERVED, RESERVED, self.target_addr, UNKNOWN, #self.key_addr, self.key_addr, #self.op, self.op, RESERVED, RESERVED, UNKNOWN2, #self.sc ) for i=1, #self.sc do data = data .. tostring( self.sc[i]) end data = data .. bin.pack(">II", UNKNOWN3, self.how_many ) local packet = Packet.GIOP:new( 0, data ) packet:setVersion( Constants.VERSION_1_2 ) return tostring( packet ) end, } -- Static class containing various message decoders MessageDecoder = { --- Decodes a get response -- -- @param packet the GIOP packet as received by the comm -- <code>exchGIOPPacket</code> function -- @return status true on success, false on failure -- @return table containing <code>ip</code> and <code>ctx</code> ["get"] = function( packet ) local bo = ( packet.GIOP.byte_order == 0 and ">" or "<") local pos, len = bin.unpack(bo .. "I", packet.stub_data) local ip, ctx pos = pos + len + 16 pos, len = bin.unpack(bo .. "I", packet.stub_data, pos) pos, ip = bin.unpack( bo .. "A" .. len, packet.stub_data, pos) pos = pos + 3 pos, len = bin.unpack(bo .. "I", packet.stub_data, pos) pos, ctx = bin.unpack( bo .. "A" .. len, packet.stub_data, pos) return true, { ip = ip, ctx = ctx} end, --- Decodes a _is_a response (not implemented) -- -- @param packet the GIOP packet as received by the comm -- <code>exchGIOPPacket</code> function -- @return status, always true ["_is_a"] = function( packet ) return true end, --- Decodes a list response -- -- @param packet the GIOP packet as received by the comm -- <code>exchGIOPPacket</code> function -- @return status true on success, false on failure -- @return table containing <code>id</code>, <code>kind</code> and -- <code>enum</code> or error message if status is false ["list"] = function( packet ) local bo = ( packet.GIOP.byte_order == 0 and ">" or "<") local pos, seq_len = bin.unpack( bo .. "I", packet.data, 7) local objs = {} for i=1, seq_len do local seq_len_of_bind_name local len, name local obj = {} pos, seq_len_of_bind_name = bin.unpack( bo .. "I", packet.data, pos) if ( seq_len_of_bind_name ~= 1 ) then return false, "Sequence length of Binding_binding_name was greater than 1" end pos, len = bin.unpack( bo .. "I", packet.data, pos ) pos, obj.id = bin.unpack( "A" .. len - 1, packet.data, pos ) -- Account for terminating zero pos = pos + 1 -- Account for undecoded data pos = pos + ( ( len % 4 > 0 ) and ( 4 - ( len % 4 ) ) or 0 ) pos = pos + 3 pos, obj.kind = bin.unpack("C", packet.data, pos) -- Account for undecoded data pos = pos + 4 pos, obj.enum = bin.unpack( bo .. "I", packet.data, pos ) table.insert( objs, obj ) end return true, objs end, } Comm = { --- Creates a new Comm instance -- -- @param socket containing a buffered socket connected to the server -- @return a new Comm instance new = function(self, socket) local o = {} setmetatable(o, self) self.__index = self o.socket = socket return o end, --- Sends and receives a GIOP packet -- -- @param packet containing a Packet.* object, the object must -- implement the __tostring meta method -- @return status true on success, false on failure -- @return data decoder specific data, see the corresponding -- MessageDecoder for more information. exchGIOPPacket = function( self, packet ) local status, err = self.socket:send( tostring(packet) ) local op = packet.op:sub(1, -2) local data if( not(status) ) then return false, err end packet = Packet.GIOP.reply:new() status, err = packet:recv( self.socket ) if( not(status) ) then return false, err end if ( MessageDecoder[op] ) then status, data = MessageDecoder[op]( packet ) else return false, ("No message decoder for op (%s)"):format(op) end return status, data end, } Helper = { new = function(self, host, port ) local o = {} setmetatable(o, self) self.__index = self o.host = host o.port = port o.socket = nmap.new_socket() return o end, GetNamingContext = function( self ) local packet = Packet.GIOP.get:new( 5, 0x494e4954, bin.pack(">IA", #Constants.NAMESERVICE, Constants.NAMESERVICE) ) local status, ctx, lhost, pos, len, bo, tmp packet:addServiceContext( 17, "\0\x02", 0) packet:addServiceContext( Constants.ServiceContext.NEO_FIRST_SERVICE_CONTEXT, "\0\x14", 0) packet:addServiceContext( Constants.ServiceContext.SENDING_CONTEXT_RUNTIME, tostring(SendingContextRuntime:new( self.lhost )), 0 ) status, packet = self.comm:exchGIOPPacket( packet ) if( not(status) ) then return status, packet end return true, packet.ctx end, ListObjects = function( self, keyaddr ) -- SyncScope WITH_TARGET local packet = Packet.GIOP._is_a:new( 5, Constants.SyncScope.WITH_TARGET, keyaddr ) local status, err, lhost status, err = self:Reconnect() if( not(status) ) then return false, err end packet:addServiceContext( 17, "\0\2", 0x000d) packet:addServiceContext( Constants.ServiceContext.CODESETS, "\0\0\0\0\0\1\0\1\0\1\1\9" ) packet:addServiceContext( Constants.ServiceContext.NEO_FIRST_SERVICE_CONTEXT, "\0\x14", 0x5d69) packet:addServiceContext( Constants.ServiceContext.SENDING_CONTEXT_RUNTIME, tostring(SendingContextRuntime:new( self.lhost )), 0 ) status, packet = self.comm:exchGIOPPacket( packet ) if( not(status) ) then return status, packet end packet = Packet.GIOP.list:new( Constants.ServiceContext.SENDING_CONTEXT_RUNTIME, Constants.SyncScope.WITH_TARGET, keyaddr, 1000 ) packet:addServiceContext( 17, "\0\2", 0x000d) packet:addServiceContext( Constants.ServiceContext.CODESETS, "\0\0\0\0\0\1\0\1\0\1\1\9" ) packet:addServiceContext( Constants.ServiceContext.NEO_FIRST_SERVICE_CONTEXT, "\0\x14", 0x9c9b) status, packet = self.comm:exchGIOPPacket( packet ) if( not(status) ) then return status, packet end return true, packet end, --- Connects and performs protocol negotiation with the Oracle server -- -- @return true on success, false on failure -- @return err containing error message when status is false Connect = function( self ) self.socket:set_timeout(10000) local status, data = self.socket:connect( self.host.ip, self.port.number, "tcp" ) if( not(status) ) then return status, data end self.comm = Comm:new( self.socket ) status, self.lhost = self.socket:get_info() if ( not(status) ) then self.socket:close() return false, "Error failed to get socket information" end return true end, Close = function( self ) return self.socket:close() end, Reconnect = function( self ) local status = self:Close() if( not(status) ) then return false, "Failed to close socket" end status = self:Connect() if( not(status) ) then return false, "Failed to re-connect socket" end return true end, } return _ENV;