dm secu
This commit is contained in:
parent
08933e3529
commit
303c31a179
4 changed files with 35 additions and 6 deletions
16
securite/dm/pcap_analyzer/Cargo.lock
generated
16
securite/dm/pcap_analyzer/Cargo.lock
generated
|
@ -60,6 +60,12 @@ dependencies = [
|
|||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
|
@ -145,6 +151,15 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "etherparse"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "21696e6dfe1057a166a042c6d27b89a46aad2ee1003e6e1e03c49d54fd3270d7"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
|
@ -199,6 +214,7 @@ name = "pcap_analyzer"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"etherparse",
|
||||
"pcap",
|
||||
]
|
||||
|
||||
|
|
|
@ -5,4 +5,5 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
clap = { version = "4.5.7", features = ["derive"] }
|
||||
etherparse = "0.15.0"
|
||||
pcap = "2.0.0"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::{error::Error, path::PathBuf};
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use etherparse::{NetSlice, SlicedPacket};
|
||||
use pcap::Capture;
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
@ -20,11 +21,11 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||
let mut total_ipv4 = 0;
|
||||
let mut total = 0;
|
||||
while let Ok(packet) = pcap.next_packet() {
|
||||
total += 1;
|
||||
let ether_type = &packet.data[20..][..2];
|
||||
if ether_type == [0x00, 0x08] {
|
||||
let packet = SlicedPacket::from_ethernet(packet.data)?;
|
||||
if let Some(NetSlice::Ipv4(_)) = packet.net {
|
||||
total_ipv4 += 1;
|
||||
}
|
||||
total += 1;
|
||||
}
|
||||
println!("Count: {total: >9}");
|
||||
println!("Count IPv4: {total_ipv4: >9}");
|
||||
|
|
|
@ -1,5 +1,16 @@
|
|||
#!/bin/sh
|
||||
set -e
|
||||
cd "$(dirname "$(realpath "$0")")"
|
||||
|
||||
|
||||
echo "checks compile"
|
||||
cd pcap_analyzer
|
||||
cargo build
|
||||
cd ..
|
||||
|
||||
|
||||
echo "pushing"
|
||||
git add .
|
||||
git commit -m "dm secu"
|
||||
git push
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue