Hi, I'm writing a Lua program to process data that captured by tshark, and I'm in need for a filter to separate inbound traffic from outbound traffic in our network to process each group alone. Can some one help me in this, because I'm new in both: Lua and Wireshark. Thanks

asked 25 Jan '12, 22:39

Leena's gravatar image

Leena
51131721
accept rate: 0%

edited 26 Jan '12, 00:46


I'm assuming you're interested in IP traffic only.

You would create two taps (aka "Listeners") -- one filtered for incoming packets to your host and another for outgoing:

local HOST_IP = '1.2.3.4'

local tap_in = Listener.new(nil, 'ip.dst=='..HOST_IP)
local tap_out = Listener.new(nil, 'ip.src=='..HOST_IP)

-- handles packets going to $HOST_IP
function tap_in.packet(pinfo, buf)
    print('#'..pinfo.number, '<IN>', tostring(buf))
end

-- handles packets going out from $HOST_IP
function tap_out.packet(pinfo, buf)
    print('#'..pinfo.number, '<OUT>', tostring(buf))
end


Copy this file to a temporary directory (e.g., /tmp/test.lua), and run it from TShark as follows:

$ tshark -Xlua_script:/tmp/test.lua

You can also load this from Wireshark (as shown in a recent post).

link

answered 02 Feb '12, 18:53

helloworld's gravatar image

helloworld
2.6k21739
accept rate: 27%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×245
×121

Asked: 25 Jan '12, 22:39

Seen: 1,401 times

Last updated: 02 Feb '12, 18:53

powered by OSQA