A highly configurable multi-threaded packet sniffer and parser build in rust-lang.
the Json file is generated like given below :
```Json
[{ "Ok": { "len": 11, "timestamp": "1234567890.123456", "headers": [{ "Tls": { ... } }, { "Tcp": { ... } }, { "Ipv4": { ... } }, { "Ether": { ... } } ], "remaining": [...] } }, ... ]
```
Ensure that you have libpcap-dev
(ubuntu) or the corresponding package installed on your system.
Run the following commands in the command line inside the folder :
zsh
cargo install --path .
To Capture packets and print them onto the console : ```zsh
52.216.185.195 | 443 | 10.20.197.103 | 38522 | Tcp | 10078 | 1562310108.589373
10.20.197.103 | 38522 | 52.216.185.195 | 443 | Tcp | 54 | 1562310108.589468
52.216.185.195 | 443 | 10.20.197.103 | 38522 | Tcp | 10078 | 1562310108.890490
10.20.197.103 | 38522 | 52.216.185.195 | 443 | Tcp | 54 | 1562310108.890547
52.216.185.195 | 443 | 10.20.197.103 | 38522 | Tcp | 1486 | 1562310109.197739
10.20.197.103 | 38522 | 52.216.185.195 | 443 | Tcp | 54 | 1562310109.197795
52.216.185.195 | 443 | 10.20.197.103 | 38522 | Tcp | 1486 | 1562310109.197841
10.20.197.103 | 38522 | 52.216.185.195 | 443 | Tcp | 66 | 1562310109.197865
52.216.185.195 | 443 | 10.20.197.103 | 38522 | Tcp | 2918 | 1562310109.197887
10.20.197.103 | 38522 | 52.216.185.195 | 443 | Tcp | 74 | 1562310109.197906
52.216.185.195 | 443 | 10.20.197.103 | 38522 | Tcp | 1486 | 1562310109.197965
10.20.197.103 | 38522 | 52.216.185.195 | 443 | Tcp | 74 | 1562310109.197984
35.154.102.71 | 443 | 10.20.197.103 | 56572 | Tls | 160 | 1562310109.262324
10.20.197.103 | 56572 | 35.154.102.71 | 443 | Tcp | 66 | 1562310109.262383
```
Capture packets and save them to Pcap files :
shell
➜ sudo snoopy capture run --timeout 10000 --savefile captured.pcap
Note: For capturing packets the user needs root user permissions to capture network packets.
Parse Pcap files and print to console:
shell
➜ snoopy parse ./Sample/captured.pcap
Parse Pcap files and print to console (with filters):
shell
➜ snoopy parse ./Sample/captured.pcap --filter "tcp port 443"
The above command will print all TCP packets with source/destination port 443.
Parse Pcap files and save to JSON file:
shell
➜ snoopy parse ./Sample/captured.pcap --savefile ./parsed.json
All commands and sub-commands are listed below :
```zsh USAGE: snoopy [SUBCOMMAND]
FLAGS: -h, --help Prints help information -V, --version Prints version information
SUBCOMMANDS: capture Capture packets from interfaces. help Prints this message or the help of the given subcommand(s) parse Parse pcap files.
zsh
USAGE:
snoopy capture [SUBCOMMAND]
FLAGS: -h, --help Prints help information -V, --version Prints version information
SUBCOMMANDS:
help Prints this message or the help of the given subcommand(s)
list List all interfaces.
run Start capturing packets.
zsh
USAGE:
snoopy capture run [FLAGS] [OPTIONS]
FLAGS: -h, --help Prints help information -p, --promisc Set promiscuous mode on or off. By default, this is off. -r, --rfmon Set rfmon mode on or off. The default is maintained by pcap. -V, --version Prints version information
OPTIONS:
-b, --buffersize
zsh
USAGE:
snoopy parse [OPTIONS]
FLAGS: -h, --help Prints help information -V, --version Prints version information
OPTIONS:
-f, --filter
ARGS:
```
Note: The filters can be defined according to the syntax specified here.
Run the following commands in the command line inside the folder :
zsh
docker build -t snoopy .
docker container run -it snoopy
Run the following command in the command line inside the folder :
zsh
cargo build
This project is under the MIT license.