This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Lua: Listener object can not be instantiated

0

Hi, I am using lates wireshark together with lua 5.2 dll and ZeroBrane Master from GIT to debug lua scripts.

I have set the Path to the ZeroBrane EduKit to fix a lua socket problem with lua 5.2.

After copy the lua 5.2 dll into the wireshark folder, fixing the problem with the lua path and socket error I was able to start the script and debug. However the Listener object is not instantiated. The watch expression shows: Listener = "bad argument #1 to ? (userdata expected, got table)" I assume that is related to version missmatch between lua 5.2 dll and debugger mobdeug but I an not able to find a working setup.

Anyone have had the same problem and was able to fix it?

A Zip or portable with running wireshark, lua and ZeroBrane to debug lua scripts for wireshark would be very appreciated.

Thank you,

Markus

Code:

_G.debug = require("debug")
require("mobdebug").start()

local function menuable_tap() – Declare the window we will use local tw = TextWindow.new("Address Counter")

-- This will contain a hash of counters of appearances of a certain address
local ips = {}

-- this is our tap
local tap = Listener.new(nil, "ip")

function remove()
        -- this way we remove the listener that otherwise will remain running indefinitely
        tap:remove()
end

-- we tell the window to call the remove() function when closed
tw:set_atclose(remove)

-- this function will be called once for each packet
function tap.packet(pinfo,tvb)
        local src = ips[tostring(pinfo.src)] or 0
        local dst = ips[tostring(pinfo.dst)] or 0
        ips[tostring(pinfo.src)] = src + 1
        ips[tostring(pinfo.dst)] = dst + 1
end

-- this function will be called once every few seconds to update our window
function tap.draw(t)
        tw:clear()
        for ip,num in pairs(ips) do
                tw:append(ip .. "\t" .. num .. "\n");
        end
end

-- this function will be called whenever a reset is needed
-- e.g. when reloading the capture file
function tap.reset()
        tw:clear()
        ips = {}
end

end

– using this function we register our function – to be called when the user selects the Tools->Test->Packets menu register_menu("Test/Packets", menuable_tap, MENU_TOOLS_UNSORTED)

asked 09 Apr ‘15, 06:28

supisupi's gravatar image

supisupi
6224
accept rate: 0%

edited 09 Apr ‘15, 06:42

grahamb's gravatar image

grahamb ♦
19.8k330206