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: xmpp.lua
Close
--- A XMPP (Jabber) library, implementing a minimal subset of the protocol -- enough to do authentication brute-force. -- -- The XML parsing of tags isn't optimal but there's no other easy way -- (nulls or line-feeds) to match the end of a message. The parse_tag -- method in the XML class was borrowed from the initial xmpp.nse -- script written by Vasiliy Kulikov. -- -- The library consist of the following classes: -- * <code>XML</code> - containing a minimal XML parser written by -- Vasiliy Kulikov. -- * <code>TagProcessor</code> - Contains processing code for common tags -- * <code>XMPP</code> - containing the low-level functions used to -- communicate with the Jabber server. -- * <code>Helper</code> - containing the main interface for script -- writers -- -- The following sample illustrates how to use the library to authenticate -- to a XMPP sever: -- <code> -- local helper = xmpp.Helper:new(host, port, options) -- local status, err = helper:connect() -- status, err = helper:login(user, pass, "DIGEST-MD5") -- </code> -- -- @copyright Same as Nmap--See https://nmap.org/book/man-legal.html -- @author Patrik Karlsson <patrik@cqure.net> -- Version 0.2 -- Created 07/19/2011 - v0.1 - Created by Patrik Karlsson -- Revised 07/22/2011 - v0.2 - Added TagProcessors and two new auth mechs: -- CRAM-MD5 and LOGIN <patrik@cqure.net> local base64 = require "base64" local match = require "match" local nmap = require "nmap" local sasl = require "sasl" local stdnse = require "stdnse" local string = require "string" local table = require "table" _ENV = stdnse.module("xmpp", stdnse.seeall) -- This is a trivial XML processor written by Vasiliy Kulikov. It doesn't -- fully support XML, but it should be sufficient for the basic XMPP -- stream handshake. If you see stanzas with uncommon symbols, feel -- free to enhance these regexps. XML = { ---XML tag table --@class table --@name XML.tag --@field name The tag name --@field attrs The tag attributes as a key-value table --@field start True if this was an opening tag. --@field contents The contents of the tag --@field finish true if the tag was closed. ---Parse an XML tag --@name XML.parse_tag --@param s String containing the XML tag --@return XML tag table --@see XML.tag parse_tag = function(s) local _, _, contents, empty, name = string.find(s, "([^<]*)<(/?)([?:%w-]+)") local attrs = {} if not name then return end for k, v in string.gmatch(s, "%s([%w:]+)='([^']+)'") do attrs[k] = v end for k, v in string.gmatch(s, "%s([%w:]+)=\"([^\"]+)\"") do attrs[k] = v end local finish = (empty ~= "") or (s:sub(#s-1) == '/>') return { name = name, attrs = attrs, start = (empty == ""), contents = contents, finish = finish } end, } TagProcessor = { ["failure"] = function(socket, tag) return TagProcessor["success"](socket,tag) end, ["success"] = function(socket, tag) if ( tag.finish ) then return true end local newtag repeat local status, data = socket:receive_buf(match.pattern_limit(">", 2048), true) if ( not(status) ) then return false, ("ERROR: Failed to process %s tag"):format(tag.name) end newtag = XML.parse_tag(data) until( newtag.finish and newtag.name == tag.name ) if ( newtag.name == tag.name ) then return true, tag end return false, ("ERROR: Failed to process %s tag"):format(tag.name) end, ["challenge"] = function(socket, tag) local status, data = socket:receive_buf(match.pattern_limit(">", 2048), true) if ( not(status) ) then return false, "ERROR: Failed to read challenge tag" end local tag = XML.parse_tag(data) if ( not(status) or tag.name ~= "challenge" ) then return false, "ERROR: Failed to process challenge" end return status, (tag.contents and base64.dec(tag.contents)) end, } XMPP = { --- Creates a new instance of the XMPP class -- -- @name XMPP.new -- @param host table as received by the action function -- @param port table as received by the action function -- @param options table containing options, currently supported -- * <code>timeout</code> - sets the socket timeout -- * <code>servername</code> - sets the server name to use in -- communication with the server. -- * <code>starttls</code> - start TLS handshake even if it is optional. new = function(self, host, port, options) local o = { host = host, port = port, options = options or {}, auth = { mechs = {} } } o.options.timeout = o.options.timeout and o.options.timeout or 10 o.servername = stdnse.get_hostname(host) or o.options.servername setmetatable(o, self) self.__index = self return o end, --- Sends data to XMPP server -- @name XMPP.send -- @param data string containing data to send to server -- @return status true on success false on failure -- @return err string containing error message send = function(self, data) -- this ain't pretty, but we try to "flush" what's left of the receive -- buffer, prior to send. This way we account for not reading to the -- end of one message resulting in the next read reading from our -- previous message. self.socket:set_timeout(1) repeat local status = self.socket:receive_buf("\0", false) until(not(status)) self.socket:set_timeout(self.options.timeout * 1000) return self.socket:send(data) end, --- Receives a XML tag from the server -- -- @name XMPP.receive_tag -- @param tag [optional] if unset, receives the next available tag -- if set, reads until the given tag has been found -- @param close [optional] if set, matches a closing tag -- @return true on success, false on error -- @return The XML tag table, or error message -- @see XML.tag receive_tag = function(self, tag, close) local result repeat local status, data = self.socket:receive_buf(match.pattern_limit(">", 2048), true) if ( not(status) ) then return false, data end result = XML.parse_tag(data) until( ( not(tag) and (close == nil or result.finish == close ) ) or ( tag == result.name and ( close == nil or result.finish == close ) ) ) return true, result end, --- Connects to the XMPP server -- @name XMPP.connect -- @return status true on success, false on failure -- @return err string containing an error message if status is false connect = function(self) assert(self.servername, "Cannot connect to XMPP server without valid server name") -- we may be reconnecting using SSL if ( not(self.socket) ) then self.socket = nmap.new_socket() self.socket:set_timeout(self.options.timeout * 1000) local status, err = self.socket:connect(self.host, self.port) if ( not(status) ) then return false, err end end local data = ("<?xml version='1.0' ?><stream:stream to='%s' xmlns='jabber:client'" .. " xmlns:stream='http://etherx.jabber.org/streams'" .. " version='1.0'>"):format(self.servername) local status, err = self:send(data) if ( not(status) ) then return false, "ERROR: Failed to connect to server" end local version, start_tls repeat local status, tag = self:receive_tag() if ( not(status) ) then return false, "ERROR: Failed to connect to server" end if ( tag.name == "stream:stream" ) then version = tag.attrs and tag.attrs.version elseif ( tag.name == "starttls" and tag.start ) then status, tag = self:receive_tag() if ( not(status) ) then return false, "ERROR: Failed to connect to server" end if ( tag.name ~= "starttls" ) then start_tls = tag.name else start_tls = "optional" end elseif ( tag.name == "mechanism" and tag.finish ) then self.auth.mechs[tag.contents] = true end until(tag.name == "stream:features" and tag.finish) if ( version ~= "1.0" ) then return false, "ERROR: Only version 1.0 is supported" end if ( start_tls == "required" or self.options.starttls) then status, err = self:send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>") if ( not(status) ) then return false, "ERROR: Failed to initiate STARTTLS" end local status, tag = self:receive_tag() if ( not(status) ) then return false, "ERROR: Failed to receive from server" end if ( tag.name == "proceed" ) then status, err = self.socket:reconnect_ssl() self.options.starttls = false return self:connect() end end return true end, --- Logs in to the XMPP server -- -- @name XMPP.login -- @param username string -- @param password string -- @param mech string containing a supported authentication mechanism -- @return status true on success, false on failure -- @return err string containing error message if status is false login = function(self, username, password, mech) assert(mech == "PLAIN" or mech == "DIGEST-MD5" or mech == "CRAM-MD5" or mech == "LOGIN", "Unsupported authentication mechanism") local auth = ("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' " .. "mechanism='%s'/>"):format(mech) -- we currently don't do anything with the realm local realm -- we need to cut the @domain.tld from the username if ( username:match("@") ) then username, realm = username:match("^(.*)@(.*)$") end local status, result if ( mech == "PLAIN" ) then local mech_params = { username, password } local auth_data = sasl.Helper:new(mech):encode(table.unpack(mech_params)) auth = ("<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' " .. "mechanism='%s'>%s</auth>"):format(mech, base64.enc(auth_data)) status, result = self.socket:send(auth) if ( not(status) ) then return false, "ERROR: Failed to send SASL PLAIN authentication" end status, result = self:receive_tag() if ( not(status) ) then return false, "ERROR: Failed to receive login response" end if ( result.name == "failure" ) then status = TagProcessor[result.name](self.socket, result) end else local status, err = self.socket:send(auth) if(not(status)) then return false, "ERROR: Failed to initiate SASL login" end local chall status, result = self:receive_tag() if ( not(status) ) then return false, "ERROR: Failed to retrieve challenge" end status, chall = TagProcessor[result.name](self.socket, result) if ( mech == "LOGIN" ) then if ( chall ~= "User Name" ) then return false, ("ERROR: Login expected 'User Name' received: %s"):format(chall) end self.socket:send("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>" .. base64.enc(username) .. "</response>") status, result = self:receive_tag() if ( not(status) or result.name ~= "challenge") then return false, "ERROR: Receiving tag from server" end status, chall = TagProcessor[result.name](self.socket, result) if ( chall ~= "Password" ) then return false, ("ERROR: Login expected 'Password' received: %s"):format(chall) end self.socket:send("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>" .. base64.enc(password) .. "</response>") status, result = self:receive_tag() if ( not(status) ) then return false, "ERROR: Failed to receive login challenge" end if ( result.name == "failure" ) then status = TagProcessor[result.name](self.socket, result) return false, "Login failed" end else local mech_params = { username, password, chall, "xmpp", "xmpp/" .. self.servername } local auth_data = sasl.Helper:new(mech):encode(table.unpack(mech_params)) auth_data = "<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>" .. base64.enc(auth_data) .. "</response>" status, err = self.socket:send(auth_data) -- read to the end tag regardless of what it is -- it should be one of either: success, challenge or error repeat status, result = self:receive_tag() if ( not(status) ) then return false, "ERROR: Failed to receive login challenge" end if ( result.name == "failure" ) then status = TagProcessor[result.name](self.socket, result) return false, "Login failed" elseif ( result.name == "success" ) then status = TagProcessor[result.name](self.socket, result) if ( not(status) ) then return false, "Failed to process success message" end return true, "Login success" elseif ( result.name ~= "challenge" ) then return false, "ERROR: Failed to receive login challenge" end until( result.name == "challenge" and result.finish ) if ( result.name == "challenge" and mech == "DIGEST-MD5" ) then status, result = self.socket:send("<response xmlns='urn:ietf:params:xml:ns:xmpp-sasl'/>") if ( not(status) ) then return false, "ERROR: Failed to send DIGEST-MD5 request" end status, result = self:receive_tag() if ( not(status) ) then return false, "ERROR: Failed to receive DIGEST-MD5 response" end end end end if ( result.name == "success" ) then return true, "Login success" end return false, "Login failed" end, --- Retrieves the available authentication mechanisms -- @name XMPP.getAuthMechs -- @return table containing all available authentication mechanisms getAuthMechs = function(self) return self.auth.mechs end, --- Disconnects the socket from the server -- @name XMPP.disconnect -- @return status true on success, false on failure -- @return error message if status is false disconnect = function(self) local status, err = self.socket:close() self.socket = nil return status, err end, } Helper = { --- Creates a new Helper instance -- @name Helper.new -- @param host table as received by the action function -- @param port table as received by the action function -- @param options table containing options, currently supported -- * <code>timeout</code> - sets the socket timeout -- * <code>servername</code> - sets the server name to use in -- communication with the server. new = function(self, host, port, options) local o = { host = host, port = port, options = options or {}, xmpp = XMPP:new(host, port, options), state = "" } setmetatable(o, self) self.__index = self return o end, --- Connects to the XMPP server and starts the initial communication -- @name Helper.connect -- @return status true on success, false on failure -- @return err string containing an error message is status is false connect = function(self) if ( not(self.host.targetname) and not(self.options.servername) ) then return false, "ERROR: Cannot connect to XMPP server without valid server name" end self.state = "CONNECTED" return self.xmpp:connect() end, --- Login to the XMPP server -- -- @name Helper.login -- @param username string -- @param password string -- @param mech string containing a supported authentication mechanism -- @see Helper.getAuthMechs -- @return status true on success, false on failure -- @return err string containing error message if status is false login = function(self, username, password, mech) return self.xmpp:login(username, password, mech) end, --- Retrieves the available authentication mechanisms -- @name Helper.getAuthMechs -- @return table containing all available authentication mechanisms getAuthMechs = function(self) if ( self.state == "CONNECTED" ) then return self.xmpp:getAuthMechs() end return end, --- Closes the connection to the server -- @name Helper.close close = function(self) self.xmpp:disconnect() self.state = "DISCONNECTED" end, } return _ENV;