Skip to content

Instantly share code, notes, and snippets.

@quarnster
Created October 6, 2012 19:22
Show Gist options
  • Save quarnster/3845849 to your computer and use it in GitHub Desktop.
Save quarnster/3845849 to your computer and use it in GitHub Desktop.
Wireshark lua script for capturing audio/mpeg content
-- tshark -i tap0 -Xlua_script:./script.lua -f "src port 80" -O HTTP > /dev/null
function lastfile()
local max = 0
for filename in io.popen("ls data/*.mp3"):lines() do
local curr = tonumber(string.sub(filename, filename:find("%d+")))
if curr > max then
max = curr
end
end
return max
end
function install_listener()
local http_media_f = Field.new("media")
local tap = Listener.new(nil, 'tcp.srcport == 80 && http.content_type == "audio/mpeg" && media')
local i = lastfile()
function tap.packet(pinfo,tvb)
local http_media = http_media_f()
i = i+1
local fn = "data/"..tostring(i)..".mp3"
local file = io.open(fn, "wb")
file:write(http_media.value:tvb()():string())
file:close()
io.stderr:write("dumped to "..fn.."\n")
end
end
install_listener()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment