Beispiel #1
0
 def login_Attempt(self):
     self.__init__()
     filename = "Login_Attempt"
     self.regular_type.append(re.compile(r'http.status_code=4(.*?);'))
     self.regular_type.append(re.compile(r'http.status_code=;'))
     _xlxs_csv.Csv2Xlxs(self.time, filename)
     wb_source = openpyxl.load_workbook("inputFile/" + self.time + "/" +
                                        filename + ".xlsx")
     ws_source = wb_source.get_sheet_by_name("Sheet")
     ws_filter_all = DO().get_Sheet(self.wb_filter, u"登录(全)", self.title)
     ws_chart_loginall = DO().get_Sheet(self.wb_chart, u"登录(全)",
                                        [u"系统", u"次数"])
     ws_top_all = DO().get_Sheet(self.wb_top, u"登录(全)", [u"IP", u"次数"])
     for rows_source in list(ws_source.rows):
         rows_source = list(rows_source)
         if DO().data_Regular(rows_source[7].value, self.regular_type):
             sys_all = DO().system_Belong(rows_source[4].value,
                                          self.assetall)
             if sys_all != None:
                 data = DO().get_Data(rows_source)
                 data.append(sys_all)
                 ws_filter_all.append(data)
                 self.top = DO().count_Dict(self.top, data[2])
                 self.charts = DO().count_Dict(self.charts, data[-1])
     ws_top_all = DO().get_Dict_data(ws_top_all, self.top)
     ws_chart_loginall = DO().get_Dict_data(ws_chart_loginall, self.charts)
     self.wb_filter.save("outputFile/" + self.time + "/" + u"数据筛选" +
                         ".xlsx")
     self.wb_chart.save("outputFile/" + self.time + "/" + u"图表" + ".xlsx")
     self.wb_top.save("outputFile/" + self.time + "/" + u"Top5" + ".xlsx")
     wb_source.close()
     print u"======登录筛选完成======"
Beispiel #2
0
 def rate_Count(self, time):
     time_ = []
     rate = {}
     wb_source = openpyxl.load_workbook("inputFile/" + time +
                                        "/IP_with_area.xlsx")
     wb_end = openpyxl.load_workbook("outputFile/" + time + u"/统计.xlsx")
     wb_end.create_sheet(u"IP(全)")
     ws_source = wb_source.get_sheet_by_name("Sheet")
     ws_end = wb_end.get_sheet_by_name(u"IP(全)")
     for i in range(2, 8):
         time_.append((datetime.datetime.now() -
                       datetime.timedelta(days=i)).strftime('%Y%m%d'))
     ip_6day = []
     for t in time_:
         test = []
         while True:
             try:
                 wb = openpyxl.load_workbook("inputFile/" + t +
                                             "/IP_with_area.xlsx")
                 ws = wb.get_sheet_by_name("Sheet")
                 break
             except:
                 _xlxs_csv.Csv2Xlxs(t, "IP_with_area")
         for y in list(ws.rows):
             test.append(y[0].value)
         ip_6day.append(test)
         wb.close()
     count = 0
     for x in list(ws_source.rows):
         x = list(x)
         if count < 1:
             title = []
             for y in x:
                 title.append(y.value)
             title.append(u'频率')
             ws_end.append(title)
             count += 1
             continue
         rate[x[0].value] = 1
         data = []
         for y in x:
             data.append(y.value)
         for day in ip_6day:
             for ip in day:
                 if ip == x[0].value:
                     rate[x[0].value] += 1
                     break
         data.append(rate[x[0].value])
         ws_end.append(data)
     wb_end.save("outputFile/" + time + u"/统计.xlsx")
     wb_end.close()
     wb_source.close()
Beispiel #3
0
 def internet_Event(self):
     self.__init__()
     filename = "Internet_Event"
     self.regular_type.append(re.compile(r'http.status_code=4(.*?);'))
     self.regular_type.append(re.compile(r'http.status_code=;'))
     self.regular_type.append(re.compile(r'http.url=/;'))
     self.regular_type.append(re.compile(r'http.url=;'))
     _xlxs_csv.Csv2Xlxs(self.time, filename)
     wb_source = openpyxl.load_workbook("inputFile/" + self.time + "/" +
                                        filename + ".xlsx")
     ws_source = wb_source.get_sheet_by_name("Sheet")
     ws_filter_portall = DO().get_Sheet(self.wb_filter, u"端口(全)",
                                        self.title)
     ws_filter_urlall = DO().get_Sheet(self.wb_filter, u"URL(全)",
                                       self.title)
     ws_chart_portall = DO().get_Sheet(self.wb_chart, u"端口(全)",
                                       [u"端口", u"次数"])
     ws_chart_urlall_sys = DO().get_Sheet(self.wb_chart, u"URL(全)系统",
                                          [u"系统", u"次数"])
     ws_chart_urlall_rul = DO().get_Sheet(self.wb_chart, u"URL(全)规则",
                                          [u"规则", u"次数"])
     ws_top_all = DO().get_Sheet(self.wb_top, u"URL(全)", [u"IP", u"次数"])
     for rows_source in list(ws_source.rows):
         rows_source = list(rows_source)
         sys_all = DO().system_Belong(rows_source[4].value, self.assetall)
         if sys_all != None:
             data = DO().get_Data(rows_source)
             data.append(sys_all)
             self.port = DO().count_Dict(self.port, data[5])
             ws_filter_portall.append(data)
             if data[7] != None:
                 if "http" in data[7]:
                     if DO().data_Regular(rows_source[7].value,
                                          self.regular_type):
                         ws_filter_urlall.append(data)
                         self.top = DO().count_Dict(self.top, data[2])
                         self.charts = DO().count_Dict(
                             self.charts, data[-1])
                         self.chartr = DO().count_Dict(self.chartr, data[1])
     ws_top_all = DO().get_Dict_data(ws_top_all, self.top)
     ws_chart_urlall_sys = DO().get_Dict_data(ws_chart_urlall_sys,
                                              self.charts)
     ws_chart_urlall_rul = DO().get_Dict_data(ws_chart_urlall_rul,
                                              self.chartr)
     ws_chart_portall = DO().get_Dict_data(ws_chart_portall, self.port)
     self.wb_filter.save("outputFile/" + self.time + "/" + u"数据筛选" +
                         ".xlsx")
     self.wb_chart.save("outputFile/" + self.time + "/" + u"图表" + ".xlsx")
     self.wb_top.save("outputFile/" + self.time + "/" + u"Top5" + ".xlsx")
     wb_source.close()
     print u"======原始筛选完成======"
Beispiel #4
0
 def rate_Count(self):
     filename = 'IP_with_area'
     _xlxs_csv.Csv2Xlxs(self.time, filename)
     DO().rate_Count(self.time)
     print u"======频率统计完成======"
Beispiel #5
0
 def internet_Event(self):
     self.__init__()
     filename = "Internet_Event"
     self.regular_type_1.append(re.compile(r'http.status_code=4(.*?);'))
     self.regular_type_0.append(re.compile(r'http.status_code=(.*?);'))
     self.regular_type_0.append(re.compile(r'http.url=/(.*?);'))
     self.regular_type_0.append(re.compile(r'http.url=(.*?);'))
     try:
         _xlxs_csv.Csv2Xlxs(self.time, filename)
     except:
         pass
     wb_source = openpyxl.load_workbook("inputFile/" + self.time + "/" +
                                        filename + ".xlsx")
     ws_source = wb_source.get_sheet_by_name("Sheet")
     ws_filter_urlall = DO().get_Sheet(self.wb_filter, u"URL(分)",
                                       self.title)
     ws_filter_url_f = DO().get_Sheet(self.wb_filter, u"URL(分)筛",
                                      self.title_f)
     ws_chart_urlsys = DO().get_Sheet(self.wb_chart, u"URL(分)系统",
                                      [u"系统", u"次数"])
     ws_chart_url = DO().get_Sheet(self.wb_chart, u"URL(分)筛URL",
                                   [u"URL", u"次数"])
     ws_top_url = DO().get_Sheet(self.wb_top, u"URL(分)",
                                 [u"URL", u"应用系统", u"源IP", u"告警名称", u"频率"])
     for rows_source in list(ws_source.rows):
         rows_source = list(rows_source)
         sys_other = DO().system_Belong(rows_source[4].value,
                                        self.assetother)
         if sys_other != None:
             data = DO().get_Data(rows_source)
             data.append(sys_other)
             ws_filter_urlall.append(data)
             self.charts = DO().count_Dict(self.charts, data[-1])
             if rows_source[7].value != None:
                 if "http.host" in rows_source[7].value:
                     if DO().data_Regular(rows_source[7].value,
                                          self.regular_type_1, 1):
                         if DO().data_Regular(rows_source[7].value,
                                              self.regular_type_0, 0):
                             host, url, user_agent, status_code = DO(
                             ).http_Split(data[7])
                             for x in status_code, user_agent, url, host:
                                 data.insert(7, x)
                             ws_filter_url_f.append(data)
                             if host != 'NULL':
                                 self.chartall = DO().count_Dict(
                                     self.chartall, host + data[8])
                                 self.topall = DO().count_Dict(
                                     self.topall, host + data[8],
                                     [data[-1], data[2], data[1]])
                             else:
                                 self.chartall = DO().count_Dict(
                                     self.chartall, data[4] + data[8])
                                 self.topall = DO().count_Dict(
                                     self.topall, data[4] + data[8],
                                     [data[-1], data[2], data[1]])
     ws_chart_url = DO().get_Dict_data(ws=ws_chart_url,
                                       dict=self.chartall,
                                       des=1)
     ws_chart_urlsys = DO().get_Dict_data(ws=ws_chart_urlsys,
                                          dict=self.charts,
                                          des=1)
     ws_top_url = DO().get_Dict_data(ws=ws_top_url,
                                     dict=self.topall,
                                     des=1,
                                     delet=1)
     self.wb_filter.save("outputFile/" + self.time + "/" + u"数据筛选" +
                         ".xlsx")
     self.wb_chart.save("outputFile/" + self.time + "/" + u"图表" + ".xlsx")
     self.wb_top.save("outputFile/" + self.time + "/" + u"Top" + ".xlsx")
     wb_source.close()
     print u"======分行筛选完成======"
Beispiel #6
0
 def lan_Event(self):
     self.__init__()
     filename = "Lan_Event"
     self.regular_type_1.append(re.compile(u"r'http.status_code=4(.*?);'"))
     self.regular_type_0.append(re.compile(u"r'http.status_code=(.*?);'"))
     try:
         _xlxs_csv.Csv2Xlxs(self.time, filename)
     except:
         pass
     wb_source = openpyxl.load_workbook("inputFile/" + self.time + "/" +
                                        filename + ".xlsx")
     ws_source = wb_source.get_sheet_by_name("Sheet")
     ws_filter_lan = DO().get_Sheet(self.wb_filter, u"内网(分)",
                                    self.title_lan)
     ws_filter_zz = DO().get_Sheet(self.wb_filter, u"自助设备", self.title_lan)
     ws_filter_wy = DO().get_Sheet(self.wb_filter, u"网银体验", self.title_lan)
     ws_chart_lan = DO().get_Sheet(self.wb_chart, u"内网(分)", [u"分行", u"次数"])
     ws_chart_zz = DO().get_Sheet(self.wb_chart, u"自助设备", [u"分行", u"次数"])
     ws_chart_wy = DO().get_Sheet(self.wb_chart, u"网银体验", [u"分行", u"次数"])
     ws_top_lan = DO().get_Sheet(
         self.wb_top, u"内网(分)",
         [u"源IP", u"源所属分行/设备", u"目IP", u"目所属分行/设备", u"规则", u"次数"])
     ws_top_zz = DO().get_Sheet(
         self.wb_top, u"自助设备",
         [u"源IP", u"源所属分行/设备", u"目IP", u"目所属分行/设备", u"规则", u"次数"])
     ws_top_wy = DO().get_Sheet(
         self.wb_top, u"网银体验",
         [u"源IP", u"源所属分行/设备", u"目IP", u"目所属分行/设备", u"规则", u"次数"])
     for rows_source in list(ws_source.rows):
         rows_source = list(rows_source)
         if u"告警时间" not in rows_source[0].value:
             if DO().data_Regular(rows_source[7].value, self.regular_type_1,
                                  1):
                 if DO().data_Regular(rows_source[7].value,
                                      self.regular_type_0, 0):
                     sbranch, sequ = DO().branch_Belong(
                         rows_source[2].value, self.assetlan)
                     obranch, oequ = DO().branch_Belong(
                         rows_source[4].value, self.assetlan)
                     data = DO().get_Data(rows_source)
                     data.append(sbranch)
                     data.append(sequ)
                     data.append(obranch)
                     data.append(oequ)
                     ws_filter_lan.append(data)
                     self.chartall = DO().count_Dict(
                         self.chartall, data[-2])
                     self.topall = DO().count_Dict(self.topall, data[2], [
                         data[-4] + '/' + data[-3], data[4],
                         data[-2] + '/' + data[-1], data[1]
                     ])
                     if u"自助设备" in sequ or u"自助设备" in oequ:
                         ws_filter_zz.append(data)
                         self.chartzz = DO().count_Dict(
                             self.chartzz, data[-2])
                         self.topzz = DO().count_Dict(
                             self.topzz, data[2], [
                                 data[-4] + '/' + data[-3], data[4],
                                 data[-2] + '/' + data[-1], data[1]
                             ])
                     if u"网银体验" in sequ or u"网银体验" in oequ:
                         ws_filter_wy.append(data)
                         self.chartwy = DO().count_Dict(
                             self.chartwy, data[-2])
                         self.topwy = DO().count_Dict(
                             self.topwy, data[2], [
                                 data[-4] + '/' + data[-3], data[4],
                                 data[-2] + '/' + data[-1], data[1]
                             ])
     ws_chart_lan = DO().get_Dict_data(ws_chart_lan, self.chartall, 1)
     ws_chart_zz = DO().get_Dict_data(ws_chart_zz, self.chartzz, 1)
     ws_chart_wy = DO().get_Dict_data(ws_chart_wy, self.chartwy, 1)
     ws_top_lan = DO().get_Dict_data(ws_top_lan, self.topall, 1)
     ws_top_zz = DO().get_Dict_data(ws_top_zz, self.topzz, 1)
     ws_top_wy = DO().get_Dict_data(ws_top_wy, self.topwy, 1)
     self.wb_filter.save("outputFile/" + self.time + "/" + u"数据筛选" +
                         ".xlsx")
     self.wb_chart.save("outputFile/" + self.time + "/" + u"图表" + ".xlsx")
     self.wb_top.save("outputFile/" + self.time + "/" + u"Top" + ".xlsx")
     wb_source.close()
     print u"======内网筛选完成======"