我需要有关在笔记本电脑上安装 Kaitai Struct 的帮助。
我安装了 python-kaitaistruct 并编译了网络文件。
但我收到一个导入错误:
Traceback (most recent call last):
File "test2.py", line 1, in <module>
from ethernet_frame import *
File "/home/bene/python/ethernet_frame.py", line 15, in <module>
from ipv6_packet import Ipv6Packet
File "/home/bene/python/ipv6_packet.py", line 17, in <module>
from ipv4_packet import Ipv4Packet
File "/home/bene/python/ipv4_packet.py", line 17, in <module>
from ipv6_packet import Ipv6Packet
ImportError: cannot import name 'Ipv6Packet
我的文件夹如下所示:
insgesamt 76K
drwxr-xr-x 3 bene bene 330 19. Jan 16:03 .
drwx------ 24 bene bene 4,0K 19. Jan 16:06 ..
-rw-r--r-- 1 bene bene 42 5. Jan 12:38 country.py
-rw-r--r-- 1 bene bene 8,0K 5. Jan 12:09 dns_packet.py
-rw-r--r-- 1 bene bene 1,6K 5. Jan 12:09 ethernet_frame.py
-rw-r--r-- 1 bene bene 3,0K 5. Jan 12:09 icmp_packet.py
-rw-r--r-- 1 bene bene 7,7K 5. Jan 12:09 ipv4_packet.py
-rw-r--r-- 1 bene bene 2,7K 5. Jan 12:09 ipv6_packet.py
-rw-r--r-- 1 bene bene 6,4K 5. Jan 12:09 microsoft_network_monitor_v2.py
-rw-r--r-- 1 bene bene 7,0K 5. Jan 12:09 pcap.py
drwxr-xr-x 2 bene bene 180 5. Jan 12:12 __pycache__
-rw-r--r-- 1 bene bene 1,1K 5. Jan 12:09 tcp_segment.py
-rw-r--r-- 1 bene bene 518 5. Jan 12:32 test1.py
-rw-r--r-- 1 bene bene 596 19. Jan 15:56 test2.py
-rw-r--r-- 1 bene bene 667 5. Jan 12:38 test.py
-rw-r--r-- 1 bene bene 880 5. Jan 12:09 udp_datagram.py
-rw-r--r-- 1 bene bene 986 5. Jan 12:09 windows_systemtime.py
和我执行的文件:
from ethernet_frame import *
import socket
s = socket.socket(socket.AF_PACKET,socket.SOCK_RAW,socket.ntohs(3))
def network(buf):
io = BytesIO(buf)
ksio = KaitaiStream(io)
pkt = EthernetFrame(ksio)
dummy = pkt.ipv4_body.src_ip_addr
print(dummy)
while True:
p = s.recvfrom(65565)
network(p)
有人可以帮助我,也许我安装错了?或完整指南如何安装和使用它会很酷:DD
谢谢<3