Run lua dissector and tap in tshark at the same time - lua

I have a custom dissector (written in Lua) that I am using in many aspects of my current project.
I would also like to write a tap to perform some specific calculations for a particular task. I would like to keep this separate from the general purpose dissector for purposes of modularity.
Is there a way to invoke a dissector and a tap, both written in Lua, from the tshark command line? More generally, can an arbitrary number of Lua scripts be invoked, and if so, will they get invoked in the correct order?
EDIT:
I have tried invoking the two scripts from the command line:
tshark -Xlua_script:my_diss.lua -Xlua_script:my_tap.lua -r my.pcap
But I get an error:
tshark: Lua: Error during loading:
[string "my_tap.lua"]:9: bad argument #1 to 'new' (Field_new: a field with this name must exist)
The field name that this line refers to is created in my_diss.lua, but it is apparently not visible when my_tap.lua is being loaded.

That would require that the "initialize Lua" code in libwireshark be told which Lua scripts are dissectors and which Lua scripts are taps, and load them at the appropriate time so that, for example, all dissectors are loaded before all taps.
That means Wireshark would have to be changed; please file an bug at the Wireshark Bugzilla for this.

This is now supported in the wireshark codebase (version 1.8.5). I built from source and was able to get the desired behavior.
The relevant issue is: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6020
The relevant commit is: http://anonsvn.wireshark.org/viewvc?view=revision&revision=47877

Related

SciTE can not find user defined function. The editor executes "/bin/sh" for some reason

So, this is my first attempt to make my source code editing more comfortable. I follow the SciTE scripting guide.
ext.lua.startup.script=$(SciteDefaultHome)/startup.lua
command.name.1.*= Programmer's Manual (selected text)
command.subsystem.1.*= 3
command.1.*=man_select
command.shortcut.1.*=F1
Above is the user properties file. It binds F1 key to user defined Lua function.
The problem is, that insteed of starting the function, man_select in my case, the SciTE editor output gives me
>man_select
/bin/sh: man_select: not found
>Exit code: 127
So, the editor runs a shell with my function name as a argument. I can't find no SciTE logs, or console, to see what the cause is.
I define man_select as a simple Lua function, without arguments:
function man_select()
local sel = editor:GetSelText()
...
end
What should I do to make my own Lua functions visible to SciTE editor? Is there a way to ask SciTE for more information on its scripting system flow?

How can I extend scrapy-splash 'render.html' endpoint with some lua code?

So, I want to use scrapy-splash with endpoint='execute' but mimic endpoint='render.html' with my Lua extra code. But I couldn't find an example how this should be done so that the Lua code that will be sent with the request will be the same as the Lua (I expect) used to intercept an HTML with all it's parameters.
Any idea?
As far as I could see this is not supported, but I have found this
https://github.com/scrapinghub/splash/blob/master/splash/tests/lua_modules/emulation.lua script which mimics the actual python code that runs render.html (and other endpoints).
This (should) allow mimicing (as much as possible) the python code that runs render.html and should be easy to extend with lua/js code.
Note: you want to add the following lines at the bottom of emulation.lua:
function main(splash)
return {
html = emulation.render_html(splash)
}
end
Important: you must add --disable-lua-sandbox to splash (docker) command line

Call into Lua from TI-BASIC

I have an nspire calculator and after writing a hash table implementation, found the BASIC environment to be a pretty offensive programming environment. Unfortunately, as far as I'm aware, it's impossible to use Lua to write libraries.
I did see that somewhere in the Lua interface you can detect variable changes so it might be possible within a file to use Lua functions, but I fear it will go out of scope if used externally.
Is there a better way to do this?
It's not impossible to write Lua libraries for a TI-Nspire. You can put the libraries code into a string, store it as a variable in TI-Basic and put the file in the MyLibs folder. Then, when you want to load your library, do loadstring(var.recall("libfilename/programstring"))(). This will load the library's code as a string from that files, compile it (using loadstring), and execute it (practicaly the same as require).
Also, about getting from controlling a Lua script using TI-Basic, depending on what you want to do, you could use math.eval("<some TI-Basic code>"). This will execute the code in TI-Basic, and return the result as a Lua value (or string). This way, you can call a TI-Basic function every once in a while, and act according to its output.

Read data before executing lua file

I want to read a table inside a Lua file before executing it. Is there a way to do this with loadfile. It returns only a function and I can't seem to be able to read what is inside (what is declared but not executed).
The other option I tried is to check if the environment changed, but yet again I couldn't read inside the function returned by loadfile().
Is there a way to do this without opening the file as text and searching the table?
Here is an example of the table I try to retrieve:
--file to be loaded
local library = require("library") --random requires...
table = { author = "myself", dependencies = "library > 1.0"} --table to get before execution
What you want is not possible.
There are no declarations in Lua, only executable statements.
You need to execute a script to see what it does.
However, you could read the file as text and try to extract the info you need using pattern matching. This won't be foolproof but it'll probably work in most cases if the files are written in the same way.

How do I Make an executable Lua script using srlua?

My main goal is to either make my lua file into executable or make it into a bite code.
preferably both of them.
I am trying srlua,but in readme file it tells me to do:
"For Windows, you need to create srlua.exe and glue.exe first. Then for each
Lua program that you want to turn into a stand-alone program, do
glue srlua.exe prog.lua prog.exe
Of course, you can use any name instead of prog.exe."
and when I am trying to compile it using codebluck to get(srlua.exe),I get this :
and what dose it mean by this?
glue srlua.exe prog.lua prog.exe
where should I type that it.
Thanks in advance.
Type it into your shell. Once you have the binary of srlua, that takes "prog.lua" and glues it to "srlua.exe" making "prog.exe". Of course, you need glue as well. You can get an srlua binary and a glue binary for Lua 5.1 here. http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/#srlua

Resources