sniffer.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:Charlie 作者: nxintech 项目源码 文件源码
def recv(self):
        while True:

            pkt, sa_ll = self.sock.recvfrom(MTU)

            if type == socket.PACKET_OUTGOING and self.on_ip_outgoing is None:
                continue
            elif self.on_ip_outgoing is None:
                continue

            if len(pkt) <= 0:
                break

            eth_header = struct.unpack("!6s6sH", pkt[0:14])

            dummy_eth_protocol = socket.ntohs(eth_header[2])

            if eth_header[2] != ETH_P_IP:
                continue

            ip_header = pkt[14:34]
            payload = pkt[14:]

            self.__process_ipframe(sa_ll[2], payload)


# run code
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号