在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 wget

wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb

sudo 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 update

sudo apt -y install powershell

启动Powershell

pwsh

## 会显示
 PowerShell 6.1.1

Type 'help' to get help.

PS /home/vagrant>

##执行Get—ChildItem

PS /home/vagrant>Get—ChildItem

会显示

PS /home/vagrant>Get—ChildItem
Directory: /home/ftq

UnixMode   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-Be
                                                                               ryllium-SR4
drwxr-xr-x root             root               12/30/2021 18:10           4096 distribution-karaf-0.6.0-Ca
                                                                               rbon
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则在后面补零。
  • 每个文件夹下都有两个文件夹 TestTrain ,是随机分的

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

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值