Skip to content

apconole/pcap-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pcap-mode.el

Load an display a pcap file using the tshark utility.

To copy it yourself, simply:

git clone https://github.com/orgcandman/pcap-mode.git

Setup

In your .emacs initialization, add the following:

(add-to-list 'load-path "/path/to/pcap-mode")
(require 'pcap-mode)

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:

extra/pcapmode-core.png

The mode map (customizable via pcap-mode-map variable) is defaulted as follows:

KeyFunctionDescription
<return>pcap-mode-view-pkt-contentsPop up a separate buffer with the contents of a specific packet
cpcap-mode-search-framesSearch frame contents
fpcap-mode-set-tshark-filterChange the buffer local display filter applied to the pcap file.
Fpcap-mode-set-named-filterChoose a predefined filter and apply it.
gpcap-mode-clear-filterClear the current filter.
qanonymous call to kill-bufferDestroys the pcap buffer and all open packet buffers.
rpcap-mode-reload-fileReload the current pcap buffer.
C-u fpcap-mode-set-tshark-single-packet-filterChange the command line settings passed when running against a single packet.
spcap-mode-set-tshark-single-packet-filterSame as ‘C-u f’ keybind.
tpcap-mode-toggle-conversation-viewSets the tshark options to follow tcp streams.
C-u tpcap-mode-toggle-conversation-viewSets the tshark options to follow a specific type of stream (prompted)
C-c C-danonymous debug functionDisplay some debugging information

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:

extra/pcapmode-packet.png

Hooks and variables

The following hooks are exposed by pcap-mode:

hook variableHook entry notes
pcap-mode-hookHook run when pcap-mode starts
pcap-mode-quit-hookHook run when pcap-mode window is closed.
pcap-mode-reloaded-hookHook run when the main pcap windows is reloaded

The following customizable variables exist

Variable NameDescription
pcap-mode-tshark-executablePath to the tshark binary
pcap-mode-reload-pcap-when-filter-changesAutomatically reload pcap window buffer when changing filter
pcap-mode-tshark-filterFilter used when reloading the pcap viewer window
pcap-mode-tshark-single-packet-filterFilter used for single-packet viewing
pcap-mode-dfilters-fileLocation 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

About

emacs lisp pcap file viewer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •