pcap-mode
pcap-mode copied to clipboard
emacs lisp pcap file viewer
- pcap-mode.el
Load an display a pcap file using the =tshark= utility.
To copy it yourself, simply:
#+NAME: setup_pcap_mode #+BEGIN_SRC sh git clone https://github.com/orgcandman/pcap-mode.git #+END_SRC
- Setup
In your =.emacs= initialization, add the following:
#+NAME: elisp-to-initialize #+BEGIN_SRC elisp (add-to-list 'load-path "/path/to/pcap-mode") (require 'pcap-mode) #+END_SRC
Then, when you open any .pcap file, the =tshark-executable= will be invoked against the filename, and the contents displayed in the buffer.
- Normally working with pcap-mode
When pcap-mode initially completes, it will display a summary-line listing of the packets. This is comparable to the tshark output when run against the pcap file. Example:
[[https://github.com/orgcandman/pcap-mode/blob/master/extra/pcapmode-core.png][file:extra/pcapmode-core.png]]
The mode map (customizable via =pcap-mode-map= variable) is defaulted as follows:
| Key | Function | Description |
|----------+-------------------------------------------+-------------------------------------------------------------------------------|
|
The filters are "smart" and will remember previous values set, making switching between filters convenient.
The packet viewer is a call to =pcap-mode--tshark-executable= passing the =pcap-mode--tshark-single-packet-filter= variable as well as the text frame.number==%d where %d is replaced with the packet number.
Example:
[[https://github.com/orgcandman/pcap-mode/extra/pcapmode-packet.png][file:extra/pcapmode-packet.png]]
- Hooks and variables
The following hooks are exposed by pcap-mode:
| hook variable | Hook entry notes | |-------------------------+-------------------------------------------------| | pcap-mode-hook | Hook run when pcap-mode starts | | pcap-mode-quit-hook | Hook run when pcap-mode window is closed. | | pcap-mode-reloaded-hook | Hook run when the main pcap windows is reloaded |
The following customizable variables exist | Variable Name | Description | |-------------------------------------------+----------------------------------------------------------------------------| | pcap-mode-tshark-executable | Path to the tshark binary | | pcap-mode-reload-pcap-when-filter-changes | Automatically reload pcap window buffer when changing filter | | pcap-mode-tshark-filter | Filter used when reloading the pcap viewer window | | pcap-mode-tshark-single-packet-filter | Filter used for single-packet viewing | | pcap-mode-dfilters-file | Location of wireshark dfilters file containing predefined display filters. |
- TODOS
The following list of todos should be eliminated as they are completed.
** Syntax table to make the list view pretty
** Unit tests? Maybe?
** display filter building wizard