diff --git a/attack_event/fw.go b/attack_event/fw.go index 46c7f1c..f29984e 100644 --- a/attack_event/fw.go +++ b/attack_event/fw.go @@ -16,8 +16,9 @@ import ( ) var cookieStr string -var Counts int //存储总条数 -var err error + +// var Counts int //存储总条数 +// var err error // 传入cookie func Fw_event(cookieStr string) { @@ -74,24 +75,14 @@ func Fw_event(cookieStr string) { body := conn.DT_POST("https://11.2.68.146/wnm/get.j", header, bytes.NewBufferString(values_1.Encode())) var bodys Person json.Unmarshal(body, &bodys) - Counts, err = strconv.Atoi(bodys.LogPaging[0].TotalCounts) - if err != nil { - log.Println(err) - } - // bodys := Person{ - // LogPaging: []LogPaging{ - // { - // TotalCounts: "899", - // }, - // }, - // } + var Con int //插入总数 //存储昨日攻击事件 if bodys.LogPaging[0].TotalCounts > "200" { a, err := strconv.ParseFloat(bodys.LogPaging[0].TotalCounts, 64) if err != nil { log.Println(err) } - log.Println(a) + log.Println("昨日查询到总条数:", a) totalPages := int(math.Floor(float64(a))/float64(200) + 1) log.Println(totalPages) for i := 1; i < totalPages+1; i++ { @@ -102,22 +93,26 @@ func Fw_event(cookieStr string) { var bodys Person json.Unmarshal(body, &bodys) log.Println(values_1, i) + + for v, k := range bodys.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) + } } - for v, k := range bodys.LogPaging { - sheet.Cell("A" + strconv.Itoa(v+1)).SetString(strconv.Itoa(v)) // 第一列 (A1) - sheet.Cell("B" + strconv.Itoa(v+1)).SetString(k.OutputJSON.Time) - sheet.Cell("C" + strconv.Itoa(v+1)).SetString(k.OutputJSON.SrcZoneName) - sheet.Cell("D" + strconv.Itoa(v+1)).SetString(k.OutputJSON.DestZoneName) - sheet.Cell("E" + strconv.Itoa(v+1)).SetString(k.OutputJSON.SrcIPAddr) - sheet.Cell("F" + strconv.Itoa(v+1)).SetString(k.OutputJSON.DestIPAddr) - sheet.Cell("G" + strconv.Itoa(v+1)).SetString(k.OutputJSON.DestPort) - sheet.Cell("H" + strconv.Itoa(v+1)).SetString(k.OutputJSON.ThreatName) - sheet.Cell("I" + strconv.Itoa(v+1)).SetString(k.OutputJSON.MethodNameCN) - sheet.Cell("J" + strconv.Itoa(v+1)).SetString(k.OutputJSON.MethodSubNameCN) - sheet.Cell("K" + strconv.Itoa(v+1)).SetString(k.OutputJSON.Application) - sheet.Cell("L" + strconv.Itoa(v+1)).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())) var bodys_1 Person @@ -127,7 +122,7 @@ func Fw_event(cookieStr string) { if err != nil { log.Println(err) } - log.Println(a) + log.Println("今日查询到总条数:", a) totalPages := int(math.Floor(float64(a))/float64(200) + 1) log.Println(totalPages) for i := 1; i < totalPages+1; i++ { @@ -138,20 +133,21 @@ func Fw_event(cookieStr string) { var bodys Person json.Unmarshal(body, &bodys) log.Println(values_1, i) - } - for v, k := range bodys.LogPaging { - sheet.Cell("A" + strconv.Itoa(v+Counts)).SetString(strconv.Itoa(v)) // 第一列 (A1) - sheet.Cell("B" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.Time) - sheet.Cell("C" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.SrcZoneName) - sheet.Cell("D" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.DestZoneName) - sheet.Cell("E" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.SrcIPAddr) - sheet.Cell("F" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.DestIPAddr) - sheet.Cell("G" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.DestPort) - sheet.Cell("H" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.ThreatName) - sheet.Cell("I" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.MethodNameCN) - sheet.Cell("J" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.MethodSubNameCN) - sheet.Cell("K" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.Application) - sheet.Cell("L" + strconv.Itoa(v+Counts)).SetString(k.OutputJSON.HttpHost) + for v, k := range bodys.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) + } } }