s_sniffer.py 文件源码

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

项目:smart_sniffer 作者: ScarWar 项目源码 文件源码
def update_next_packet(self):
        packet = s.sniff(count=1)  # filter = "tcp.len > 0",
        packet = packet[0]

        if s.IP not in packet:
            return

        ip_send = packet[s.IP].src
        ip_rec = packet[s.IP].dst

        if ip_send != self.our_ip and ip_rec != self.our_ip:
            return
        print packet.summary()
        if make_stamp(packet) is not None:
            ip_send, ip_rec, protocol = make_stamp(packet)
            three_tuple = [ip_send, ip_rec, protocol]

            stamp = self.decide_stamp(three_tuple)

            if self.sessions.get(stamp) is None:
                threading.Thread(target=self.set_session, args=[packet, stamp, self.our_ip]).start()
            else:
                threading.Thread(target=self.sessions[stamp].update_session, args=[packet]).start()

                # in case we done working on connection
                # we will order by time and add to global list
                if self.sessions[stamp].got_fin is True:
                    to_add = self.sessions.pop(stamp)
                    sorted(to_add.income, key=key_func)
                    sorted(to_add.outcome, key=key_func)
                    sorted(to_add.combined, key=key_func)
                    lst.add(to_add)
        else:
            print "[Error] - Shit happens"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号