forked from eciavatta/caronte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hyperscan to vectorscan for arm64 compatibility
- Loading branch information
Domingo Dirutigliano
committed
Apr 28, 2023
1 parent
4fc5f0d
commit f4e90c5
Showing
5 changed files
with
66 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ pcaps/*.pcap | |
pcaps/*.pcapng | ||
pcaps/processing/*.pcap | ||
pcaps/processing/*.pcapng | ||
Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,46 @@ | ||
#!/bin/bash - | ||
#=============================================================================== | ||
# | ||
# FILE: feedCaronte.sh | ||
# | ||
# USAGE: ./feedCaronte.sh PCAP_DIR_PATH | ||
# | ||
# DESCRIPTION: | ||
# | ||
# OPTIONS: --- | ||
# REQUIREMENTS: inotify-tools, curl | ||
# BUGS: --- | ||
# NOTES: test in Debian Buster | ||
# AUTHOR: Andrea Giovine (AG), | ||
# ORGANIZATION: | ||
# CREATED: 17/08/2020 16:36:57 | ||
# REVISION: --- | ||
#=============================================================================== | ||
|
||
set -o nounset # Treat unset variables as an error | ||
|
||
CHECK_INOTIFY=$(dpkg-query -W -f='${status}' 'inotify-tools') | ||
|
||
if [[ "$CHECK_INOTIFY" != 'install ok installed' ]]; then | ||
echo "Install inotify-tools" | ||
exit 1 | ||
fi | ||
|
||
CHECK_CURL=$(dpkg-query -W -f='${Status}' 'curl') | ||
#!/usr/bin/env bash | ||
|
||
if [[ "$CHECK_CURL" != 'install ok installed' ]]; then | ||
echo "Install curl" | ||
exit 1 | ||
fi | ||
# . TIMEOUT CARONTE_IP | ||
#./caronte.sh 30 https://caronte.com game | ||
|
||
if [[ "$#" -ne 1 ]]; then | ||
echo "Need 1 arg" | ||
if [[ "$#" -ne 3 ]]; then | ||
echo "Usage: ./caronte.sh <timeout> <ip:port> <interface>" | ||
exit 2 | ||
fi | ||
|
||
PCAP_DIR="$1" | ||
PROC_TIMEOUT=$$ | ||
UPLOAD_PROC=$$ | ||
THIS_PROC=$$ | ||
|
||
if [[ -z "$PCAP_DIR" ]]; then | ||
echo "Need path to dir where are store pcaps" | ||
exit 2 | ||
fi | ||
trap 'echo; kill -9 $PROC_TIMEOUT; kill -9 $UPLOAD_PROC; kill -9 $THIS_PROC' INT | ||
|
||
TIMEOUT_TCPDUMP="$1" | ||
CARONTE_ADDR="$2" | ||
INTERFACE_NAME="$3" | ||
|
||
mkdir upload 2> /dev/null | ||
|
||
function get_pcaps { | ||
while true; do | ||
timeout $TIMEOUT_TCPDUMP tcpdump -w "data.pcap" -i $INTERFACE_NAME port not 22 and port not 4444 &> /dev/null & PROC_TIMEOUT=$! | ||
wait $PROC_TIMEOUT | ||
mv data.pcap "upload/data-$(md5sum <<< date | awk '{ print $1 }').pcap" | ||
done | ||
} | ||
|
||
function upload_pcaps { | ||
while true; do | ||
files=`ls ./upload/*.pcap 2> /dev/null` | ||
for file in $files | ||
do | ||
curl -F "file=@$file" -F "flush_all=true" "$CARONTE_ADDR/api/pcap/upload" && rm $file | ||
echo | ||
done | ||
sleep `echo $TIMEOUT_TCPDUMP/2 | bc` | ||
done | ||
} | ||
|
||
upload_pcaps & UPLOAD_PROC=$! | ||
|
||
get_pcaps | ||
|
||
inotifywait -m "$PCAP_DIR" -e close_write -e moved_to | | ||
while read dir action file; do | ||
echo "The file $file appeared in directory $dir via $action" | ||
curl -F "file=@$file" "http://localhost:3333/api/pcap/upload" | ||
done |