CARNIVORE

The "Carnivore Library for Processing" is a TCP/UDP packet sniffer library for the Processing programming language. The Carnivore Library is based on Jpcap, a java native interface for the libpcap standard sniffing library.

Install

To install the Carnivore Library for Processing:

Windows people must first install Winpcap

Mac people must open a Terminal and execute this commmand (you must do this each time you reboot your mac):
sudo chmod 777 /dev/bpf*

Linux people should read the Linux Readme

Automatic Install
You can install Carnivore automatically using Processing's built-in library importer. In Processing select menu "Sketch / Import Library... / Add Library..." and then search on "Carnivore" to install.

Manual Install
1) quit Processing
2) download Carnivore
3) unzip the download folder and copy the "carnvore" folder into the "libraries" folder in your sketchbook.
4) launch Processing

You should preserve the folder structure, like this:





Sample Code

Example #1: print packets to the debug window

Example #2: display nodes in a visual map

Example #3: like #2 but with more features (color, objects for nodes and links, offline mode)



Constructor
CarnivoreP5(PApplet parent)
Example: CarnivoreP5 c = new CarnivoreP5(this);
Creates the Carnivore object



Event Handler
void packetEvent(CarnivorePacket packet)
This method is automagically called each time a new packet arrives.



"CarnivoreP5" Class Methods
void setVolumeLimit(int i)
Example: c.setVolumeLimit(7);
Output fewer packets from Carnivore. Useful for high volume networks.

void setShouldSkipUDP(boolean b)
Example: c.setShouldSkipUDP(true);
Tells Carnivore to skip UDP packets. Options are: "true" or "false" (default)



"CarnivorePacket" Class members
String ascii()
The content of the packet converted into ASCII characters. This is handy if you actually want to read the packets. (Note: any bytes outside of the simple ASCII range [greater than 31 and less than 127] are printed as whitespace.)

byte[] data
The content of the packet as bytes.

String dateStamp()
The date of the packet in the format hour:minute:second:millisecond.

int intTransportProtocol
The packet type as an int, either 6 (TCP) or 17 (UDP).

IPAddress receiverAddress
The packet's receiver IP address. Use
receiverAddress.ip
to get the IP address as a string.

int receiverPort
The packet's receiver port.

String receiverSocket()
The packet's receiver formated as an "IPaddress:Port" string.

IPAddress senderAddress
The packet's sender IP address. Use
senderAddress.ip
to get the IP address as a string.

int senderPort
The packet's sender port.

String senderSocket()
The packet's sender formated as an "IPaddress:Port" string.

String strTransportProtocol
The packet type as a string, either "TCP" or "UDP".

String toString()
Returns entire packet as a String.



"IPAddress" Class members
String ip
The IP address in 123.45.67.89 format.

int octet1()
The first octet of the address.

int octet2()
The second octet of the address.

int octet3()
The third octet of the address.

int octet4()
The fourth octet of the address.



"Log" Class Method
void setDebug(boolean b)
Example: Log.setDebug(true);
Turns debugging output on or off. Options are: "true" or "false" (default)