kamene

网络数据包和 pcap 文件制作/嗅探/操纵/可视化安全工具。最初于 2015 年从 scapy 分支而来,此后提供了 python3 兼容性。「Network packet and pcap file crafting/sniffing/manipulation/visualization security tool (based on scapy) with python3 compatibility」

Github星跟踪图

kamene (formerly known as "scapy for python3" or scapy3k)

General

Follow @pkt_kamene for recent news. Original documentation updated for kamene

News

We underwent naming transition (of github repo, pip package name, and python package name), which will be followed by new functionality. More updates to follow.

Kamene is included in the Network Security Toolkit Release 28. It used to be included in NST since Release 22 under former name.

History

This is a fork of scapy (http://www.secdev.org) originally developed to implement python3 compatibility. It has been used in production on python3 since 2015 (while secdev/scapy implemented python3 compatibility in 2018). The fork was renamed to kamene in 2018 to reduce any confusion.

These features were first implemented in kamene and some of them might have been reimplemented in scapy by now:

  • replaced PyCrypto with cryptography.io (thanks to @ThomasFaivre)
  • Windows support without a need for libdnet
  • option to return Networkx graphs instead of image, e.g. for conversations
  • replaced gnuplot with Matplotlib
  • Reading PCAP Next Generation (PCAPNG) files (please, add issues on GitHub for block types and options, which need support. Currently, reading packets only from Enhanced Packet Block)
  • new command tdecode to call tshark decoding on one packet and display results, this is handy for interactive work and debugging
  • python3 support

Installation

Install with python3 setup.py install from source tree (get it with git clone https://github.com/phaethon/kamene.git) or pip3 install kamene for latest published version.

On all OS except Linux libpcap should be installed for sending and receiving packets (not python modules - just C libraries) or winpcap driver on Windows. On some OS and configurations installing libdnet may improve experience (for MacOS: brew install libdnet). On Windows libdnet is not required. On some less common configurations netifaces may improve experience.

Usage

Use bytes() (not str()) when converting packet to bytes. Most arguments expect bytes value instead of str value except the ones, which are naturally suited for human input (e.g. domain name).*

You can use kamene running kamene command or by importing kamene as library from interactive python shell (python or ipython) or code.
Simple example that you can try from interactive shell:

from kamene.all import *
p = IP(dst = 'www.somesite.ex') / TCP(dport = 80) / Raw(b'Some raw bytes')
# to see packet content as bytes use bytes(p) not str(p)
sr1(p)

Notice 'www.somesite.ex' as a string, and b'Some raw bytes' as bytes. Domain name is normal human input, thus it is string, raw packet content is byte data. Once you start using, it will seem easier than it looks.

Use ls() to list all supported layers. Use lsc() to list all commands.

Currently, works on Linux, Darwin, Unix and co. Using python 3.4+ on Ubuntu, MacOS, FreeBSD, Windows 10 for testing.

Compatible with scapy-http module

Reading huge pcap file

rdpcap reads whole pcap file into memory. If you need to process huge file and perform some operation per packet or calculate some statistics, you can use PcapReader with iterator interface.

with PcapReader('filename.pcap') as pcap_reader:
  for pkt in pcap_reader:
    #do something with the packet

主要指标

概览
名称与所有者phaethon/kamene
主编程语言Python
编程语言Python (语言数: 3)
平台
许可证GNU General Public License v2.0
所有者活动
创建于2015-01-29 10:36:27
推送于2021-08-04 10:48:43
最后一次提交2021-08-04 13:48:43
发布数21
最新版本名称v0.32 (发布于 )
第一版名称v0.2 (发布于 )
用户参与
星数869
关注者数47
派生数190
提交数628
已启用问题?
问题数149
打开的问题数68
拉请求数98
打开的拉请求数4
关闭的拉请求数14
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?