我已按照(https://pcapdotnet.codeplex.com)上的教程设置我的程序包捕获,我被告知该数据包是由protobuf序列化的。目前将数据包转换为字符串(如底部所示)仅适用于一小部分信息,并不足以满足要求。
我无法弄清楚如何从下面将数据包转换为可接受的格式,以便能够将其反序列化为我可以使用的格式。下面是Wireshark中显示的数据包示例。
DRDNi|L.TE@4jcP""P.-h"
2 " : " 2 " " : " 2 " " " " " "
"
"
:
"
2
" $
"%
" 4
"
"
"
"#
"
"
"
" 4+
"
:
"
2
"
:
"
2
?A CCS2_121- / 01
" C ^
"
: "
2 " : "
我期待数据包的格式与此类似(根据我所说的)。
list: <
show_entity: <
entity: 29
name: "EX1_306"
tags: <
name: 45
value: 3
>
tags: <
name: 47
value: 4
>
tags: <
name: 48
value: 2
>
tags: <
name: 49
value: 1
>
tags: <
name: 201
value: 3
>
tags: <
name: 202
value: 4
>
tags: <
name: 203
value: 2
>
tags: <
name: 218
value: 1
>
>
下面的代码是我用来捕获数据包并将其转换为我可以读取一些信息的格式。我无法将protobuf反序列化为任何格式。
Private Sub PacketCap()
Dim Index As Integer = 0
Dim allDevices As IList(Of LivePacketDevice) = LivePacketDevice.AllLocalMachine
Dim device As LivePacketDevice = allDevices(1)
Dim Selecteddevice As PacketDevice = device
Using communicator As PacketCommunicator = Selecteddevice.Open(65536, PacketDeviceOpenAttributes.Promiscuous, 1000)
communicator.SetFilter("port 3724")
' read timeout
' start the capture
packetcount = 0
Invoke(New MethodInvoker(Sub()
MetroListbox1.Items.Add("Started Cap")
End Sub))
communicator.ReceivePackets(0, AddressOf PacketHandler)
End Using
End Sub
Private Sub MetroButton2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MetroButton2.Click
Dim N As New Threading.Thread(AddressOf PacketCap)
N.Start()
End Sub
Private Sub PacketHandler(ByVal packet As PcapDotNet.Packets.Packet)
Invoke(New MethodInvoker(Sub()
'ListBox1.Items.Add(packet.Timestamp.ToString("yyyy-MM-dd hh:mm:ss.fff") & " length:" & Convert.ToString(packet.Length) + packet.ToString("X2"))
If packet.Length < 200 Then
Else
Const LineLength As Integer = 64
Dim Info As String
Dim i As Integer = 0
While i <> packet.Length
Info = Info + (packet(i)).ToString("X2")
If (i + 1) Mod LineLength = 0 Then
End If
i += 1
End While
End If
End Sub))
对于几乎完成的&#39;抱歉。格式化,这是我的第一个问题。任何帮助表示赞赏
答案 0 :(得分:0)
电线规格为here。但是,在缺少模式(通常是通过.proto文件)的情况下,protobuf格式正式模糊不清。没有一种方法可以解释数据。但是,你可能会根据有线类型做一些疯狂的猜测(取标题的前3位)。
坦率地说,这将是如此命中和遗漏(主要是错过),我没有看到太多意义。