分布式网络包嗅探和处理框架。

netdumplings的Python项目详细描述


分布式网络包嗅探和处理框架。

有关详细信息,请参见documentation,以及netmomopackscape 使用Net饺子作为其 后端。Python3.6或更高版本是必需的。

安装

pip install netdumplings

分布式包嗅探?

net饺子允许您在任意数量的主机上运行多个包嗅探器。 那些嗅探者——叫做dumpling kitchens——通过任何嗅探网络 包到您的python代码进行处理。您的python代码实现为 名为dumpling chefs的类,使用网络包生成 饺子。饺子里的东西完全由你决定,但通常 描述嗅探网络数据包中包含的信息。

饺子大厨做的饺子是从饺子厨房送来的 发送到单个dumpling hub,该hub将它们转发到任何连接的 dumpling eaters用于显示或任何其他类型的处理,或 形象化。

显示了厨房厨师饺子hubeaters。 下面。你用绿色(厨师和食客)和网饺子写小片 剩下的:

docs/_static/overview.svg

饺子是通过网络在厨房、中心和食客之间发送的。

饺子长什么样?

饺子只是json数据。下面的饺子是厨师做的 为每次DNS查找生成一个饺子。

{"metadata":{"chef":"DNSLookupChef","creation_time":1515990765.925951,"driver":"packet","kitchen":"default_kitchen"},"payload":{"lookup":{"hostname":"myspace.com","when":1515990721.147}}}

"payload"部分由饺子厨师和 "metadata"当饺子发送到 厨房旁边的中心。

饺子厨师示例

下面的饺子厨师为每次DNS查找创建一个饺子(请参见 上面的饺子例子)。

importtimeimportnetdumplingsclassDNSLookupChef(netdumplings.DumplingChef):defpacket_handler(self,packet):# The incoming packet is a scapy packet object.# https://scapy.readthedocs.io# Ignore packets that we don't care about.ifnotpacket.haslayer('DNS'):return# Determine the name of the host that was looked up.dns_query=packet.getlayer('DNS')query=dns_query.fields['qd']hostname=query.qname.decode('utf-8')# Generate a dumpling payload from the DNS lookup.dumpling_payload={'lookup':{'hostname':hostname,'when':time.time(),}}# The handler is returning a dict, which will be automatically# converted into a dumpling and sent to nd-hub, which will then# forward it on to all the eaters.returndumpling_payload

吃饺子的例子

下面的食客打印每个从 nd-hub

importjsonimportnetdumplingsclassPrinterEater(netdumplings.DumplingEater):asyncdefon_connect(self,hub_uri,websocket):print(f'Connected to nd-hub at {hub_uri}')print('Waiting for dumplings...\n')asyncdefon_dumpling(self,dumpling):# The given dumpling is a netdumplings.Dumpling instance.dumpling_printable=json.dumps(dumpling.payload,indent=4)print(f'{dumpling_printable}\n')defdumpling_printer():eater=PrinterEater()eater.run()if__name__=='__main__':dumpling_printer()

更多信息

有关详细信息,请参见documentation

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java:字符串。RTL设备语言用标志“+”格式化,数字后加符号   java GAE作为桌面应用程序(Swing)的服务提供商   java将InputStream转换为FileInputStream不适用于Apache POI   java外部Voronoi库“网格”:什么是草图和处理?   重载重写的泛型方法java   java显示组织上设置的错误。springframework。验证。jsp中的错误对象   java一些Spring模型属性没有显示在我的JSP中   java无法编译Guava 23的SimpleTimeLimiter示例   java如何更改JTree中的“根”目录名?   java如何在安卓中对相对布局产生连锁反应?   java错误:org。冬眠例外SQLGrammarException:无法提取结果集,dateAccessed是未知列   如何使用java监听JSON文件更新   由抽象封闭类创建的匿名内部类能否通过反射确定实现类?