Skip to content

Update comm_dissector/README.md and init.lua#428

Merged
mefistotelis merged 2 commits intoo-gs:masterfrom
securityguy:fix-readme-init-lua
Apr 26, 2025
Merged

Update comm_dissector/README.md and init.lua#428
mefistotelis merged 2 commits intoo-gs:masterfrom
securityguy:fix-readme-init-lua

Conversation

@securityguy
Copy link
Copy Markdown
Contributor

  • Updated comm_dissector/README.md with an installation procedure that works with the current version of Wireshark

  • Corrected capitalization of "LUA" -- the name of the language is "Lua"

  • Updated init.lua to default to the current behaviour but easily allow users to specify an absolute path the the rest of the *.lua files as recommended in the updated readme

Hopefully this, along with my previous PR, saves new users an hour our so of tinkering.

Copy link
Copy Markdown
Collaborator

@mefistotelis mefistotelis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what series of problems is referred to. also few phrasing/formatting issues.

Comment thread comm_dissector/README.md Outdated

### Create a directory outside the Lua folder

If you place all of the Lua files in **or under ** Wireshark's LUA folder, you will most likely encounter a frustrating series of problems. To avoid this, create a directory outside Wireshark's plug-in tree. Feel free to create it in use your home directory, for example.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"create it in use your home directory" needs fixing

also if you referring to a series of problems, be specific enough to allow users to recognize the series - describe the first problem. (I am actually skeptical here, as I do have the scripts in that folder and I see no issues)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. I've also added a comment below to address your skepticism. (Google searches also indicate that I'm not the first person to encounter this issue.)

Comment thread comm_dissector/README.md Outdated

If you place all of the Lua files in **or under ** Wireshark's LUA folder, you will most likely encounter a frustrating series of problems. To avoid this, create a directory outside Wireshark's plug-in tree. Feel free to create it in use your home directory, for example.

(Tech note: When the Lua `dofile` command executes if it is only passed a filename, it try to load it from the current working directory and that probably won't be where the scripts are located.)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to rephrase so that it is understood on first read, ie.:
"If the Lua dofile command is only provided a file name (without path), it tries to load the file from the current working directory and that probably won't be where the scripts are located."

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, thank you.

Comment thread comm_dissector/README.md Outdated
### Copy the script files

Copy all the files LUA files (`*.lua`) and to the Wireshark profile directory. If you already different `init.lua` there, merge the content.
Copy **all the Lua files** (*.lua) to your new directory (that is outside Wireshark's plug) folder **except** `init.lua`.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why code marking was removed from file name with a wildcard.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread comm_dissector/README.md Outdated
Copy **all the Lua files** (*.lua) to your new directory (that is outside Wireshark's plug) folder **except** `init.lua`.

#### Copying files in Linux
Copy `init.lua` to your Wireshark `Personal Lua Plugins` directory. You can locate this directory in the `About Wireshark` dialog under the `Folders` tab. For further information refer to the [directories chapter in official documentation](https://www.wireshark.org/docs/wsug_html_chunked/ChAppFilesConfigurationSection.html).
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use cursive for Personal Lua Plugins, it is not a specific file name but a term. Interface items should not be in code blocks as well, can use cursive there too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread comm_dissector/README.md Outdated

The directory usually is `C:\Users\<username>\AppData\Roaming\Wireshark`. Check [directories chapter in official documentation](https://www.wireshark.org/docs/wsug_html_chunked/ChAppFilesConfigurationSection.html)
and a special chapter for Windows folders if unsure.
In summary, Wireshark will find `init.lua` in your `Personal Lua Plugins directory`, and `init.lua` in turn must contain an absolute path to the rest of the Lua files.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as before, Personal Lua Plugins directory

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread comm_dissector/README.md Outdated
Typically, you will capture the communication using either Wiresharks USB/ETH capture or using `comm_*2pcap.py` scripts. Then open the file in Wireshark.

## Setup
## Setup
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we adding that white space?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have chastised both my fingers and my MD editor. :). Fixed.

Comment thread comm_dissector/wireshark/init.lua Outdated

dofile('dji-dumlv1-proto.lua')
-- Change dji_script_path to point to the directory where you have copied
-- the Lua scripts. Do not place them in the Wireshark Lau directory.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo - Lau

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops! Fixed.

@securityguy
Copy link
Copy Markdown
Contributor Author

Thanks for the comments, you make several good points and I'll push a change to the branch shortly.

Skepticism is good. If you wish to reproduce the issues:

  1. Clean install of the latest version of Wireshark on macOS
  2. Start Wireshark and use about -> folders to identify your personal Lua script folder
  3. Stop Wireshark and copy the Lau scripts to the folder identified by Wireshark
  4. Start Wireshark and multiple errors will be displayed. Unfortunately I can not capture all of the errors in a screenshot because the error dialog expands to a height larger than my screen.

Here are some screenshots.

Screenshot 2025-04-26 at 09 05 16 Screenshot 2025-04-26 at 09 06 32

@mefistotelis
Copy link
Copy Markdown
Collaborator

Thanks for the screenshots.

So from them, it looks to me that the issue - as you rightfully stated - is that dofile on Mac only checks for files in applications CWD. But that means files can be placed within Personal Lua Plugins folder without issues, as long as they refer to each other using full paths - the placement of files does not matter and can be personal choice of users, they only have to provide the path.

My personal preference was to put symlinks to each file in the Personal Lua Plugins folder. That works on both Windows and Linux (though on these platforms full paths are not required, at least with Wireshark v4.0.17).

So if all the above is true, then the sentence "If you place all of the Lua files in **or under ** Wireshark's LUA folder, you will most likely encounter a frustrating series of problems." is not correct. It should instead convey the information that any folder can be used, as long as full path to it is provided within init.lua, and even if all the scripts are in Personal Lua Plugins folder, some versions of Wireshark will still require the full paths.

@securityguy
Copy link
Copy Markdown
Contributor Author

It should instead convey the information that any folder can be used, as long as full path to it is provided within init.lua, and even if all the scripts are in Personal Lua Plugins folder, some versions of Wireshark will still require the full paths.

On the current version of macOS (15.3.2) with the current version of Wireshark (4.4.6), that is not correct. Placing all of the files in the Personal Lua Plugins folder and changing the paths in init.lua does not work.

I have not tested on Linux, or Windows, or with older versions of Wireshark. I noted your mention of Wireshark 4.0.7. The current stable version of Wireshark is 4.4.6 and the previous stable version was 4.2.11. I doubt any users will be installing 4.0.7 these days.

Here is some additional information that you might find helpful:

I initially updated init.lua to include the files using their full paths, at which point one arrives at error round two:

Screenshot 2025-04-26 at 12 47 25 Screenshot 2025-04-26 at 12 48 02

Then, if you update dji-dumlv1-proto.lua to use full paths to the files it includes, that brings you to error round three because it appears to be loading the same files more than once:

Screenshot 2025-04-26 at 12 57 31

This behaviour appears consistent with the Wireshark documentation:

If Lua is enabled, Wireshark will first try to load a file named init.lua from the global plugins directory and then from the user’s personal plugins directory. Then all files ending with .lua are loaded from the global plugins directory and its subdirectories. Then all files ending with .lua in the personal Lua plugins directory and its subdirectories are loaded. The files are processed in ASCIIbetical order (compared byte-by-byte, as strcmp), descending into each subdirectory depth-first in order.

https://www.wireshark.org/docs/wsdg_html_chunked/wsluarm.html#:~:text=lua%20are%20loaded%20from%20the,subdirectory%20depth%2Dfirst%20in%20order.

There may be someone masochist enough to continue to tinker with the scripts in the Wireshark Lua folder and try to get them to work, but the obvious pragmatic solution at this point was to revert to the original files, place all of the files except init.lua outside of the Wireshark tree, update init.lua to point at them, test it, and then resolve the include issues within dji-dumlv1-proto.lua so that it can find scripts that are in the same directory.

Note that having resolved the above script inclusion issues, there was still error round four:

One script attempts to use the bit32 library, which was removed in Lua version 5.4 (released in 2020) and this results in a somewhat obscure "null" error. This suggests that the scripts have been incapable of running on the current version of Lua for at least four years.

I also observed that there has been an open issue on this problem since April 2020 (#153), that one user was still struggling in 2023, and another apparently felt it necessary to downgrade Wireshark in 2024.

Thank you for pointing out the issues in my initial PR, I sincerely appreciate it. That is one of the pleasures of collaboration on GitHub. This is your software and it's up to you what you wish to do with this PR. If you prefer another way of fixing this issue, that is of course your prerogative. I just hope that it does get fixed so that others don't have to invest their time to fix scripts that don't work.

As an aside, you might find increased interest in this decoder. I'm probably not the only person who has discovered that at least one current DJI product makes a stream of data in this protocol available via TCP.

@mefistotelis mefistotelis merged commit 8861550 into o-gs:master Apr 26, 2025
10 checks passed
@mefistotelis
Copy link
Copy Markdown
Collaborator

LGTM. Thank you for the detailed explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants