优化防火墙接口数据读取到xlsx文件中
This commit is contained in:
parent
30cc9fe3e5
commit
2d85afc333
@ -1,155 +0,0 @@
|
|||||||
package attackevent
|
|
||||||
|
|
||||||
import (
|
|
||||||
"bytes"
|
|
||||||
"dt_automate/conn"
|
|
||||||
"dt_automate/tool"
|
|
||||||
"log"
|
|
||||||
"math"
|
|
||||||
"net/url"
|
|
||||||
"strconv"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/Esword618/unioffice/schema/soo/sml"
|
|
||||||
"github.com/Esword618/unioffice/spreadsheet"
|
|
||||||
)
|
|
||||||
|
|
||||||
// var cookieStr string
|
|
||||||
|
|
||||||
// var Counts int //存储总条数
|
|
||||||
// var err error
|
|
||||||
|
|
||||||
// 传入cookie
|
|
||||||
func Fw_event(cookieStr string) {
|
|
||||||
ss := spreadsheet.New()
|
|
||||||
sheet := ss.AddSheet()
|
|
||||||
// sheet.SetFrozen(true, false)
|
|
||||||
v := sheet.InitialView()
|
|
||||||
v.SetState(sml.ST_PaneStateFrozen)
|
|
||||||
v.SetXSplit(0) //冻结列
|
|
||||||
v.SetYSplit(1) //冻结行
|
|
||||||
// v.SetTopLeft("B2")
|
|
||||||
// // 获取第一个工作表
|
|
||||||
// sheet, err := ss.GetSheet("Sheet2")
|
|
||||||
// if err != nil {
|
|
||||||
// log.Println(err)
|
|
||||||
// }
|
|
||||||
sheet.Cell("A1").SetString("序号")
|
|
||||||
sheet.Cell("B1").SetString("攻击时间")
|
|
||||||
sheet.Cell("C1").SetString("源安全域")
|
|
||||||
sheet.Cell("D1").SetString("目的安全域")
|
|
||||||
sheet.Cell("E1").SetString("源IP")
|
|
||||||
sheet.Cell("F1").SetString("目的IP")
|
|
||||||
sheet.Cell("G1").SetString("目的端口")
|
|
||||||
sheet.Cell("H1").SetString("威胁名称")
|
|
||||||
sheet.Cell("I1").SetString("攻击类别")
|
|
||||||
sheet.Cell("J1").SetString("攻击子类别")
|
|
||||||
sheet.Cell("K1").SetString("应用协议")
|
|
||||||
sheet.Cell("L1").SetString("域名(host)")
|
|
||||||
|
|
||||||
//当前时间
|
|
||||||
EndTime := time.Unix(tool.Timestamp("second"), 0).Format("2006-01-02T15:04:05")
|
|
||||||
//今天0点
|
|
||||||
StartTime := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.Now().Location()).Format("2006-01-02T15:04:05")
|
|
||||||
//昨天23点59分59秒
|
|
||||||
EndTime_1 := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.Now().Location()).Add(-1 * time.Second).Format("2006-01-02T15:04:05")
|
|
||||||
StartTime_1 := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.Now().Location()).Add(-8 * time.Hour).Format("2006-01-02T15:04:05")
|
|
||||||
// log.Println(EndTime_1)
|
|
||||||
// log.Println(StartTime_1)
|
|
||||||
// 构建 x-www-form-urlencoded 格式的请求体
|
|
||||||
//今天0点到现在的攻击事件
|
|
||||||
values := url.Values{}
|
|
||||||
values.Add("xml", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime+"</StartTime><EndTime>"+EndTime+"</EndTime></TimeFilter><PageNo>1</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
|
||||||
values.Add("req_menu", "M_Monitor/M_AtkLog/M_ThreatLog")
|
|
||||||
//昨天下午16点到晚上23点59分59秒的攻击事件
|
|
||||||
values_1 := url.Values{}
|
|
||||||
values_1.Add("xml", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime_1+"</StartTime><EndTime>"+EndTime_1+"</EndTime></TimeFilter><PageNo>1</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
|
||||||
values_1.Add("req_menu", "M_Monitor/M_AtkLog/M_ThreatLog")
|
|
||||||
header := map[string]string{
|
|
||||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
|
||||||
"referer": "https://11.2.68.146/wnm/frame/index.php",
|
|
||||||
"cookie": cookieStr,
|
|
||||||
}
|
|
||||||
//先查询昨天的事件
|
|
||||||
body := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values_1.Encode()))
|
|
||||||
// log.Println(string(body))
|
|
||||||
log.Println(body)
|
|
||||||
var Con int //插入总数
|
|
||||||
//存储昨日攻击事件
|
|
||||||
if body.LogPaging[0].TotalCounts > "200" {
|
|
||||||
a, err := strconv.ParseFloat(body.LogPaging[0].TotalCounts, 64)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
log.Println("昨日查询到总条数:", a)
|
|
||||||
totalPages := int(math.Floor(float64(a))/float64(200) + 1)
|
|
||||||
log.Println(totalPages)
|
|
||||||
for i := 1; i < totalPages+1; i++ {
|
|
||||||
// values_1 := url.Values{}
|
|
||||||
// values_1.Add("xml", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime_1+"</StartTime><EndTime>"+EndTime_1+"</EndTime></TimeFilter><PageNo>"+strconv.Itoa(i)+"</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
|
||||||
// values_1.Add("req_menu", "M_Monitor/M_AtkLog/M_ThreatLog")
|
|
||||||
body := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values_1.Encode()))
|
|
||||||
log.Println(values_1, i)
|
|
||||||
for v, k := range body.LogPaging {
|
|
||||||
Con = v + 2
|
|
||||||
sheet.Cell("A" + strconv.Itoa(Con)).SetString(strconv.Itoa(Con)) // 第一列 (A1)
|
|
||||||
sheet.Cell("B" + strconv.Itoa(Con)).SetString(k.OutputJSON.Time)
|
|
||||||
sheet.Cell("C" + strconv.Itoa(Con)).SetString(k.OutputJSON.SrcZoneName)
|
|
||||||
sheet.Cell("D" + strconv.Itoa(Con)).SetString(k.OutputJSON.DestZoneName)
|
|
||||||
sheet.Cell("E" + strconv.Itoa(Con)).SetString(k.OutputJSON.SrcIPAddr)
|
|
||||||
sheet.Cell("F" + strconv.Itoa(Con)).SetString(k.OutputJSON.DestIPAddr)
|
|
||||||
sheet.Cell("G" + strconv.Itoa(Con)).SetString(k.OutputJSON.DestPort)
|
|
||||||
sheet.Cell("H" + strconv.Itoa(Con)).SetString(k.OutputJSON.ThreatName)
|
|
||||||
sheet.Cell("I" + strconv.Itoa(Con)).SetString(k.OutputJSON.MethodNameCN)
|
|
||||||
sheet.Cell("J" + strconv.Itoa(Con)).SetString(k.OutputJSON.MethodSubNameCN)
|
|
||||||
sheet.Cell("K" + strconv.Itoa(Con)).SetString(k.OutputJSON.Application)
|
|
||||||
sheet.Cell("L" + strconv.Itoa(Con)).SetString(k.OutputJSON.HttpHost)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Con = Con + 1
|
|
||||||
//存储今日攻击事件
|
|
||||||
body_1 := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values_1.Encode()))
|
|
||||||
if body_1.LogPaging[0].TotalCounts > "200" {
|
|
||||||
a, err := strconv.ParseFloat(body_1.LogPaging[0].TotalCounts, 64)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
log.Println("今日查询到总条数:", a)
|
|
||||||
totalPages := int(math.Floor(float64(a))/float64(200) + 1)
|
|
||||||
log.Println(totalPages)
|
|
||||||
for i := 1; i < totalPages+1; i++ {
|
|
||||||
// values_1 := url.Values{}
|
|
||||||
// values_1.Add("xml", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime+"</StartTime><EndTime>"+EndTime+"</EndTime></TimeFilter><PageNo>"+strconv.Itoa(i)+"</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
|
||||||
// values_1.Add("req_menu", "M_Monitor/M_AtkLog/M_ThreatLog")
|
|
||||||
body_1 := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values.Encode()))
|
|
||||||
log.Println(values_1, i)
|
|
||||||
for v, k := range body_1.LogPaging {
|
|
||||||
Con = v + Con
|
|
||||||
sheet.Cell("A" + strconv.Itoa(Con)).SetString(strconv.Itoa(Con)) // 第一列 (A1)
|
|
||||||
sheet.Cell("B" + strconv.Itoa(Con)).SetString(k.OutputJSON.Time)
|
|
||||||
sheet.Cell("C" + strconv.Itoa(Con)).SetString(k.OutputJSON.SrcZoneName)
|
|
||||||
sheet.Cell("D" + strconv.Itoa(Con)).SetString(k.OutputJSON.DestZoneName)
|
|
||||||
sheet.Cell("E" + strconv.Itoa(Con)).SetString(k.OutputJSON.SrcIPAddr)
|
|
||||||
sheet.Cell("F" + strconv.Itoa(Con)).SetString(k.OutputJSON.DestIPAddr)
|
|
||||||
sheet.Cell("G" + strconv.Itoa(Con)).SetString(k.OutputJSON.DestPort)
|
|
||||||
sheet.Cell("H" + strconv.Itoa(Con)).SetString(k.OutputJSON.ThreatName)
|
|
||||||
sheet.Cell("I" + strconv.Itoa(Con)).SetString(k.OutputJSON.MethodNameCN)
|
|
||||||
sheet.Cell("J" + strconv.Itoa(Con)).SetString(k.OutputJSON.MethodSubNameCN)
|
|
||||||
sheet.Cell("K" + strconv.Itoa(Con)).SetString(k.OutputJSON.Application)
|
|
||||||
sheet.Cell("L" + strconv.Itoa(Con)).SetString(k.OutputJSON.HttpHost)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 保存修改后的 Excel 文件
|
|
||||||
|
|
||||||
if err := ss.Validate(); err != nil {
|
|
||||||
log.Fatalf("验证文件时出错: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := ss.SaveToFile("防火墙安全事件.xlsx"); err != nil {
|
|
||||||
log.Fatalf("保存文件时出错: %s", err)
|
|
||||||
}
|
|
||||||
}
|
|
309
attackevent/fw_data.go
Normal file
309
attackevent/fw_data.go
Normal file
@ -0,0 +1,309 @@
|
|||||||
|
package attackevent
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"dt_automate/conn"
|
||||||
|
"dt_automate/tool"
|
||||||
|
"encoding/json"
|
||||||
|
"log"
|
||||||
|
"math"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Esword618/unioffice/schema/soo/sml"
|
||||||
|
"github.com/Esword618/unioffice/spreadsheet"
|
||||||
|
)
|
||||||
|
|
||||||
|
// var cookieStr string
|
||||||
|
|
||||||
|
// var Counts int //存储总条数
|
||||||
|
// var err error
|
||||||
|
|
||||||
|
// 传入cookie
|
||||||
|
func Fw_event(cookieStr string) {
|
||||||
|
ss := spreadsheet.New()
|
||||||
|
sheet := ss.AddSheet()
|
||||||
|
// sheet.SetFrozen(true, false)
|
||||||
|
v := sheet.InitialView()
|
||||||
|
v.SetState(sml.ST_PaneStateFrozen)
|
||||||
|
v.SetXSplit(0) //冻结列
|
||||||
|
v.SetYSplit(1) //冻结行
|
||||||
|
|
||||||
|
// v.SetTopLeft("B2")
|
||||||
|
// // 获取第一个工作表
|
||||||
|
// sheet, err := ss.GetSheet("Sheet2")
|
||||||
|
// if err != nil {
|
||||||
|
// log.Println(err)
|
||||||
|
// }
|
||||||
|
sheet.Cell("A1").SetString("序号")
|
||||||
|
sheet.Cell("B1").SetString("攻击时间")
|
||||||
|
sheet.Cell("C1").SetString("源安全域")
|
||||||
|
sheet.Cell("D1").SetString("目的安全域")
|
||||||
|
sheet.Cell("E1").SetString("源IP")
|
||||||
|
sheet.Cell("F1").SetString("目的IP")
|
||||||
|
sheet.Cell("G1").SetString("目的端口")
|
||||||
|
sheet.Cell("H1").SetString("威胁名称")
|
||||||
|
sheet.Cell("I1").SetString("攻击类别")
|
||||||
|
sheet.Cell("J1").SetString("攻击子类别")
|
||||||
|
sheet.Cell("K1").SetString("应用协议")
|
||||||
|
sheet.Cell("L1").SetString("CVE")
|
||||||
|
sheet.Cell("M1").SetString("域名(host)")
|
||||||
|
sheet.Cell("N1").SetString("请求路径")
|
||||||
|
sheet.Cell("O1").SetString("参数")
|
||||||
|
log.Println("生成表格表头标题")
|
||||||
|
//当前时间
|
||||||
|
EndTime := time.Unix(tool.Timestamp("second"), 0).Format("2006-01-02T15:04:05")
|
||||||
|
//今天0点
|
||||||
|
StartTime := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.Now().Location()).Format("2006-01-02T15:04:05")
|
||||||
|
//昨天23点59分59秒
|
||||||
|
EndTime_1 := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.Now().Location()).Add(-1 * time.Second).Format("2006-01-02T15:04:05")
|
||||||
|
StartTime_1 := time.Date(time.Now().Year(), time.Now().Month(), time.Now().Day(), 0, 0, 0, 0, time.Now().Location()).Add(-8 * time.Hour).Format("2006-01-02T15:04:05")
|
||||||
|
// log.Println(EndTime_1)
|
||||||
|
// log.Println(StartTime_1)
|
||||||
|
// 构建 x-www-form-urlencoded 格式的请求体
|
||||||
|
//今天0点到现在的攻击事件
|
||||||
|
values := url.Values{}
|
||||||
|
values.Add("xml", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime+"</StartTime><EndTime>"+EndTime+"</EndTime></TimeFilter><PageNo>1</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
||||||
|
values.Add("req_menu", "M_Monitor/M_AtkLog/M_ThreatLog")
|
||||||
|
//昨天下午16点到晚上23点59分59秒的攻击事件
|
||||||
|
values_1 := url.Values{}
|
||||||
|
values_1.Add("xml", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime_1+"</StartTime><EndTime>"+EndTime_1+"</EndTime></TimeFilter><PageNo>1</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
||||||
|
values_1.Add("req_menu", "M_Monitor/M_AtkLog/M_ThreatLog")
|
||||||
|
header := map[string]string{
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
|
"referer": "https://11.2.68.146/wnm/frame/index.php",
|
||||||
|
"cookie": cookieStr,
|
||||||
|
}
|
||||||
|
//先查询昨天的事件
|
||||||
|
yesterday := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values_1.Encode()))
|
||||||
|
// log.Println(string(body))
|
||||||
|
// log.Println(yesterday)
|
||||||
|
|
||||||
|
var Con int //插入总数
|
||||||
|
//存储昨日攻击事件
|
||||||
|
num, _ := strconv.Atoi(Date_v(yesterday).NTOP.LogPaging[0].TotalCounts)
|
||||||
|
if num > 200 {
|
||||||
|
a, err := strconv.ParseFloat(Date_v(yesterday).NTOP.LogPaging[0].TotalCounts, 64)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
log.Println("昨日查询到总条数:", a)
|
||||||
|
totalPages := int(math.Floor(float64(a))/float64(200) + 1)
|
||||||
|
log.Println(totalPages)
|
||||||
|
for i := 1; i < totalPages+1; i++ {
|
||||||
|
values_1 := url.Values{}
|
||||||
|
values_1.Add("xml", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime_1+"</StartTime><EndTime>"+EndTime_1+"</EndTime></TimeFilter><PageNo>"+strconv.Itoa(i)+"</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
||||||
|
values_1.Add("req_menu", "M_Monitor/M_AtkLog/M_ThreatLog")
|
||||||
|
yesterday := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values_1.Encode()))
|
||||||
|
log.Println(values_1, i)
|
||||||
|
for v, k := range Date_v(yesterday).NTOP.LogPaging {
|
||||||
|
Con = v + 2
|
||||||
|
sheet.Cell("A" + strconv.Itoa(Con)).SetString(strconv.Itoa(Con)) // 第一列 (A1)
|
||||||
|
sheet.Cell("B" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string))
|
||||||
|
sheet.Cell("C" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string))
|
||||||
|
sheet.Cell("D" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string))
|
||||||
|
sheet.Cell("E" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string))
|
||||||
|
sheet.Cell("F" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string))
|
||||||
|
sheet.Cell("G" + strconv.Itoa(Con)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64))
|
||||||
|
sheet.Cell("H" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string))
|
||||||
|
sheet.Cell("I" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string))
|
||||||
|
sheet.Cell("J" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string))
|
||||||
|
sheet.Cell("K" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string))
|
||||||
|
sheet.Cell("L" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string))
|
||||||
|
sheet.Cell("M" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string))
|
||||||
|
sheet.Cell("N" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string))
|
||||||
|
sheet.Cell("O" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string))
|
||||||
|
log.Println("开始插入昨日数据:", Con, k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
for v, k := range Date_v(yesterday).NTOP.LogPaging {
|
||||||
|
Con = v + 2
|
||||||
|
sheet.Cell("A" + strconv.Itoa(Con)).SetString(strconv.Itoa(Con)) // 第一列 (A1)
|
||||||
|
sheet.Cell("B" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string))
|
||||||
|
sheet.Cell("C" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string))
|
||||||
|
sheet.Cell("D" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string))
|
||||||
|
sheet.Cell("E" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string))
|
||||||
|
sheet.Cell("F" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string))
|
||||||
|
sheet.Cell("G" + strconv.Itoa(Con)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64))
|
||||||
|
sheet.Cell("H" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string))
|
||||||
|
sheet.Cell("I" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string))
|
||||||
|
sheet.Cell("J" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string))
|
||||||
|
sheet.Cell("K" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string))
|
||||||
|
sheet.Cell("L" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string))
|
||||||
|
sheet.Cell("M" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string))
|
||||||
|
sheet.Cell("N" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string))
|
||||||
|
sheet.Cell("O" + strconv.Itoa(Con)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string))
|
||||||
|
log.Println("开始插入昨日数据:", Con, k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Con = Con + 1
|
||||||
|
//存储今日攻击事件
|
||||||
|
today := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values_1.Encode()))
|
||||||
|
num_1, _ := strconv.Atoi(Date_v(today).NTOP.LogPaging[0].TotalCounts)
|
||||||
|
if num_1 > 200 {
|
||||||
|
a, err := strconv.ParseFloat(Date_v(today).NTOP.LogPaging[0].TotalCounts, 64)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
log.Println("今日查询到总条数:", a)
|
||||||
|
totalPages := int(math.Floor(float64(a))/float64(200) + 1)
|
||||||
|
log.Println(totalPages)
|
||||||
|
for i := 1; i < totalPages+1; i++ {
|
||||||
|
values_1 := url.Values{}
|
||||||
|
values_1.Add("xml", "<rpc message-id='101' xmlns='urn:ietf:params:xml:ns:netconf:base:1.0' xmlns:web='urn:ietf:params:xml:ns:netconf:base:1.0'><get-bulk><filter type='subtree'><top xmlns='http://www.unis.cn/netconf/data:1.0' xmlns:web='http://www.unis.cn/netconf/base:1.0' xmlns:data='http://www.unis.cn/netconf/data:1.0'><NTOP><LogPaging><Log><LogType>1</LogType><UserID/><ID/><TimeFilter><StartTime>"+StartTime+"</StartTime><EndTime>"+EndTime+"</EndTime></TimeFilter><PageNo>"+strconv.Itoa(i)+"</PageNo><CountPerPage>200</CountPerPage><TotalCounts/><InputJSON>{"SrcZoneName":"Untrust","DestZoneName":"Trust"}</InputJSON><OutputJSON/></Log></LogPaging></NTOP></top></filter></get-bulk></rpc>")
|
||||||
|
values_1.Add("req_menu", "M_Monitor/M_AtkLog/M_ThreatLog")
|
||||||
|
today := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values.Encode()))
|
||||||
|
log.Println(values_1, i)
|
||||||
|
for v, k := range Date_v(today).NTOP.LogPaging {
|
||||||
|
sheet.Cell("A" + strconv.Itoa(Con+v)).SetString(strconv.Itoa(Con)) // 第一列 (A1)
|
||||||
|
sheet.Cell("B" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string))
|
||||||
|
sheet.Cell("C" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string))
|
||||||
|
sheet.Cell("D" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string))
|
||||||
|
sheet.Cell("E" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string))
|
||||||
|
sheet.Cell("F" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string))
|
||||||
|
sheet.Cell("G" + strconv.Itoa(Con+v)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64))
|
||||||
|
sheet.Cell("H" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string))
|
||||||
|
sheet.Cell("I" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string))
|
||||||
|
sheet.Cell("J" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string))
|
||||||
|
sheet.Cell("K" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string))
|
||||||
|
sheet.Cell("L" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string))
|
||||||
|
sheet.Cell("M" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string))
|
||||||
|
sheet.Cell("N" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string))
|
||||||
|
sheet.Cell("O" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string))
|
||||||
|
log.Println("开始插入今日数据:", v+Con, k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string))
|
||||||
|
}
|
||||||
|
// log.Println(Date_v(JsonStr).NTOP.LogPaging)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for v, k := range Date_v(today).NTOP.LogPaging {
|
||||||
|
sheet.Cell("A" + strconv.Itoa(Con+v)).SetString(strconv.Itoa(Con)) // 第一列 (A1)
|
||||||
|
sheet.Cell("B" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Time"].(string))
|
||||||
|
sheet.Cell("C" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["SrcZoneName"].(string))
|
||||||
|
sheet.Cell("D" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["DestZoneName"].(string))
|
||||||
|
sheet.Cell("E" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string))
|
||||||
|
sheet.Cell("F" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["DestIPAddr"].(string))
|
||||||
|
sheet.Cell("G" + strconv.Itoa(Con+v)).SetString(strconv.FormatFloat(k.OutputJSON.(map[string]interface{})["DestPort"].(float64), 'f', -1, 64))
|
||||||
|
sheet.Cell("H" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["ThreatName"].(string))
|
||||||
|
sheet.Cell("I" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["MethodNameCN"].(string))
|
||||||
|
sheet.Cell("J" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["MethodSubNameCN"].(string))
|
||||||
|
sheet.Cell("K" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Application"].(string))
|
||||||
|
sheet.Cell("L" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["CVE"].(string))
|
||||||
|
sheet.Cell("M" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["HttpHost"].(string))
|
||||||
|
sheet.Cell("N" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["HttpFirstLine"].(string))
|
||||||
|
sheet.Cell("O" + strconv.Itoa(Con+v)).SetString(k.OutputJSON.(map[string]interface{})["Payload"].(string))
|
||||||
|
log.Println("开始插入今日数据:", v+Con, k.OutputJSON.(map[string]interface{})["SrcIPAddr"].(string))
|
||||||
|
}
|
||||||
|
// log.Println(Date_v(JsonStr).NTOP.LogPaging)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存修改后的 Excel 文件
|
||||||
|
|
||||||
|
if err := ss.Validate(); err != nil {
|
||||||
|
log.Fatalf("验证文件时出错: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := ss.SaveToFile("防火墙安全事件.xlsx"); err != nil {
|
||||||
|
log.Fatalf("保存文件时出错: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Date_v(jsonStr string) *Person {
|
||||||
|
var person Person
|
||||||
|
err := json.Unmarshal([]byte(jsonStr), &person)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("JSON 解析失败: %v", err)
|
||||||
|
}
|
||||||
|
// 手动解析 InputJSON 和 OutputJSON 字段
|
||||||
|
for i := range person.NTOP.LogPaging {
|
||||||
|
logPaging := &person.NTOP.LogPaging[i]
|
||||||
|
|
||||||
|
// 解析 InputJSON
|
||||||
|
var inputJSON map[string]interface{}
|
||||||
|
err := json.Unmarshal([]byte(logPaging.InputJSON.(string)), &inputJSON)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("解析 InputJSON 失败: %v", err)
|
||||||
|
}
|
||||||
|
logPaging.InputJSON = inputJSON // 更新为解析后的数据
|
||||||
|
|
||||||
|
// 解析 OutputJSON
|
||||||
|
var outputJSON map[string]interface{}
|
||||||
|
err = json.Unmarshal([]byte(logPaging.OutputJSON.(string)), &outputJSON)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("解析 OutputJSON 失败: %v", err)
|
||||||
|
}
|
||||||
|
logPaging.OutputJSON = outputJSON // 更新为解析后的数据
|
||||||
|
}
|
||||||
|
// 输出结果
|
||||||
|
// log.Printf("解析结果: %+v\n", person.NTOP.LogPaging[4].OutputJSON.(map[string]interface{})["SrcPort"])
|
||||||
|
return &person
|
||||||
|
}
|
||||||
|
|
||||||
|
type Person struct {
|
||||||
|
NTOP NTOP `json:"NTOP"`
|
||||||
|
}
|
||||||
|
type NTOP struct {
|
||||||
|
LogPaging []LogPaging `json:"LogPaging"`
|
||||||
|
}
|
||||||
|
type LogPaging struct {
|
||||||
|
LogType string `json:"LogType"` //日志ID
|
||||||
|
ID string `json:"ID"`
|
||||||
|
UserID string `json:"UserID"`
|
||||||
|
PageNo string `json:"PageNo"` //页数
|
||||||
|
CountPerPage string `json:"CountPerPage"` //每页计数
|
||||||
|
TotalCounts string `json:"TotalCounts"` //总条数
|
||||||
|
InputJSON interface{} `json:"InputJSON"` //输入参数
|
||||||
|
OutputJSON interface{} `json:"OutputJSON"` //输出参数
|
||||||
|
TimeFilter TimeFilter `json:"TimeFilter"` //本次查询时间区间
|
||||||
|
}
|
||||||
|
|
||||||
|
type InputJSON struct {
|
||||||
|
SrcZoneName string `json:"SrcZoneName"` //源安全域
|
||||||
|
DestZoneName string `json:"DestZoneName"` //目的安全域
|
||||||
|
}
|
||||||
|
|
||||||
|
type OutputJSON struct {
|
||||||
|
SrcPort string `json:"SrcPort"` //源端口
|
||||||
|
DestPort string `json:"DestPort"` //目的端口
|
||||||
|
Action string `json:"Action"`
|
||||||
|
AttackCount string `json:"AttackCount"` //攻击计数
|
||||||
|
SrcVrfIndex string `json:"SrcVrfIndex"`
|
||||||
|
ThreatID string `json:"ThreatID"`
|
||||||
|
Severity string `json:"Severity"`
|
||||||
|
HddInfo string `json:"HddInfo"`
|
||||||
|
Application string `json:"Application"` //应用协议
|
||||||
|
ThreatName string `json:"ThreatName"` //威胁名称
|
||||||
|
SrcRegion string `json:"SrcRegion"` //源区域
|
||||||
|
DestRegion string `json:"DestRegion"` //目的区域
|
||||||
|
ThreatType string `json:"ThreatType"` //威胁类型 {入侵防御}
|
||||||
|
Time string `json:"Time"` //时间
|
||||||
|
ContextName string `json:"ContextName"` //上下文名称
|
||||||
|
Policy string `json:"Policy"` //策略
|
||||||
|
Protocol string `json:"Protocol"` //传输协议
|
||||||
|
SrcIPAddr string `json:"SrcIPAddr"` //源IP
|
||||||
|
User string `json:"User"` //用户
|
||||||
|
DestIPAddr string `json:"DestIPAddr"` //目的IP
|
||||||
|
SrcZoneName string `json:"SrcZoneName"` //源安全域
|
||||||
|
DestZoneName string `json:"DestZoneName"` //目的安全域
|
||||||
|
CVE string `json:"CVE"` //漏洞披露
|
||||||
|
MSB string `json:"MSB"`
|
||||||
|
BID string `json:"BID"`
|
||||||
|
RealIP string `json:"RealIP"`
|
||||||
|
CapturePktName string `json:"CapturePktName"`
|
||||||
|
HttpHost string `json:"HttpHost"` //host头
|
||||||
|
HttpFirstLine string `json:"HttpFirstLine"` //请求路径
|
||||||
|
Payload string `json:"Payload"` //请求数据
|
||||||
|
MethodName string `json:"MethodName"` //方法名称
|
||||||
|
MethodNameCN string `json:"MethodNameCN"` //方法名称中国(攻击类别)
|
||||||
|
MethodSubName string `json:"MethodSubName"` //方法子名称
|
||||||
|
MethodSubNameCN string `json:"MethodSubNameCN"` //方法子名称中国(具体攻击形式)
|
||||||
|
LoginUserName string `json:"LoginUserName"`
|
||||||
|
LoginPassword string `json:"LoginPassword"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TimeFilter struct {
|
||||||
|
StartTime string `json:"StartTime"`
|
||||||
|
EndTime string `json:"EndTime"`
|
||||||
|
}
|
@ -1,13 +1,6 @@
|
|||||||
package attackevent
|
package attackevent
|
||||||
|
|
||||||
import (
|
var JsonStr = `{
|
||||||
"encoding/json"
|
|
||||||
"log"
|
|
||||||
"strings"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Ceshi() {
|
|
||||||
jsonStr := `{
|
|
||||||
"NTOP":{
|
"NTOP":{
|
||||||
"LogPaging":
|
"LogPaging":
|
||||||
[{"LogType":"1","ID":"1766","UserID":"65538","PageNo":"1","CountPerPage":"200","TotalCounts":"28","InputJSON":"{\"SrcZoneName\":\"Untrust\",\"DestZoneName\":\"Trust\"}","OutputJSON":"{\"SrcPort\":33432,\"DestPort\":80,\"Action\":20,\"AttackCount\":1,\"SrcVrfIndex\":0,\"ThreatID\":24881,\"Severity\":30,\"HddInfo\":false,\"Application\":\"http\",\"ThreatName\":\"Git 客户端命令执行漏洞(CVE-2014-9390)\",\"SrcRegion\":\"\",\"DestRegion\":\"\",\"ThreatType\":\"入侵防御\",\"Time\":\"2025-02-26T23:42:32\",\"ContextName\":\"Admin\",\"Policy\":\"default\",\"Protocol\":\"TCP\",\"SrcIPAddr\":\"45.144.212.139\",\"User\":\"45.144.212.139\",\"DestIPAddr\":\"121.30.199.80\",\"SrcZoneName\":\"Untrust\",\"DestZoneName\":\"Trust\",\"CVE\":\"CVE-2014-9390\",\"MSB\":\"\",\"BID\":\"BID-71732\",\"RealIP\":\"\",\"CapturePktName\":\"\",\"HttpHost\":\" 121.30.199.80\",\"HttpFirstLine\":\"\/.git\/objects\/\",\"Payload\":\"GET \/.git\/objects\/ HTTP\/1.1\\\\0d\\\\0aHost: 121.30.199.80\\\\0d\\\\0aUser-Agent: Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/76.0.3809.100 Safari\/537.36\\\\0d\\\\0aAccept-Charset: utf-8\\\\0d\\\\0aAccept-Encoding: gzip\\\\0d\\\\0aConnection: close\\\\0d\\\\0a\\\\0d\\\\0a\",\"MethodName\":\"Vulnerability\",\"MethodNameCN\":\"漏洞\",\"MethodSubName\":\"CommandInjection\",\"MethodSubNameCN\":\"命令注入\",\"LoginUserName\":\"\",\"LoginPassword\":\"\"}","TimeFilter":{"StartTime":"2025-02-26T16:00:00","EndTime":"2025-02-26T23:59:59"}}
|
[{"LogType":"1","ID":"1766","UserID":"65538","PageNo":"1","CountPerPage":"200","TotalCounts":"28","InputJSON":"{\"SrcZoneName\":\"Untrust\",\"DestZoneName\":\"Trust\"}","OutputJSON":"{\"SrcPort\":33432,\"DestPort\":80,\"Action\":20,\"AttackCount\":1,\"SrcVrfIndex\":0,\"ThreatID\":24881,\"Severity\":30,\"HddInfo\":false,\"Application\":\"http\",\"ThreatName\":\"Git 客户端命令执行漏洞(CVE-2014-9390)\",\"SrcRegion\":\"\",\"DestRegion\":\"\",\"ThreatType\":\"入侵防御\",\"Time\":\"2025-02-26T23:42:32\",\"ContextName\":\"Admin\",\"Policy\":\"default\",\"Protocol\":\"TCP\",\"SrcIPAddr\":\"45.144.212.139\",\"User\":\"45.144.212.139\",\"DestIPAddr\":\"121.30.199.80\",\"SrcZoneName\":\"Untrust\",\"DestZoneName\":\"Trust\",\"CVE\":\"CVE-2014-9390\",\"MSB\":\"\",\"BID\":\"BID-71732\",\"RealIP\":\"\",\"CapturePktName\":\"\",\"HttpHost\":\" 121.30.199.80\",\"HttpFirstLine\":\"\/.git\/objects\/\",\"Payload\":\"GET \/.git\/objects\/ HTTP\/1.1\\\\0d\\\\0aHost: 121.30.199.80\\\\0d\\\\0aUser-Agent: Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_10_4) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/76.0.3809.100 Safari\/537.36\\\\0d\\\\0aAccept-Charset: utf-8\\\\0d\\\\0aAccept-Encoding: gzip\\\\0d\\\\0aConnection: close\\\\0d\\\\0a\\\\0d\\\\0a\",\"MethodName\":\"Vulnerability\",\"MethodNameCN\":\"漏洞\",\"MethodSubName\":\"CommandInjection\",\"MethodSubNameCN\":\"命令注入\",\"LoginUserName\":\"\",\"LoginPassword\":\"\"}","TimeFilter":{"StartTime":"2025-02-26T16:00:00","EndTime":"2025-02-26T23:59:59"}}
|
||||||
@ -41,78 +34,3 @@ func Ceshi() {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}`
|
}`
|
||||||
processed := strings.Replace(jsonStr, `\`, "", -1)
|
|
||||||
var student Person
|
|
||||||
err := json.Unmarshal([]byte(processed), &student)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("unmarshal err=%v\n", err)
|
|
||||||
}
|
|
||||||
log.Println(student.NTOP.LogPaging[0].InputJSON)
|
|
||||||
}
|
|
||||||
|
|
||||||
type Person struct {
|
|
||||||
NTOP NTOP `json:"NTOP"`
|
|
||||||
}
|
|
||||||
type NTOP struct {
|
|
||||||
LogPaging []LogPaging `json:"LogPaging"`
|
|
||||||
}
|
|
||||||
type LogPaging struct {
|
|
||||||
LogType string `json:"LogType"` //日志ID
|
|
||||||
ID string `json:"ID"`
|
|
||||||
UserID string `json:"UserID"`
|
|
||||||
PageNo string `json:"PageNo"` //页数
|
|
||||||
CountPerPage string `json:"CountPerPage"` //每页计数
|
|
||||||
TotalCounts string `json:"TotalCounts"` //总条数
|
|
||||||
InputJSON InputJSON `json:"InputJSON"` //输入参数
|
|
||||||
OutputJSON OutputJSON `json:"OutputJSON"` //输出参数
|
|
||||||
TimeFilter TimeFilter `json:"TimeFilter"` //本次查询时间区间
|
|
||||||
}
|
|
||||||
|
|
||||||
type InputJSON struct {
|
|
||||||
SrcZoneName string `json:"SrcZoneName"` //源安全域
|
|
||||||
DestZoneName string `json:"DestZoneName"` //目的安全域
|
|
||||||
}
|
|
||||||
|
|
||||||
type OutputJSON struct {
|
|
||||||
SrcPort string `json:"SrcPort"` //源端口
|
|
||||||
DestPort string `json:"DestPort"` //目的端口
|
|
||||||
Action string `json:"Action"`
|
|
||||||
AttackCount string `json:"AttackCount"` //攻击计数
|
|
||||||
SrcVrfIndex string `json:"SrcVrfIndex"`
|
|
||||||
ThreatID string `json:"ThreatID"`
|
|
||||||
Severity string `json:"Severity"`
|
|
||||||
HddInfo string `json:"HddInfo"`
|
|
||||||
Application string `json:"Application"` //应用协议
|
|
||||||
ThreatName string `json:"ThreatName"` //威胁名称
|
|
||||||
SrcRegion string `json:"SrcRegion"` //源区域
|
|
||||||
DestRegion string `json:"DestRegion"` //目的区域
|
|
||||||
ThreatType string `json:"ThreatType"` //威胁类型 {入侵防御}
|
|
||||||
Time string `json:"Time"` //时间
|
|
||||||
ContextName string `json:"ContextName"` //上下文名称
|
|
||||||
Policy string `json:"Policy"` //策略
|
|
||||||
Protocol string `json:"Protocol"` //传输协议
|
|
||||||
SrcIPAddr string `json:"SrcIPAddr"` //源IP
|
|
||||||
User string `json:"User"` //用户
|
|
||||||
DestIPAddr string `json:"DestIPAddr"` //目的IP
|
|
||||||
SrcZoneName string `json:"SrcZoneName"` //源安全域
|
|
||||||
DestZoneName string `json:"DestZoneName"` //目的安全域
|
|
||||||
CVE string `json:"CVE"` //漏洞披露
|
|
||||||
MSB string `json:"MSB"`
|
|
||||||
BID string `json:"BID"`
|
|
||||||
RealIP string `json:"RealIP"`
|
|
||||||
CapturePktName string `json:"CapturePktName"`
|
|
||||||
HttpHost string `json:"HttpHost"` //host头
|
|
||||||
HttpFirstLine string `json:"HttpFirstLine"` //请求路径
|
|
||||||
Payload string `json:"Payload"` //请求数据
|
|
||||||
MethodName string `json:"MethodName"` //方法名称
|
|
||||||
MethodNameCN string `json:"MethodNameCN"` //方法名称中国(攻击类别)
|
|
||||||
MethodSubName string `json:"MethodSubName"` //方法子名称
|
|
||||||
MethodSubNameCN string `json:"MethodSubNameCN"` //方法子名称中国(具体攻击形式)
|
|
||||||
LoginUserName string `json:"LoginUserName"`
|
|
||||||
LoginPassword string `json:"LoginPassword"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TimeFilter struct {
|
|
||||||
StartTime string `json:"StartTime"`
|
|
||||||
EndTime string `json:"EndTime"`
|
|
||||||
}
|
|
||||||
|
@ -2,7 +2,6 @@ package conn
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"encoding/json"
|
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
@ -13,7 +12,7 @@ import (
|
|||||||
// headers := map[string]string{
|
// headers := map[string]string{
|
||||||
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
// "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||||
// }
|
// }
|
||||||
func DT_POST(urls string, headers map[string]string, bytess io.Reader) Person {
|
func DT_POST(urls string, headers map[string]string, bytess io.Reader) string {
|
||||||
url, err := url.Parse(urls)
|
url, err := url.Parse(urls)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
@ -53,14 +52,8 @@ func DT_POST(urls string, headers map[string]string, bytess io.Reader) Person {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
log.Println(string(body))
|
// log.Println(string(body))
|
||||||
// var gcresp map[string]interface{}
|
return string(body)
|
||||||
// if err := ScanJson(resp, gcresp); err != nil {
|
|
||||||
// log.Println(err)
|
|
||||||
// }
|
|
||||||
var bodys Person
|
|
||||||
json.NewDecoder(resp.Body).Decode(&bodys)
|
|
||||||
return bodys
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// req 请求体 url 请求地址 headers请求头
|
// req 请求体 url 请求地址 headers请求头
|
||||||
|
8
main.go
8
main.go
@ -1,8 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"dt_automate/attackevent"
|
||||||
"dt_automate/tool"
|
"dt_automate/tool"
|
||||||
"dt_automate/wps"
|
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
@ -73,18 +73,18 @@ func main() {
|
|||||||
// method.HW_DTCLOUD() //截取运维中心的图片
|
// method.HW_DTCLOUD() //截取运维中心的图片
|
||||||
// method.HW_BAOLJ() //截取堡垒机的图片
|
// method.HW_BAOLJ() //截取堡垒机的图片
|
||||||
//运维巡检文档生成
|
//运维巡检文档生成
|
||||||
wps.HW_SYS_Word() //运维平台word文档生成
|
// wps.HW_SYS_Word() //运维平台word文档生成
|
||||||
// //政务网区截图
|
// //政务网区截图
|
||||||
// method.ZWW_FW1() //截取防火墙的图片
|
// method.ZWW_FW1() //截取防火墙的图片
|
||||||
// method.ZWW_TSGZ() //截取态势感知的图片
|
// method.ZWW_TSGZ() //截取态势感知的图片
|
||||||
// method.ZWW_DTCLOUD() //截取运维中心的图片
|
// method.ZWW_DTCLOUD() //截取运维中心的图片
|
||||||
// method.ZWWW_BAOLJ() //截取堡垒机的图片
|
// method.ZWWW_BAOLJ() //截取堡垒机的图片
|
||||||
//运维巡检文档生成
|
//运维巡检文档生成
|
||||||
wps.ZWW_SYS_Word() //运维平台word文档生成
|
// wps.ZWW_SYS_Word() //运维平台word文档生成
|
||||||
//安全巡检文档生成
|
//安全巡检文档生成
|
||||||
// wps.SAFET_Word() //安全巡检文档生成
|
// wps.SAFET_Word() //安全巡检文档生成
|
||||||
//安全事件表格生成(需要先执行互联网区防火墙截图)
|
//安全事件表格生成(需要先执行互联网区防火墙截图)
|
||||||
// attackevent.Fw_event("vindex==3a=18=0AB00=0R; supportLang=cn%2Cen; lang=cn; sessionid=200001b7412db35d796213e8e98a20f69ccd; loginid=6c0a82d050f61bf767ea5b5398eb6d17; 200001b7412db35d796213e8e98a20f69ccd=true; abcd1234=true; login=false") //将防火墙安全事件存放到xlsx文件中
|
attackevent.Fw_event("vindex==3a=18=0AB00=0R; supportLang=cn%2Cen; lang=cn; sessionid=200001b7412db35d796213e8e98a20f69ccd; loginid=6c0a82d050f61bf767ea5b5398eb6d17; 200001b7412db35d796213e8e98a20f69ccd=true; abcd1234=true; login=false") //将防火墙安全事件存放到xlsx文件中
|
||||||
// attackevent.Ceshi()
|
// attackevent.Ceshi()
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
BIN
防火墙安全事件.xlsx
Normal file
BIN
防火墙安全事件.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user