在Ubuntu18.04上安装USTC-TK2016
在Ubuntu18.04上安装USTC-TK2016
1.安装依赖
1. 安装Mono
sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update## 安装
sudo apt install mono-devel
2. 安装Powershell Core
可以使用Microsoft Debian存储库在Ubuntu 18.04上安装PowerShell Core
sudo apt -y install wgetwget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.debsudo dpkg -i packages-microsoft-prod.deb
成功后会输出以下信息:
Selecting previously unselected package packages-microsoft-prod.
(Reading database ... 391742 files and directories currently installed.)
Preparing to unpack packages-microsoft-prod.deb ...
Unpacking packages-microsoft-prod (1.0-2) ...
Setting up packages-microsoft-prod (1.0-2) ...
然后更新Package index列表并安装PowerShell
sudo apt updatesudo apt -y install powershell
启动Powershell
pwsh## 会显示PowerShell 6.1.1Type 'help' to get help.PS /home/vagrant>##执行Get—ChildItemPS /home/vagrant>Get—ChildItem
会显示
PS /home/vagrant>Get—ChildItem
Directory: /home/ftqUnixMode User Group LastWriteTime Size Name
-------- ---- ----- ------------- ---- ----
drwxr-xr-x ftq ftq 3/18/2022 18:29 4096 Desktop
drwxrwxr-x ftq ftq 3/2/2022 22:52 4096 distribution-karaf-0.4.4-Beryllium-SR4
drwxr-xr-x root root 12/30/2021 18:10 4096 distribution-karaf-0.6.0-Carbon
drwxr-xr-x ftq ftq 12/30/2021 01:43 4096 Documents
drwxr-xr-x ftq ftq 3/19/2022 01:50 4096 Downloads
drwxr-xr-x root root 3/14/2022 06:28 4096 hello
drwxrwxr-x ftq ftq 3/14/2022 05:45 4096 hello_world
drwxrwxr-x ftq ftq 3/3/2022 05:41 4096 ideaIU-2021.3.2
drwxrwxr-x ftq ftq 3/3/2022 17:31 4096 jdk-11.0.14
drwxr-xr-x ftq ftq 2/21/2022 18:14 12288 libpcap-1.10.1
drwxr-xr-x root root 12/30/2021 18:50 4096 mininet
drwxr-xr-x ftq ftq 12/30/2021 01:43 4096 Music
drwxr-xr-x root root 12/30/2021 18:52 4096 oflops
drwxr-xr-x root root 12/30/2021 18:52 4096 oftest
drwxrwxr-x ftq ftq 3/3/2022 17:41 4096 opendaylight-14.4.0
drwxr-xr-x root root 12/30/2021 18:50 4096 openflow
drwxr-xr-x ftq ftq 12/30/2021 19:14 4096 openvswitch-2.13.6
drwxr-xr-x ftq ftq 3/14/2022 05:20 4096 Pictures
drwxr-xr-x root root 12/30/2021 18:51 4096 pox
drwxr-xr-x ftq ftq 12/30/2021 01:43 4096 Public
drwxrwxr-x ftq ftq 1/21/2022 07:59 4096 pycharm-professional-2021.3.1
drwxrwxr-x ftq ftq 3/18/2022 20:00 4096 python_project
drwx------ ftq ftq 3/14/2022 05:04 4096 snap
drwxr-xr-x ftq ftq 12/30/2021 01:43 4096 Templates
drwxr-xr-x ftq ftq 12/30/2021 01:43 4096 Videos
-rw-r--r-- ftq ftq 12/30/2021 01:31 8980 examples.desktop
-rw-r--r-- root root 11/27/2017 15:03 2438 packages-microsoft-prod.deb
-rw-r--r-- root root 1/2/2019 15:49 3132 packages-microsoft-prod.deb.1
3.安装fdupes
sudo apt-get install fdupes
2.安装USTC-TK2016
需要:
- numpy 1.16.4
- PIL 1.1.6
## 克隆文件
git clone -b ubuntu https://github.com/yungshenglu/USTC-TK2016##安装所需packages
sudo pip freeze > requirements.txt
sudo pip install -r requirements.txt
3. 测试
1. 添加数据集
将数据集转移到 1_Pcap
文件夹下;
数据集可以在 https://github.com/yungshenglu/USTC-TFC2016
中下载;
注意:1_Pcap
文件夹下要是 pcap 文件,不要有文件夹。
cp -r /home/ftq/dataset/USTC-TFC2016-master/Benign/Weibo/* /home/ftq/USTC-TK2016/1_Pcap
2. 运行 1_Pcap2Session.ps1
对数据集进行分割操作
# 确保你当前目录正确
# Split the PCAP files by flow
$ pwsh 1_Pcap2Session.ps1 -f
# Split the PCAP files by session
$ pwsh 1_Pcap2Session.ps1 -s
如果成功了你可以在 2_Session/
文件夹下看到以下两个文件夹
- AllLayers/
- L7/
3. 运行 2_ProcessSession.ps1
# 确保你当前目录正确
# [ ]选择一个填写,其中 -u 代表 unsorting 不排序,-s 代表 sorting 排序
# Process the PCAP file with all layers (ALL) (for unsorting or sorting)
$ pwsh 2_ProcessSession.ps1 -a [-u | -s]
# Process the PCAP file only with layer 7 (L7) (for unsorting or sorting)
$ pwsh 2_ProcessSession.ps1 -l [-u | -s]
如果成功了,在3_ProcessedSession/
文件夹下会有两个文件夹
FilteredSession/
:存放了前6000个大PCAP文件TrimedSession/
:将PCAP文件切割成大小为 784(28*28) byte大小的文件夹,如果不足784 byte则在后面补零。- 每个文件夹下都有两个文件夹
Test
和Train
,是随机分的
4. 运行 3_Session2Png.py
# 确保你当前目录正确
$ python3 3_Session2png.py
如果成功了,可以在 4_Png/
文件夹下看到 Test/
和 Train/
文件夹,每个文件夹下都有处理好的图片
5. 运行 4_Png2Mnist.py
# 确保你当前目录正确
$ python3 4_Png2Mnist.py
如果运行成功,在 5_Mnist/
文件夹下能看到:
train-images-idx1-ubyte
train-images-idx3-ubyte
train-images-idx1-ubyte.gz
train-images-idx3-ubyte.gz
但是我的文件夹下只能看到压缩包,并没有上面两个文件,但是我的终端中显示已经生成了前两个文件
## 我的终端显示
root@ubuntu:/home/ftq/USTC-TK2016# python 4_Png2Mnist.py
[INFO] Generated file: 5_Mnist/train-images-idx3-ubyte
[INFO] Generated file: 5_Mnist/train-labels-idx1-ubyte
[INFO] Compressed file: 5_Mnist/train-images-idx3-ubyte.gz
[INFO] Compressed file: 5_Mnist/train-labels-idx1-ubyte.gz