|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
import glob
|
|
|
|
|
import wx
|
|
|
|
|
import logging
|
|
|
|
|
import sys
|
|
|
|
|
import wx.lib.buttons as buttons
|
|
|
|
|
import numpy as np
|
|
|
|
|
import pandas as pd
|
|
|
|
@ -47,7 +49,7 @@ class OtherFrame(wx.Frame):
|
|
|
|
|
self.Show()
|
|
|
|
|
|
|
|
|
|
def on_edit(self, event):
|
|
|
|
|
fprint('in on_edit')
|
|
|
|
|
fprint('in on_edit', settings)
|
|
|
|
|
|
|
|
|
|
def on_window(self, event):
|
|
|
|
|
return
|
|
|
|
@ -208,16 +210,30 @@ class ServerPanel(wx.Panel):
|
|
|
|
|
self.blacklist_button = wx.Button(self, label='Add to blacklist')
|
|
|
|
|
#self.login_button.SetBackgroundColour((205, 215, 206))
|
|
|
|
|
self.blacklist_button.Bind(wx.EVT_BUTTON, self.on_blacklist)
|
|
|
|
|
|
|
|
|
|
self.whitelist_button = wx.Button(self, label='Add to whitelist')
|
|
|
|
|
#self.login_button.SetBackgroundColour((205, 215, 206))
|
|
|
|
|
self.whitelist_button.Bind(wx.EVT_BUTTON, self.on_whitelist)
|
|
|
|
|
|
|
|
|
|
self.log_button = wx.Button(self, label='Logs')
|
|
|
|
|
self.log_button.Bind(wx.EVT_BUTTON, self.on_log)
|
|
|
|
|
|
|
|
|
|
#self.log_window = wx.LogWindow(self, 'Log Window', True)
|
|
|
|
|
|
|
|
|
|
#show_log_button = wx.Button(self, wx.NewId(), 'Show Log')
|
|
|
|
|
#show_log_button.Bind(wx.EVT_BUTTON, self._show_log)
|
|
|
|
|
|
|
|
|
|
self.sub_sizer_right.Add(self.statustext, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.sub_sizer_right.Add(self.logintext, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.sub_sizer_left.Add(self.start_button, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.sub_sizer_left.Add(self.stop_button, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.sub_sizer_left.Add(self.secondary_frame_button, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.sub_sizer_left.Add(self.log_button, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.sub_sizer_right.Add(self.login_button, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.sub_sizer_right.Add(self.quit_button, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.sub_sizer_stats.Add(self.stattext, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.sub_sizer_filter.Add(self.blacklist_button, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.sub_sizer_filter.Add(self.whitelist_button, 0, wx.CENTER | wx.ALL | 100, 5)
|
|
|
|
|
self.SetSizer(self.main_sizer)
|
|
|
|
|
self.start_button.Enable(enable=settings["loggedin"])
|
|
|
|
|
self.stop_button.Enable(enable=settings["loggedin"])
|
|
|
|
@ -238,8 +254,10 @@ class ServerPanel(wx.Panel):
|
|
|
|
|
self.quit_button.Enable(enable=settings["loggedin"])
|
|
|
|
|
if self.list_ctrl.GetFirstSelected() < 0:
|
|
|
|
|
self.blacklist_button.Enable(enable=False)
|
|
|
|
|
self.whitelist_button.Enable(enable=False)
|
|
|
|
|
else:
|
|
|
|
|
self.blacklist_button.Enable(enable=settings["loggedin"])
|
|
|
|
|
self.whitelist_button.Enable(enable=settings["loggedin"])
|
|
|
|
|
def updatedata(self):
|
|
|
|
|
global settings
|
|
|
|
|
if settings["running"] == True:
|
|
|
|
@ -265,16 +283,16 @@ class ServerPanel(wx.Panel):
|
|
|
|
|
else:
|
|
|
|
|
wx.CallLater(100, self.updatedata)
|
|
|
|
|
return
|
|
|
|
|
fprint("updatedata called")
|
|
|
|
|
fprint("updatedata called", settings)
|
|
|
|
|
loaddata()
|
|
|
|
|
list_total = self.list_ctrl.GetItemCount()
|
|
|
|
|
list_top = self.list_ctrl.GetTopItem()
|
|
|
|
|
list_pp = self.list_ctrl.GetCountPerPage()
|
|
|
|
|
list_bottom = min(list_top + list_pp, list_total - 1)
|
|
|
|
|
if self.list_ctrl.DeleteAllItems():
|
|
|
|
|
fprint("Items deleted")
|
|
|
|
|
fprint("Items deleted", settings)
|
|
|
|
|
else:
|
|
|
|
|
fprint("Unable to delete")
|
|
|
|
|
fprint("Unable to delete", settings)
|
|
|
|
|
for i in range(len(TEST_FILE)):
|
|
|
|
|
if str(TEST_FILE.iloc[i, 4]).find("TIME_WAIT") >= 0 or str(TEST_FILE.iloc[i, 4]).find("FIN_WAIT_2") >= 0:
|
|
|
|
|
continue
|
|
|
|
@ -283,7 +301,7 @@ class ServerPanel(wx.Panel):
|
|
|
|
|
#fprint(pid)
|
|
|
|
|
idx = i
|
|
|
|
|
if TEST_FILE.iloc[i, 5] == app: # "bad" pid, highlight in red at the top
|
|
|
|
|
fprint("BAD APP UI: " + str(app))
|
|
|
|
|
fprint("BAD APP UI: " + str(app), settings)
|
|
|
|
|
idx = self.list_ctrl.InsertItem(0, TEST_FILE.iloc[i, 0])
|
|
|
|
|
self.list_ctrl.SetItemBackgroundColour(idx, wx.Colour(200, 51, 51))
|
|
|
|
|
break
|
|
|
|
@ -305,21 +323,21 @@ class ServerPanel(wx.Panel):
|
|
|
|
|
wx.CallLater(100, self.updatedata)
|
|
|
|
|
|
|
|
|
|
def on_start(self, event):
|
|
|
|
|
fprint('in on_start')
|
|
|
|
|
fprint('in on_start', settings)
|
|
|
|
|
settings["running"] = True
|
|
|
|
|
|
|
|
|
|
def on_stop(self, event):
|
|
|
|
|
fprint('in on_stop')
|
|
|
|
|
fprint('in on_stop', settings)
|
|
|
|
|
settings["running"] = False
|
|
|
|
|
util.clear_fwll()
|
|
|
|
|
|
|
|
|
|
def on_window(self, event):
|
|
|
|
|
fprint("open settings")
|
|
|
|
|
fprint("open settings", settings)
|
|
|
|
|
dg = GetData(parent = None)
|
|
|
|
|
dg.ShowModal()
|
|
|
|
|
|
|
|
|
|
def on_login(self, event):
|
|
|
|
|
fprint("open login")
|
|
|
|
|
fprint("open login", settings)
|
|
|
|
|
if settings["loggedin"] == True:
|
|
|
|
|
settings["loggedin"] = False
|
|
|
|
|
return
|
|
|
|
@ -341,10 +359,32 @@ class ServerPanel(wx.Panel):
|
|
|
|
|
proto = self.list_ctrl.GetItem(idx, 1).GetText()
|
|
|
|
|
dest = self.list_ctrl.GetItem(idx, 3).GetText()
|
|
|
|
|
destip, destport = dest.split(":")
|
|
|
|
|
fprint([proto, destip, destport])
|
|
|
|
|
fprint([proto, destip, destport], settings)
|
|
|
|
|
tmp.append(["N/A", proto, "N/A", "N/A", destip, destport, "N/A", "N/A", "N/A", "N/A", "N/A", "N/A", "N/A"])
|
|
|
|
|
settings["appendbad"] = tmp
|
|
|
|
|
|
|
|
|
|
def on_whitelist(self, event):
|
|
|
|
|
global settings
|
|
|
|
|
tmp = settings["whitelist"]
|
|
|
|
|
idx = self.list_ctrl.GetFirstSelected()
|
|
|
|
|
if idx < 0:
|
|
|
|
|
return
|
|
|
|
|
proto = self.list_ctrl.GetItem(idx, 1).GetText()
|
|
|
|
|
dest = self.list_ctrl.GetItem(idx, 3).GetText()
|
|
|
|
|
pid = self.list_ctrl.GetItem(idx, 5).GetText()
|
|
|
|
|
destip, destport = dest.split(":")
|
|
|
|
|
fprint([proto, destip, destport], settings)
|
|
|
|
|
tmp.append([destip, destport, int(pid)])
|
|
|
|
|
settings["whitelist"] = tmp
|
|
|
|
|
|
|
|
|
|
def on_log(self, event):
|
|
|
|
|
fprint("open log", settings)
|
|
|
|
|
dg = logData(parent = None)
|
|
|
|
|
#fprint("attempting logLoop", settings)
|
|
|
|
|
logData.logLoop(dg)
|
|
|
|
|
#fprint("did logLoop work?", settings)
|
|
|
|
|
dg.ShowModal()
|
|
|
|
|
|
|
|
|
|
def ShowImage(self, imageFile):
|
|
|
|
|
if imageFile == "":
|
|
|
|
|
self.bitmap = wx.StaticBitmap(self, -1, size=(0, 0))
|
|
|
|
@ -373,7 +413,7 @@ def openwindow(data, sets, kill):
|
|
|
|
|
displaydata = data
|
|
|
|
|
settings = sets
|
|
|
|
|
#if settings["loggedin"]:
|
|
|
|
|
fprint("Creating server panel")
|
|
|
|
|
fprint("Creating server panel", settings)
|
|
|
|
|
loaddata()
|
|
|
|
|
app = wx.App(False)
|
|
|
|
|
frame = OtherFrame()
|
|
|
|
@ -387,6 +427,58 @@ def openwindow(data, sets, kill):
|
|
|
|
|
#frame.SetIcon(wx.Icon(find_data_file("icon.ico"), wx.BITMAP_TYPE_ICO))
|
|
|
|
|
#app.MainLoop()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RedirectText(object):
|
|
|
|
|
def __init__(self,aWxTextCtrl):
|
|
|
|
|
self.out = aWxTextCtrl
|
|
|
|
|
|
|
|
|
|
def write(self,string):
|
|
|
|
|
self.out.WriteText(string)
|
|
|
|
|
|
|
|
|
|
class logData(wx.Dialog):
|
|
|
|
|
def __init__(self, parent):
|
|
|
|
|
wx.Dialog.__init__(self, parent, wx.ID_ANY, "Logs: ", size = (800,500))
|
|
|
|
|
self.p = wx.Panel(self, wx.ID_ANY)
|
|
|
|
|
#self.logBox = wx.BoxSizer(wx.VERTICAL)
|
|
|
|
|
self.logsTitle = wx.StaticText(self.p, label="Logs", pos=(20,20))
|
|
|
|
|
self.logs = wx.TextCtrl(self.p, pos=(20,40), size= (700, 400), style=wx.TE_MULTILINE|wx.TE_READONLY|wx.HSCROLL)
|
|
|
|
|
self.logs.WriteText("init\n")
|
|
|
|
|
#keepLoop = False
|
|
|
|
|
|
|
|
|
|
def logLoop(self):
|
|
|
|
|
#self.logs.WriteText("before while loop\n")
|
|
|
|
|
i=0
|
|
|
|
|
#self.logs.Clear()
|
|
|
|
|
tmp = settings["logMsg"]
|
|
|
|
|
if (tmp is not None):
|
|
|
|
|
while(i < len(settings["logMsg"])):
|
|
|
|
|
#for i in range(len(settings["logMsg"])):
|
|
|
|
|
#self.logs.WriteText("in while loop\n")
|
|
|
|
|
self.logs.WriteText(settings["logMsg"][i])
|
|
|
|
|
self.logs.WriteText("\n")
|
|
|
|
|
tmp.remove(settings["logMsg"][i])
|
|
|
|
|
i+=1
|
|
|
|
|
else:
|
|
|
|
|
#self.logs.WriteText("settings is none :(")
|
|
|
|
|
tmp.add("init string for list")
|
|
|
|
|
logData.logLoop(self)
|
|
|
|
|
settings["logMsg"] = tmp
|
|
|
|
|
wx.CallLater(100, self.logLoop)
|
|
|
|
|
#self.logs.WriteText("after while loop\n")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#redir = RedirectText(self.logs)
|
|
|
|
|
#sys.stdout = redir
|
|
|
|
|
#self.logs.WriteText(redir)
|
|
|
|
|
|
|
|
|
|
#self.logs.LoadFile('output.log')
|
|
|
|
|
|
|
|
|
|
#def doLogging(self):
|
|
|
|
|
#self.logs.WriteText("hi from doLogging\n")
|
|
|
|
|
#self.logs.WriteText(settings["logMsg"])
|
|
|
|
|
|
|
|
|
|
class GetData(wx.Dialog):
|
|
|
|
|
def __init__(self, parent):
|
|
|
|
|
wx.Dialog.__init__(self, parent, wx.ID_ANY, "User Settings: ", size = (800,500))
|
|
|
|
@ -434,7 +526,7 @@ class GetData(wx.Dialog):
|
|
|
|
|
|
|
|
|
|
def OnQuit(self, event):
|
|
|
|
|
# save changes
|
|
|
|
|
fprint("saving changes...")
|
|
|
|
|
fprint("saving changes...", settings)
|
|
|
|
|
config = settings["config"]
|
|
|
|
|
config["sftp"]["host"] = self.hostnametext.GetValue()
|
|
|
|
|
config["sftp"]["user"] = self.usertext.GetValue()
|
|
|
|
|