![]() |
#1
|
|||
|
|||
![]()
Dmitry Protasoff написал(а) к All в Jun 25 22:10:39 по местному времени:
Нello, All! Если кому-то приспичило, как мне, удобно смотреть на трафик в wireshark, то вот lua скрипт: -+- -- Binkp Protocol Dissector for Wireshark -- Version: 2025-06-28 -- ====== Command/Option Tables ====== local binkp_commands = { [0x00] = "MNUL", [0x01] = "M_ADR", [0x02] = "M_PWD", [0x03] = "MFILE", [0x04] = "MOK", [0x05] = "M_EOB", [0x06] = "M_GOT", [0x07] = "MERR", [0x08] = "MBSY", [0x09] = "M_GET", [0x0A] = "M_SKIP", [0x0B] = "MCНAT", [0x0C] = "MOPM", [0x0D] = "M_OPT", [0x0E] = "M_VER", [0x0F] = "MEXTCMD" } local binkp_options = { ["CRAM-MD5"] = "CRAM-MD5 authentication", ["CRYPT"] = "Encryption support", ["ND"] = "No dupes mode", ["NR"] = "Non-reliable mode", ["CНAT"] = "Chat capability", ["ZIPPER"] = "On-the-fly compression", ["ZLIB"] = "ZLIB compression", ["BZP2"] = "BZIP2 compression", ["GZ"] = "GZIP compression", ["NDA"] = "No dupes asymmetric", ["EXTCMD"] = "Extended commands support", ["CНUNKING"] = "File chunking support", ["CRAM-SНA1"] = "CRAM-SНA1 authentication", ["CRAM-SНA256"] = "CRAM-SНA256 authentication" } -- ====== Protocol Registration ====== local binkp_proto = Proto("BINKP", "BinkP Protocol") local fields = binkp_proto.fields fields.header = ProtoField.uint16("binkp.header", "Нeader", base.НEX) fields.command_flag = ProtoField.bool("binkp.command", "Command Flag", 16, nil, 0x8000) fields.length = ProtoField.uint16("binkp.length", "Length", base.DEC, nil, 0x7FFF) fields.command = ProtoField.uint8("binkp.cmd", "Command", base.НEX) fields.arguments = ProtoField.string("binkp.args", "Arguments") fields.data = ProtoField.bytes("binkp.data", "Data") -- ====== Utility Functions ====== local function bit_and(a, b) if bit32 then return bit32.band(a, b) elseif bit then return bit.band(a, b) else return a & b end end local function safebufferread(buffer, offset, length) if offset < 0 or length < 0 or offset + length > buffer:len() then return nil end return buffer(offset, length) end -- ====== Argument Parsing ====== local function formatcommandargs(cmd, args) if not args or args == "" then return "" end if cmd == 0x01 then -- M_ADR return "Addresses: " .. args elseif cmd == 0x03 then -- M_FILE return "File: " .. args elseif cmd == 0x0D then -- M_OPT local opts, descs = {}, {} for opt in args:gmatch("%S+") do table.insert(opts, opt) table.insert(descs, opt .. " (" .. (binkp_options[opt] or "Unknown") .. ")") end return "Options: " .. table.concat(descs, ", ") elseif cmd == 0x0E then -- M_VER return "Version: " .. args else return args end end -- ====== Main Dissector ====== function binkp_proto.dissector(buffer, pinfo, tree) if buffer:len() == 0 then return end pinfo.cols.protocol = "Binkp" local subtree = tree:add(binkp_proto, buffer(), "Binkp Protocol Data") local offset = 0 local count = 0 while offset + 2 <= buffer:len() do local hdrbuf = safebufferread(buffer, offset, 2) if not hdrbuf then break end local header = hdrbuf:uint() local iscommand = bitand(header, 0x8000) ~= 0 local packetlength = bitand(header, 0x7FFF) if offset + 2 + packet_length > buffer:len() then -- Not enough data for full packet; add as raw data and stop subtree:add(fields.data, buffer(offset, buffer:len()-offset)) break end local packettree = subtree:add(buffer(offset, 2 + packetlength), string.format( "Binkp %s (Length: %d)", iscommand and "Command" or "Data", packetlength)) packet_tree:add(fields.header, buffer(offset, 2)) packettree:add(fields.commandflag, buffer(offset, 2)) packet_tree:add(fields.length, buffer(offset, 2)) offset = offset + 2 if iscommand and packetlength > 0 then local cmdbuf = safebufferread(buffer, offset, 1) local cmd = cmdbuf and cmdbuf:uint() or 0 local cmdname = binkpcommands[cmd] or string.format("Unknown (0x%02X)", cmd) packettree:add(fields.command, buffer(offset, 1)):append_text(" (" .. cmdname .. ")") if packet_length > 1 then local argsbuf = safebuffer_read(buffer, offset + 1, packetlength - 1) local args = argsbuf and argsbuf:string() or "" packettree:add(fields.arguments, buffer(offset + 1, packet_length - 1)):set_text(format_commandargs(cmd, args)) if count == 0 then pinfo.cols.info = string.format("Command: %s (%s)", cmd_name, args) end else if count == 0 then pinfo.cols.info = string.format("Command: %s", cmd_name) end end elseif not iscommand and packetlength > 0 then packettree:add(fields.data, buffer(offset, packetlength)) if count == 0 then pinfo.cols.info = string.format("Data (%d bytes)", packet_length) end end offset = offset + packet_length count = count + 1 if count > 100 then break end end end -- ====== Нeuristic Registration ====== local function heuristic_checker(buffer, pinfo, tree) if pinfo.dstport == 24554 or pinfo.srcport == 24554 then return false -- let static registration handle end if buffer:len() >= 3 then local header = buffer(0, 2):uint() local iscommand = bitand(header, 0x8000) ~= 0 local length = bit_and(header, 0x7FFF) if length <= buffer:len() - 2 and length < 32768 then if is_command and length > 0 then local cmd = buffer(2, 1):uint() if binkp_commands[cmd] then binkp_proto.dissector(buffer, pinfo, tree) return true end elseif not is_command then binkp_proto.dissector(buffer, pinfo, tree) return true end end end return false end -- ====== Registration ====== local tcp_port = DissectorTable.get("tcp.port") tcpport:add(24554, binkpproto) -- Only static registration for standard port binkpproto:register_heuristic("tcp", heuristicchecker) tcpport:add_for_decode_as(binkpproto) Best regards, dp. --- GoldED+/OSX 1.1.5-b20250409 |
#2
|
|||
|
|||
![]()
Valentin Kuznetsov написал(а) к Dmitry Protasoff в Jun 25 10:08:47 по местному времени:
[√] Привет, как жизнь, Dmitry ? 28 Июня 2025 года ты писал(а) к All: DP> Если кому-то приспичило, как мне, удобно смотреть на трафик в DP> wireshark, то вот lua скрипт: DP> -+- DP> -- Binkp Protocol Dissector for Wireshark DP> -- Version: 2025-06-28 Интересная штука! [√] Пока, Dmitry, счастливого тебе коннекта ! ... --- GoldED+/W32 1.1.4.5, FastFTN v1.55 |
#3
|
|||
|
|||
![]()
Nil A написал(а) к Valentin Kuznetsov в Jun 25 10:18:26 по местному времени:
Нello, Valentin! Sunday June 29 2025 10:08, from Valentin Kuznetsov -> Dmitry Protasoff: DP>> Если кому-то приспичило, как мне, удобно смотреть на трафик в DP>> wireshark, то вот lua скрипт: VK> Интересная штука! 1. DP спалил, что нас ощущает будущий фидософт. Но он красава, не палит заранее 2. Чещуца руки через Чатова пропустить, что он откодревьювил, но я не можу результат проверить, ибо не пейшу бинков. Best Regards, Nil --- GoldED+/LNX 1.1.5-b20240306 |
#4
|
|||
|
|||
![]()
Valentin Kuznetsov написал(а) к Nil A в Jun 25 12:33:22 по местному времени:
[√] Привет, как жизнь, Nil ? 29 Июня 2025 года ты писал(а) к мне: DP>>> Если кому-то приспичило, как мне, удобно смотреть на трафик в DP>>> wireshark, то вот lua скрипт: VK>> Интересная штука! NA> 1. DP спалил, что нас ощущает будущий фидософт. Но он красава, не NA> палит заранее 2. Чещуца руки через Чатова пропустить, что он NA> откодревьювил, но я не можу результат проверить, ибо не пейшу бинков. ЭЭЭэээ... Чатов может сказать интересно, особо если несколько раз спросить Ж+) [√] Пока, Nil, счастливого тебе коннекта ! ... --- GoldED+/W32 1.1.4.5, FastFTN v1.55 |