在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:JuliaIO/Pcap.jl开源软件地址:https://github.com/JuliaIO/Pcap.jl开源编程语言:Julia 100.0%开源软件介绍:PcapPcap contains libpcap bindings for Julia as well as logic to parse and extract useful data from packet captures Examplefunction display_eth_hdr(ethhdr::EthHdr)
println("Ethernet Header")
println(" |- Src Mac : $(ethhdr.src_mac)")
println(" |- Dest Mac : $(ethhdr.dest_mac)")
println(" |- Type : $(ethhdr.ptype)")
end # function display_ip_hdr
function display_ip_hdr(iphdr::IpHdr)
println("IP Header")
println(" |- Version : $(iphdr.version)")
println(" |- Length : $(iphdr.length)")
println(" |- Type of Service : $(iphdr.services)")
println(" |- Total Length : $(iphdr.totlen)")
println(" |- ID : $(iphdr.id)")
println(" |- TTL : $(iphdr.ttl)")
println(" |- Protocol : $(iphdr.protocol)")
println(" |- Src Ip : $(iphdr.src_ip)")
println(" |- Dest Ip : $(iphdr.dest_ip)")
println(" |- Checksum : 0x$(hex(iphdr.checksum,4))")
end # function display_ip_hdr
function display_udp_hdr(udphdr::UdpHdr)
println("UDP Header")
println(" |- Src Port : $(udphdr.src_port)")
println(" |- Dest Port : $(udphdr.dest_port)")
println(" |- Length : $(udphdr.length)")
println(" |- Checksum : 0x$(hex(udphdr.checksum, 4))")
print(" |- Data : ")
n = 0
for byte = udphdr.data
if n % 16 == 0 && n != 0
print("\n ")
end
print("$(hex(byte, 2)) ")
n = n + 1
end
end # function display_udp_hdr
cap = PcapOffline("data/dns-query-response.pcap")
rec = pcap_get_record(cap)
layers = decode_pkt(rec.payload)
println("---------- UDP Packet ----------\n")
display_eth_hdr(layers.datalink)
display_ip_hdr(layers.network)
if (layers.network.protocol == 17)
display_udp_hdr(layers.protocol)
end
println("\n\n--------------------------------\n") Output
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论