summaryrefslogtreecommitdiff
path: root/script/replay.sh
blob: 52b0766b14ffd58ef64db8a748b89dda16437e9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
#实现对恶意流量的检测和性能数据
#将参数改为灵活指定的形式
# 指定文件夹路径

#echo "pcap-folder $1"
#echo "是否模型训练 $2"

if [ "$(id -u)" != "0" ]; then
   echo "[ERROR] This script must be run as root!"
   exit
fi
#echo "[INFO] Step0: 安装python依赖"
#sudo apt install python3-pip
#sudo pip3 install -r ../requirements.txt
# 提取文件夹名(不包含路径)
parent_folder=$1
for folder_name in "$parent_folder"/*/; do
    folder=$(basename "$folder_name")
    
    #echo "[INFO] Step1: 对流量pcap包进行重放工作"
    #sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
    #sudo python3 per_packet_replay_pcap.py --pcap-dir $folder_name --output ../data/replay_res/mawi_substate_ws_fixed_$folder.csv --interface lo
    #sudo iptables -D INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

    echo "[INFO] Step2:将状态与特征进行组合拼装"
    python3 analyze_packet_trace.py --pcap-dir $parent_folder/$folder --dataset-fpath ../data/raw_dataset/mawi_ws_ds_sorted_$folder.csv.raw --kitsune-dataset-fpath ../data/raw_dataset/mawi_ws_ds_sorted_$folder.csv.raw.kitsune --dataset-type wami --sk-mapping-path ../data/replay_res/mawi_substate_ws_fixed_$folder.csv
    
    
    if [ ! -z "$2" ] &&[ $2 = '--train' ]
    then
        echo "[INFO] Step3: 训练Preprocess formed dataset to produce dataset that is consumable by the model"
        sh prepare_dataset_test.sh mawi_ws_ds_sorted_$folder 6 none --incremental-seq-ack-strict --coarse-grained-label-overall --filter-capture-loss --dummy merge_kitsune
        echo "[INFO] Step4: --train-rnn --train-ae"
        sh run_experiment_test.sh 42 42 3 50 1000 cpu -1 -1 42 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted no_addi only_outbound $folder
    else
        echo "Training mode not specified. Running in default mode."
        echo "[INFO] Step3: 检测Preprocess formed dataset to produce dataset that is consumable by the model"
        sh prepare_dataset_test.sh mawi_ws_ds_sorted_$folder -1 none --incremental-seq-ack-strict --coarse-grained-label-overall --filter-capture-loss --dummy merge_kitsune
        echo "[INFO] Step4: --dummy"
        sh run_experiment_test.sh 42 42 3 50 1000 cpu -1 -1 42 --dummy --dummy --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted no_addi only_outbound $folder
    fi
done
#experiment 与visualize.py配合使用
#sh cat_roc_score.sh 42 42 3 50 1000 cpu -1 -1 42 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted no_addi only_outbound


#按需修改参数,修改utils中的usecols=range(30),TRIMMED_COL_NAMES, fuhe xianyou tezheng#
#sh cat_roc_score.sh 137 140 3 50 1000 cpu -1 -1 137 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted all_addi only_outbound
#sh cat_roc_score.sh 62 65 3 50 1000 cpu -1 -1 62 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted all_addi only_outbound
#sh cat_roc_score.sh 42 45 3 50 1000 cpu -1 -1 42 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted all_addi only_outbound
#sh cat_roc_score.sh 37 37 3 50 1000 cpu -1 -1 37 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none lstm large weighted no_addi only_outbound
#sh cat_roc_score.sh 42 45 3 50 1000 cpu -1 -1 42 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none lstm large weighted all_addi only_outbound
#sh cat_roc_score.sh 47 50 3 50 1000 cpu -1 -1 47 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted all_addi only_outbound
#new model 10
    #sh run_experiment_test.sh 137 140 3 50 1000 cpu -1 -1 137 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted all_addi only_outbound $folder
#model 5
    #sh run_experiment_test.sh 62 65 3 50 1000 cpu -1 -1 62 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted all_addi only_outbound $folder
#model 2
    #sh run_experiment_test.sh 47 50 3 50 1000 cpu -1 -1 47 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted all_addi only_outbound $folder
#model 1
    #sh run_experiment_test.sh 42 45 3 50 1000 cpu -1 -1 42 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted all_addi only_outbound $folder
#old model
#    sh run_experiment_test.sh 37 37 3 50 1000 cpu -1 -1 37 --train-rnn --train-ae --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted no_addi only_outbound $folder

#without addi
#model 1
#
    #sh run_experiment_test.sh 42 45 3 50 1000 cpu -1 -1 42 --dummy --dummy --launch-attack mawi_ws_ds_sorted use_gates none gru large weighted all_addi only_outbound $folder
#old model  :delete  trimmed_col_names