Skip to content

An excellent solution to weak training data in encrypted malicious network traffic detection.

Notifications You must be signed in to change notification settings

666ghj/HangShield

Repository files navigation

HangShield:加密恶意网络流量检测的弱训练数据解决方案

执行检测任务

将要预测的包长度序列npy文件放在/data/data下,命名为test.npy,该文件的格式如下:

要保持51维,第51维可以随便给

[
    [61, 141, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [52, 52, 745, 1999, 40, 662, 40, 1999, 40, 1422, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1422, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 40, 1999, 0],
    [58, 298, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [63, 94, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [58, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [63, 491, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    [66, 179, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
]

然后cd到main目录,执行python main.py,注意此时该程序main函数只需要执行mainUSE()函数:

if __name__ == '__main__':
    mainUSE()
预测结果已保存至: ..\data_BEN\result\prediction_BEN.npy
预测结果已保存至: ..\data_RAT\result\prediction_RAT.npy
预测结果已保存至: ..\data_PST\result\prediction_PST.npy
预测结果已保存至: ..\data_BDT\result\prediction_BDT.npy
预测结果已保存至: ..\data_SPT\result\prediction_SPT.npy
预测结果已保存至: ..\data_DLT\result\prediction_DLT.npy
已复制         1 个文件。
整合后的数据已保存至: ..\multi_Classifier\combined_data_with_labels.npy
已加载训练好的复杂softmax模型: ../multi_Classifier/model.pth
最终预测结果已保存至: ..\multi_Classifier\final_predictions.npy

运行结束,结果保存在\multi_Classifier\final_predictions.npy中,手动点击该目录下手动查看精度.py即可查看精度

执行训练任务

基本步骤同上,main.py里面改成:

if __name__ == '__main__':
    mianTRAIN()

About

An excellent solution to weak training data in encrypted malicious network traffic detection.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published