首页 > 其他分享 >第二周进展

第二周进展

时间:2023-11-26 22:12:23浏览次数:30  
标签:dissector 进展 -- fields add 第二周 undeny local

本周计划完成任务

本人所负责的不可否认性模块全部代码的初步编写

本周实际完成情况

通过解析数据,获取证书信息

相关代码

local version_str = string.match(_VERSION, "%d+[.]%d*")
local version_num = version_str and tonumber(version_str) or 5.1
local bit = (version_num >= 5.2) and require("bit32") or require("bit")

-- create a new dissector to decode rtp private payload
local NAME1          = "undeny"
local PORT           = 5004
local RTP_PROTO_TYPE = 106


local undeny            = Proto(NAME1, "undeny Protocol")

-- create fields of undeny
fields_M             = ProtoField.uint8 (NAME1 .. ".M", "M", base.HEX,Payload_type,0x80)
fields_pt            = ProtoField.uint8 (NAME1 .. ".PT", "PT", base.DEC,Payload_type,0x7F)
fields_seqno         = ProtoField.uint16(NAME1 .. ".seqno", "Sequence number")
fields_h264bytes     = ProtoField.bytes(NAME1 .. ".bytes", "H264Data")
fields_fec           = ProtoField.bytes(NAME1 .. ".fec", "FEC Payload")

undeny.fields           = { fields_M, fields_pt, fields_seqno, fields_h264bytes,fields_fec }

local RTP_dis        = Dissector.get("rtp")
local H264_dis       = Dissector.get("h264")
local Data_dis       = Dissector.get("data")


-- dissect packet
function undeny.dissector(tvb, pinfo, tree)
	length = tvb:len()
	if length == 0 then return end
    -- decode private header
    local subtree = tree:add(undeny, tvb(0,3))
	subtree:add(fields_M, tvb(0,1))
	subtree:add(fields_pt, tvb(0,1))
    subtree:add(fields_seqno, tvb(1,2))

    -- show protocol name in protocol column
    pinfo.cols.protocol = undeny.name
   	
	local fec_id = tvb(0,1):uint()
	local fec_type = bit.band(fec_id,0x7F)
	if fec_type == 109 then 
		tree:add(fields_fec,tvb(3))
	else 
		H264_dis:call(tvb(3):tvb(), pinfo, tree)
	end 
end


--decode first layer  as rtp
local udp_dissector_table = DissectorTable.get("udp.port")
udp_dissector_table:set(PORT,RTP_dis)

-- register this dissector
-- DissectorTable.get("rtp.pt"):add(PORT, undeny)
--decode private protocol layer  3-bytes private datas + standard h264
local rtp_dissector_table = DissectorTable.get("rtp.pt")
rtp_dissector_table:set(RTP_PROTO_TYPE,undeny)
do
    local undeny_proto = Proto("undeny", "Undeny Protocol")
    
    local f_user_certificate = ProtoField.bytes("undeny.certificate", "User Certificate")
    
    undeny_proto.fields = { f_user_certificate }
    
    function undeny_proto.dissector(buffer, pinfo, tree)
        local length = buffer:len()
        if length == 0 then return end
    
        local subtree = tree:add(undeny_proto, buffer(), "User Certificate")
    
        local x509_dissector = Dissector.get("x509")  -- 获取X.509解析器
        x509_dissector:call(buffer, pinfo, tree)  -- 调用X.509解析器来解析证书
    
        local cert_data = buffer:string()  -- 获取证书数据
        if is_rsa_2048_certificate(cert_data) then
            subtree:add(f_user_certificate, buffer(0, length))  -- 将证书添加到协议树中
            subtree:append_text(" (RSA-2048)")  -- 添加证书类型描述
        else
            subtree:add(f_user_certificate, buffer(0, length))
        end
    end
    
    local tcp_port = DissectorTable.get("tcp.port")
    tcp_port:add(443, undeny_proto)  -- 将端口号改为443
end

未完成原因:感觉有点难,迈出第一步有点艰难,熟悉上手后会好很多

本周遇到的问题

代码载入wireshark后,出现如下报错:

Lua: Error during loading:C:\Program Files Wireshark\undeny1.lua:83: attempt toindex local tls dissector tab' (a nil value)stack traceback:
C: Program Files Wireshark undeny1.lua:83: inmain chunk[C]: in function 'dofile'C:\Program Files Wireshark init.lua:669: in main
chunk
询问GPT解答:

目前版本的插件载入后报错,过滤不到相应的包

标签:dissector,进展,--,fields,add,第二周,undeny,local
From: https://www.cnblogs.com/wenxinhe/p/17858073.html

相关文章

  • 第二周进展
    Wiresharklua插件开发第二周进展本周在Wiresharklua插件开发方面取得了以下进展:1.Lua简介Lua是一种轻量级的脚本语言,它不需要编译器等额外的工具,可以直接进行解释执行。Lua的基本语法可以参考官网或者菜鸟教程。Wireshark内置对Lua脚本的支持,无需额外的配置,使用起来非常方便......
  • 第二周进展
    本周计划:完成自己的部分遇到了许多的问题,比如插件载入后每次报错:Lua:Errorduringloading:C:\ProgramFiles\Wireshark\plugins\RSA.lua:42:badargument#1to'add'(DissectorTable_add:invalidintegerorrange)stacktraceback: [C]:infunction'add' C:\Prog......
  • Wireshark lua插件开发第二周进展
    1.Lua简介Lua是一种轻量级的脚本语言,解释执行,不需要编译器之类的。Lua的基本语法可以参考官网或者菜鸟教程。Wireshark内置了对Lua脚本的支持,可以直接编写Lua脚本,无需配置额外的环境,使用起来还是非常方便的。[WiresharkDeveloper'sGuide]里的第10章和第11章都是关于Lua......
  • 2023-2024-1 20232428 《网络空间安全导论》第二周学习总结
    1.教材学习内容总结2.基于AI的学习......
  • 2023-2024-1 20232315 《网络空间安全导论》第二周学习
      一、 我最近初步了解了密码学基础,了解了其起源、初步发展与应用、包含的主要内容以及在当下的情况,下面是大概的思维导图: 二、下面是我学习后的问题:1、信息加密与信息隐藏有何本质区别?解决方法:问AI答案: 问题2:当今密码学面临哪些挑战,该如何迎接这些挑战?答案:......
  • 军工物联网的进展和困难
    军工物联网的进展和困难可以从以下几个方面来讨论:进展:技术发展:物联网技术不断发展,已经可以实现物物相连,实时监测,信息共享等功能,这为军工物联网的发展提供了技术基础。军事应用:军工物联网已经在军事领域得到了一定的应用,例如战场环境监测、武器装备智能化、后勤保障管理等。这些应用......
  • 《2023-2024-1 20232415 《网络》第二周学习总结》
      本周的网络空间安全课程的学习主要围绕密码科学技术展开。通过学习与探究,我了解了密码科学技术的基本原理,应用方式以及发展前景。 教材学习中的问题:问题1:不同密码表对文字的加密方式各不相同,较为复杂,难以理解。问题1解决方案:通过反复阅读,探寻不同密码表之间的规律,可以有......
  • 2023-2024-1 20232327《网络空间安全导论》第二周学习总结
    2023-2024-120232327《网络空间安全导论》第二周学习总结教材学习内容总结1.密码学历史悠久,主要分为古典密码、机械密码和线代密码;2.密码学研究主要有密码分析,密码理论,密码工程与应用以及密码管理;3.密码体制的分类:单钥密码体制和双钥密码体制;4.密码分析方法有穷举攻击法、......
  • 第二周
    Shell编程语言学习了Shell编程的基础知识,包括命令行参数、变量、条件判断、循环结构等。并且通过编写脚本演示了Shell脚本的实际应用。文件和系统管理学习了如何在Linux系统中创建、复制、移动、重命名、删除等文件和目录,以及如何使用chmod命令为文件添加权限。同时,我们还学习了......
  • 网空第二周
    (2023-2024-1)(20232410)《网络》第2周学习总结教材学习内容总结密码学基本概念和主要研究方向教材学习中的问题和解决过程问题:为何说一次一密在理论上是安全的,在实际应用中存在什么问题问题解决方案:运用ai提问回答参考资料《网络空间安全导论》网络空间安全导论书单......