Beispiel #1
0
 def _ontimer(self, event):
     """ Refresh and show network card details."""
     cur_netstat = self._ofile()
     cur_netstat.sort()
     self.tab1.Freeze()
     j = 0
     for details in self.cur_view:
         if details not in cur_netstat:
             del self.cur_view[j]
             self.tab1.DeleteItem(j)
         j += 1
     for details in cur_netstat:
         if details not in self.cur_view:
             if details[2] == "ESTABLISHED":
                 if "127.0.0.1" not in details[3]:
                     i = self.tab1.InsertStringItem(sys.maxint, str(details[0]))
                     self.tab1.SetStringItem(i, 0, details[3].lstrip("scr="))
                     self.tab1.SetStringItem(i, 1, details[4].lstrip("dst="))
                     self.tab1.SetStringItem(i, 2, details[5].lstrip("dport="))
                     self.tab1.SetStringItem(i, 3, details[1])
                     self.cur_view.append(details)
                     if self.myhost != details[3].lstrip("scr="):
                         source = details[3].lstrip("scr=")
                         port = details[5].lstrip("dport=")
                         winmesg.toster(self, "Server {0} is trying to connect via port {1}".format(source, port))
     count_rows = self.tab1.GetItemCount()
     for row in range(count_rows):
         if row % 2:
             self.tab1.SetItemBackgroundColour(row, "#FFFFFF")
         else:
             self.tab1.SetItemBackgroundColour(row, "#E5E5E5")
             self.tab1.SetBackgroundStyle(wx.LC_HRULES)
     self.tab1.Thaw()
Beispiel #2
0
    def _ontimer(self, event):
        """Refresh log messages."""

        listfile = self.openfile()
        for i in listfile:
            date = str(i[0])
            time = str(i[1])
            time = time[:-4]
            port = str(i[5])
            port = port.replace('[', '').replace(']', '')
            source = str(i[6])
            ban = str(i[7])

            if i not in self.cur_view:
                index = 0
                self.tab1.InsertStringItem(index, date)
                self.tab1.SetStringItem(index, 1, time)
                self.tab1.SetStringItem(index, 2, port)
                self.tab1.SetStringItem(index, 3, ban)
                self.tab1.SetStringItem(index, 4, source)
                self.cur_view.append(i)
                index -= 1
                cur_time = str(datetime.now().time())
                cur_time = cur_time.split(".")[0]
                cur_time = cur_time[:-1]
                timeix = time[:-1]
                if cur_time in timeix:
                    if source == 'Ban':
                        source = "banned"
                    else:
                        source = "unbanned"
                    winmesg.toster(self, 'Server {0} is {1}'.format(ban, source))
            count_rows = self.tab1.GetItemCount()
            for row in range(count_rows):
                if row % 2:
                    self.tab1.SetItemBackgroundColour(row, "#FFFFFF")
                else:
                    self.tab1.SetItemBackgroundColour(row, "#E5E5E5")
                    self.tab1.SetBackgroundStyle(wx.LC_HRULES)