GithubHelp home page GithubHelp logo

kanishkarj / snoopy Goto Github PK

View Code? Open in Web Editor NEW
175.0 5.0 17.0 16.44 MB

A highly configurable multi-threaded packet sniffer and parser build in rust-lang.

License: MIT License

Rust 99.19% Dockerfile 0.81%
pcap-parser rust packet-capture packet-sniffer packet-parsing command-line-tool

snoopy's People

Contributors

kanishkarj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

snoopy's Issues

Compile errors

When cloning the repo or doing the cargo install snoopy, I'm getting some errors about a compilation that happens on the following lines.

https://github.com/kanishkarj/snoopy/blob/master/src/args/capture.rs#L122-L124
https://github.com/kanishkarj/snoopy/blob/master/src/args/capture.rs#L128-L139

It's complaining about Capture<Inactive> not having those methods.

EDIT:
The program is unable to compile on Windows due to missing wpcap.lib.
wpcap has been deprecated and has been replaced with npcap.
A nice library that selects the best library for the packet sniffing, that you could use, is this one: rawsock.

capture flows do individual files

This is a very nice, readable project. I'm just looking at rust for the first time, and this has been very helpful in understanding how a project should be structured.

I am trying to figure out how I could write packet data to a file based on attribute values in the header of the packets, e.g. dst_addr. I imagine this could be achived by passing the values from get_packet_meta function to a write function, although I can't figure out how to open/close a savefile. I have been able to create a file with the name of the first dst_addr received by imitating your save_to_file function, but it's a while loop so the file name is never re-evaluated. Is it possible to write to many savefiles with a single capture object?

If not, perhaps another possibility would be to start another capture object using the get_packet_meta as a filter, although with ignorance about how rust manages threads and memory I think this method could result in i/o or resource issues.

Interested in your thoughts

Fail to install snoopy in Windows

  • Rust: stable-x86_64-pc-windows-msvc 1.36.0

Here is the error log:

error[E0599]: no method named `rfmon` found for type `pcap::Capture<pcap::Inactive>` in the current scope
   --> C:\Users\Winterreise\.cargo\registry\src\github.com-1ecc6299db9ec823\snoopy-0.3.2\src\args\capture.rs:123:29
    |
123 |             device = device.rfmon(val.parse().unwrap());
    |                             ^^^^^

error[E0599]: no method named `precision` found for type `pcap::Capture<pcap::Inactive>` in the current scope
   --> C:\Users\Winterreise\.cargo\registry\src\github.com-1ecc6299db9ec823\snoopy-0.3.2\src\args\capture.rs:132:29
    |
132 |             device = device.precision(self.get_precision_type(val).unwrap());
    |                             ^^^^^^^^^

error[E0599]: no method named `tstamp_type` found for type `pcap::Capture<pcap::Inactive>` in the current scope
   --> C:\Users\Winterreise\.cargo\registry\src\github.com-1ecc6299db9ec823\snoopy-0.3.2\src\args\capture.rs:135:29
    |
135 |             device = device.tstamp_type(self.get_tstamp_type(val).unwrap());
    |                             ^^^^^^^^^^^

error[E0599]: no method named `tstamp_type` found for type `pcap::Capture<pcap::Inactive>` in the current scope
   --> C:\Users\Winterreise\.cargo\registry\src\github.com-1ecc6299db9ec823\snoopy-0.3.2\src\args\capture.rs:138:29
    |
138 |             device = device.tstamp_type(self.get_tstamp_type(val).unwrap());
    |                             ^^^^^^^^^^^

error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0599`.
error: failed to compile `snoopy v0.3.2`, intermediate artifacts can be found at `C:\Users\WINTER~1\AppData\Local\Temp\cargo-installWcR5vc`

Caused by:
  Could not compile `snoopy`.

To learn more, run the command again with --verbose.

Thanks!

Current latest version on crates.io does not compile

On a new installation of openSUSE with latest Rust compiler chain there are build failures. Latest git master compiles fine. Could you bump the version and upload it to crates.io?

steven@localhost:~> cargo --version
cargo 1.57.0 (b2e52d7ca 2021-10-21)
steven@localhost:~> rustc --version
rustc 1.57.0 (f1edd0429 2021-11-29)
steven@localhost:~> rustc --print cfg
debug_assertions
target_arch="x86_64"
target_endian="little"
target_env="gnu"
target_family="unix"
target_feature="fxsr"
target_feature="sse"
target_feature="sse2"
target_os="linux"
target_pointer_width="64"
target_vendor="unknown"
unix
   Compiling snoopy v0.3.2
error: cannot find derive macro `Serialize` in this scope
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:16:17
   |
16 | #[derive(Debug, Serialize, Deserialize, PartialEq)]
   |                 ^^^^^^^^^
   |
note: `Serialize` is imported here, but it is only a trait, without a derive macro
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:12:26
   |
12 | use serde::{Deserialize, Serialize};
   |                          ^^^^^^^^^

error: cannot find derive macro `Deserialize` in this scope
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:16:28
   |
16 | #[derive(Debug, Serialize, Deserialize, PartialEq)]
   |                            ^^^^^^^^^^^
   |
note: `Deserialize` is imported here, but it is only a trait, without a derive macro
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:12:13
   |
12 | use serde::{Deserialize, Serialize};
   |             ^^^^^^^^^^^

error: cannot find derive macro `Serialize` in this scope
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:28:17
   |
28 | #[derive(Debug, Serialize, Deserialize)]
   |                 ^^^^^^^^^
   |
note: `Serialize` is imported here, but it is only a trait, without a derive macro
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:12:26
   |
12 | use serde::{Deserialize, Serialize};
   |                          ^^^^^^^^^

error: cannot find derive macro `Deserialize` in this scope
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:28:28
   |
28 | #[derive(Debug, Serialize, Deserialize)]
   |                            ^^^^^^^^^^^
   |
note: `Deserialize` is imported here, but it is only a trait, without a derive macro
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:12:13
   |
12 | use serde::{Deserialize, Serialize};
   |             ^^^^^^^^^^^

error: cannot find derive macro `Serialize` in this scope
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:47:17
   |
47 | #[derive(Debug, Serialize, Deserialize, PartialEq)]
   |                 ^^^^^^^^^
   |
note: `Serialize` is imported here, but it is only a trait, without a derive macro
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:12:26
   |
12 | use serde::{Deserialize, Serialize};
   |                          ^^^^^^^^^

error: cannot find derive macro `Deserialize` in this scope
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:47:28
   |
47 | #[derive(Debug, Serialize, Deserialize, PartialEq)]
   |                            ^^^^^^^^^^^
   |
note: `Deserialize` is imported here, but it is only a trait, without a derive macro
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:12:13
   |
12 | use serde::{Deserialize, Serialize};
   |             ^^^^^^^^^^^

error: cannot find derive macro `Serialize` in this scope
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:57:17
   |
57 | #[derive(Debug, Serialize, Deserialize, PartialEq)]
   |                 ^^^^^^^^^
   |
note: `Serialize` is imported here, but it is only a trait, without a derive macro
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:12:26
   |
12 | use serde::{Deserialize, Serialize};
   |                          ^^^^^^^^^

error: cannot find derive macro `Deserialize` in this scope
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:57:28
   |
57 | #[derive(Debug, Serialize, Deserialize, PartialEq)]
   |                            ^^^^^^^^^^^
   |
note: `Deserialize` is imported here, but it is only a trait, without a derive macro
  --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_parse.rs:12:13
   |
12 | use serde::{Deserialize, Serialize};
   |             ^^^^^^^^^^^

error[E0277]: the trait bound `ParsedPacket: Serialize` is not satisfied
    --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/snoopy-0.3.2/src/lib/packet_capture.rs:171:57
     |
171  |                     let packets = serde_json::to_string(&packets).unwrap();
     |                                   --------------------- ^^^^^^^^ the trait `Serialize` is not implemented for `ParsedPacket`
     |                                   |
     |                                   required by a bound introduced by this call
     |
     = note: required because of the requirements on the impl of `Serialize` for `Result<ParsedPacket, std::string::String>`
     = note: 2 redundant requirements hidden
     = note: required because of the requirements on the impl of `Serialize` for `&Vec<Result<ParsedPacket, std::string::String>>`
note: required by a bound in `serde_json::to_string`
    --> /home/steven/.cargo/registry/src/github.com-1ecc6299db9ec823/serde_json-1.0.73/src/ser.rs:2216:17
     |
2216 |     T: ?Sized + Serialize,
     |                 ^^^^^^^^^ required by this bound in `serde_json::to_string`

For more information about this error, try `rustc --explain E0277`.
error: failed to compile `snoopy v0.3.2`, intermediate artifacts can be found at `/tmp/cargo-installKtYwe0`

Caused by:
  could not compile `snoopy` due to 9 previous errors

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.