test data collection

formac
Cole Deck 2 years ago
parent b4aecb1974
commit 159bbf2130

@ -0,0 +1 @@
,FRAMEWORKWIN/Cole,frameworkwin,19.09.2022 20:57,file:///C:/Users/Cole/AppData/Roaming/LibreOffice/4;

Binary file not shown.

@ -0,0 +1,64 @@
import glob
import wx
import wx.adv
import os
from time import sleep
from sys import platform
TRAY_TOOLTIP = 'IP Pigeon'
TRAY_ICON = 'icon.png'
displaydata = None
settings = None
def create_menu_item(menu, label, func):
item = wx.MenuItem(menu, -1, label)
menu.Bind(wx.EVT_MENU, func, id=item.GetId())
menu.Append(item)
return item
class TaskBarIcon(wx.adv.TaskBarIcon):
def __init__(self, frame):
self.frame = frame
super(TaskBarIcon, self).__init__()
self.set_icon(TRAY_ICON)
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'Control Panel', self.on_open)
menu.AppendSeparator()
create_menu_item(menu, 'Exit', self.on_exit)
return menu
def set_icon(self, path):
icon = wx.Icon(path)
self.SetIcon(icon, TRAY_TOOLTIP)
def on_left_down(self, event):
print ('Tray icon was left-clicked.')
def on_open(self, event):
foreground()
#self.close_popup()
def on_exit(self, event):
wx.CallAfter(self.Destroy)
self.close_popup()
def close_popup(self):
self.frame.Close()
class TaskbarApp(wx.App):
def OnInit(self):
frame=wx.Frame(None)
self.SetTopWindow(frame)
TaskBarIcon(frame)
return True
def background(data, sets):
app = TaskbarApp(False)
displaydata = data
settings = sets
app.MainLoop()

@ -109,16 +109,17 @@ class FullApp(wx.App):
def background():
app = TaskbarApp(False)
with Manager() as manager:
displaydata = manager.list()
settings = manager.list()
#with Manager() as manager:
app.MainLoop()
#displaydata = manager.list()
#settings = manager.list()
#rawdata = manager.list()
#logdata = manager.list()
#uploaddata = manager.list()
#downloaddata = manager.list()
"""rawdata = manager.list()
logdata = manager.list()
uploaddata = manager.list()
downloaddata = manager.list()"""
app.MainLoop()
def open_fg(outputdata, uisettings):
app = FullApp(False)

@ -1,14 +1,95 @@
import core
import os
import subprocess
from multiprocessing import Process, Manager, Pool, TimeoutError, freeze_support
from sys import platform
from time import sleep
import csv
displaydata = None
settings = None
netdata_res = None
procdata_res = None
def run_ps(cmd):
if platform == "win32":
completed = subprocess.run(["powershell", "-Command", cmd], capture_output=True)
return completed
def netstat():
print("netstat started")
data = run_ps("netstat -n -o")
return data
def netstat_done(res):
print("netstat done")
procdata_res = pool.apply_async(process_netstat, (res,))
#netdata_res = pool.apply_async(netstat)
def process_netstat(data):
print("netstat processing")
#if platform == 'win32':
#output = data.stdout
#print(output)
output = data.stdout.decode().split('\r\n')
output2 = list(range(len(output)))
for x in range(len(output)):
output2[x] = output[x].split(" ")
output2[x] = [i for i in output2[x] if i]
output2 = [i for i in output2 if i]
print(output2)
output2 = output2[2:]
with open("out.csv", "w", newline="") as f:
writer = csv.writer(f)
writer.writerows(output2)
print("done")
def mainloop(pool):
# worker pool: netstat, netstat cleanup, upload, download, ui tasks
print("start loop")
global netdata_res
global procdata_res
global rawdata
#print(res.get(timeout=1))
if netdata_res is None or netdata_res.ready():
#rawdata = netdata_res.get()
#procdata_res = pool.apply_async(process_netstat, (rawdata))
print("netstat starting")
netdata_res = pool.apply_async(netstat, callback=netstat_done)
sleep(10)
if __name__ == '__main__':
freeze_support() # required if packaged into EXE
# create manager to share data to me, background, foreground
# create worker pool
with Pool(processes=5) as pool:
with Manager() as manager:
displaydata = manager.list(range(2)) # data to be printed
settings = manager.list(range(20)) # configuration
# launch background UI app as process
p = Process(target=core.background, args=(displaydata,settings))
p.start()
#p.join() # not a foreground job, so let's not join it
keeprunning = True
# initial setup
#netdata_res = pool.apply_async(netstat, callback=netstat_done)
# launch loop
while(keeprunning):
mainloop(pool)
# launch main, non-blocking, loop
# launch background app as process
# create worker pool
# launch main, non-blocking, loop
def mainloop():
# worker pool: netstat, netstat cleanup, upload, download, ui tasks

@ -0,0 +1,65 @@
TCP,100.106.209.107:51133,192.168.1.216:445,ESTABLISHED,4
TCP,100.106.209.107:51134,192.168.1.11:445,ESTABLISHED,4
TCP,100.106.209.107:56843,192.168.1.173:5000,ESTABLISHED,5936
TCP,104.194.122.206:49413,40.83.240.146:443,ESTABLISHED,6108
TCP,104.194.122.206:50750,199.38.182.118:443,ESTABLISHED,8076
TCP,104.194.122.206:50786,54.148.242.254:443,ESTABLISHED,8008
TCP,104.194.122.206:50818,104.192.142.11:443,ESTABLISHED,8008
TCP,104.194.122.206:51107,18.156.90.224:80,ESTABLISHED,8076
TCP,104.194.122.206:51451,172.245.94.35:22067,ESTABLISHED,8896
TCP,104.194.122.206:52328,20.42.73.139:443,ESTABLISHED,6048
TCP,104.194.122.206:52348,142.250.191.170:443,ESTABLISHED,8008
TCP,104.194.122.206:52354,142.250.191.170:443,ESTABLISHED,8008
TCP,127.0.0.1:4742,127.0.0.1:50778,ESTABLISHED,8116
TCP,127.0.0.1:5354,127.0.0.1:49670,ESTABLISHED,4076
TCP,127.0.0.1:5354,127.0.0.1:49674,ESTABLISHED,4076
TCP,127.0.0.1:6363,127.0.0.1:49761,ESTABLISHED,8116
TCP,127.0.0.1:7039,127.0.0.1:49765,ESTABLISHED,8116
TCP,127.0.0.1:10055,127.0.0.1:50174,ESTABLISHED,11608
TCP,127.0.0.1:10632,127.0.0.1:50407,ESTABLISHED,11836
TCP,127.0.0.1:15907,127.0.0.1:49698,ESTABLISHED,8116
TCP,127.0.0.1:16619,127.0.0.1:49767,ESTABLISHED,8116
TCP,127.0.0.1:16950,127.0.0.1:49772,ESTABLISHED,8116
TCP,127.0.0.1:17311,127.0.0.1:50397,ESTABLISHED,11608
TCP,127.0.0.1:19231,127.0.0.1:50409,ESTABLISHED,11836
TCP,127.0.0.1:19492,127.0.0.1:50160,ESTABLISHED,5544
TCP,127.0.0.1:21968,127.0.0.1:50395,ESTABLISHED,8116
TCP,127.0.0.1:22890,127.0.0.1:50792,ESTABLISHED,8116
TCP,127.0.0.1:22921,127.0.0.1:49762,ESTABLISHED,8116
TCP,127.0.0.1:23938,127.0.0.1:50405,ESTABLISHED,11608
TCP,127.0.0.1:25001,127.0.0.1:50406,ESTABLISHED,11836
TCP,127.0.0.1:26068,127.0.0.1:50408,ESTABLISHED,11836
TCP,127.0.0.1:28488,127.0.0.1:50402,ESTABLISHED,11608
TCP,127.0.0.1:31770,127.0.0.1:49766,ESTABLISHED,8116
TCP,127.0.0.1:41112,127.0.0.1:50530,ESTABLISHED,8076
TCP,127.0.0.1:49670,127.0.0.1:5354,ESTABLISHED,4280
TCP,127.0.0.1:49674,127.0.0.1:5354,ESTABLISHED,4280
TCP,127.0.0.1:49698,127.0.0.1:15907,ESTABLISHED,8116
TCP,127.0.0.1:49761,127.0.0.1:6363,ESTABLISHED,8116
TCP,127.0.0.1:49762,127.0.0.1:22921,ESTABLISHED,8116
TCP,127.0.0.1:49765,127.0.0.1:7039,ESTABLISHED,8116
TCP,127.0.0.1:49766,127.0.0.1:31770,ESTABLISHED,8116
TCP,127.0.0.1:49767,127.0.0.1:16619,ESTABLISHED,8116
TCP,127.0.0.1:49772,127.0.0.1:16950,ESTABLISHED,8116
TCP,127.0.0.1:50160,127.0.0.1:19492,ESTABLISHED,5544
TCP,127.0.0.1:50174,127.0.0.1:10055,ESTABLISHED,11608
TCP,127.0.0.1:50395,127.0.0.1:21968,ESTABLISHED,11608
TCP,127.0.0.1:50397,127.0.0.1:17311,ESTABLISHED,11608
TCP,127.0.0.1:50402,127.0.0.1:28488,ESTABLISHED,11608
TCP,127.0.0.1:50405,127.0.0.1:23938,ESTABLISHED,11608
TCP,127.0.0.1:50406,127.0.0.1:25001,ESTABLISHED,11608
TCP,127.0.0.1:50407,127.0.0.1:10632,ESTABLISHED,11836
TCP,127.0.0.1:50408,127.0.0.1:26068,ESTABLISHED,11836
TCP,127.0.0.1:50409,127.0.0.1:19231,ESTABLISHED,11836
TCP,127.0.0.1:50530,127.0.0.1:41112,ESTABLISHED,14552
TCP,127.0.0.1:50778,127.0.0.1:4742,ESTABLISHED,8116
TCP,127.0.0.1:50792,127.0.0.1:22890,ESTABLISHED,8116
TCP,127.0.0.1:51758,127.0.0.1:51759,ESTABLISHED,8008
TCP,127.0.0.1:51759,127.0.0.1:51758,ESTABLISHED,8008
TCP,127.0.0.1:51760,127.0.0.1:51761,ESTABLISHED,10420
TCP,127.0.0.1:51761,127.0.0.1:51760,ESTABLISHED,10420
TCP,127.0.0.1:51977,127.0.0.1:51978,ESTABLISHED,17828
TCP,127.0.0.1:51978,127.0.0.1:51977,ESTABLISHED,17828
TCP,127.0.0.1:51986,127.0.0.1:51987,ESTABLISHED,17244
TCP,127.0.0.1:51987,127.0.0.1:51986,ESTABLISHED,17244
TCP,[2620:f3:8000:5060:5939:a4c0:4f5b:113f]:52372,[2606:4700:3035::ac43:ca7b]:443,TIME_WAIT,0
1 TCP 100.106.209.107:51133 192.168.1.216:445 ESTABLISHED 4
2 TCP 100.106.209.107:51134 192.168.1.11:445 ESTABLISHED 4
3 TCP 100.106.209.107:56843 192.168.1.173:5000 ESTABLISHED 5936
4 TCP 104.194.122.206:49413 40.83.240.146:443 ESTABLISHED 6108
5 TCP 104.194.122.206:50750 199.38.182.118:443 ESTABLISHED 8076
6 TCP 104.194.122.206:50786 54.148.242.254:443 ESTABLISHED 8008
7 TCP 104.194.122.206:50818 104.192.142.11:443 ESTABLISHED 8008
8 TCP 104.194.122.206:51107 18.156.90.224:80 ESTABLISHED 8076
9 TCP 104.194.122.206:51451 172.245.94.35:22067 ESTABLISHED 8896
10 TCP 104.194.122.206:52328 20.42.73.139:443 ESTABLISHED 6048
11 TCP 104.194.122.206:52348 142.250.191.170:443 ESTABLISHED 8008
12 TCP 104.194.122.206:52354 142.250.191.170:443 ESTABLISHED 8008
13 TCP 127.0.0.1:4742 127.0.0.1:50778 ESTABLISHED 8116
14 TCP 127.0.0.1:5354 127.0.0.1:49670 ESTABLISHED 4076
15 TCP 127.0.0.1:5354 127.0.0.1:49674 ESTABLISHED 4076
16 TCP 127.0.0.1:6363 127.0.0.1:49761 ESTABLISHED 8116
17 TCP 127.0.0.1:7039 127.0.0.1:49765 ESTABLISHED 8116
18 TCP 127.0.0.1:10055 127.0.0.1:50174 ESTABLISHED 11608
19 TCP 127.0.0.1:10632 127.0.0.1:50407 ESTABLISHED 11836
20 TCP 127.0.0.1:15907 127.0.0.1:49698 ESTABLISHED 8116
21 TCP 127.0.0.1:16619 127.0.0.1:49767 ESTABLISHED 8116
22 TCP 127.0.0.1:16950 127.0.0.1:49772 ESTABLISHED 8116
23 TCP 127.0.0.1:17311 127.0.0.1:50397 ESTABLISHED 11608
24 TCP 127.0.0.1:19231 127.0.0.1:50409 ESTABLISHED 11836
25 TCP 127.0.0.1:19492 127.0.0.1:50160 ESTABLISHED 5544
26 TCP 127.0.0.1:21968 127.0.0.1:50395 ESTABLISHED 8116
27 TCP 127.0.0.1:22890 127.0.0.1:50792 ESTABLISHED 8116
28 TCP 127.0.0.1:22921 127.0.0.1:49762 ESTABLISHED 8116
29 TCP 127.0.0.1:23938 127.0.0.1:50405 ESTABLISHED 11608
30 TCP 127.0.0.1:25001 127.0.0.1:50406 ESTABLISHED 11836
31 TCP 127.0.0.1:26068 127.0.0.1:50408 ESTABLISHED 11836
32 TCP 127.0.0.1:28488 127.0.0.1:50402 ESTABLISHED 11608
33 TCP 127.0.0.1:31770 127.0.0.1:49766 ESTABLISHED 8116
34 TCP 127.0.0.1:41112 127.0.0.1:50530 ESTABLISHED 8076
35 TCP 127.0.0.1:49670 127.0.0.1:5354 ESTABLISHED 4280
36 TCP 127.0.0.1:49674 127.0.0.1:5354 ESTABLISHED 4280
37 TCP 127.0.0.1:49698 127.0.0.1:15907 ESTABLISHED 8116
38 TCP 127.0.0.1:49761 127.0.0.1:6363 ESTABLISHED 8116
39 TCP 127.0.0.1:49762 127.0.0.1:22921 ESTABLISHED 8116
40 TCP 127.0.0.1:49765 127.0.0.1:7039 ESTABLISHED 8116
41 TCP 127.0.0.1:49766 127.0.0.1:31770 ESTABLISHED 8116
42 TCP 127.0.0.1:49767 127.0.0.1:16619 ESTABLISHED 8116
43 TCP 127.0.0.1:49772 127.0.0.1:16950 ESTABLISHED 8116
44 TCP 127.0.0.1:50160 127.0.0.1:19492 ESTABLISHED 5544
45 TCP 127.0.0.1:50174 127.0.0.1:10055 ESTABLISHED 11608
46 TCP 127.0.0.1:50395 127.0.0.1:21968 ESTABLISHED 11608
47 TCP 127.0.0.1:50397 127.0.0.1:17311 ESTABLISHED 11608
48 TCP 127.0.0.1:50402 127.0.0.1:28488 ESTABLISHED 11608
49 TCP 127.0.0.1:50405 127.0.0.1:23938 ESTABLISHED 11608
50 TCP 127.0.0.1:50406 127.0.0.1:25001 ESTABLISHED 11608
51 TCP 127.0.0.1:50407 127.0.0.1:10632 ESTABLISHED 11836
52 TCP 127.0.0.1:50408 127.0.0.1:26068 ESTABLISHED 11836
53 TCP 127.0.0.1:50409 127.0.0.1:19231 ESTABLISHED 11836
54 TCP 127.0.0.1:50530 127.0.0.1:41112 ESTABLISHED 14552
55 TCP 127.0.0.1:50778 127.0.0.1:4742 ESTABLISHED 8116
56 TCP 127.0.0.1:50792 127.0.0.1:22890 ESTABLISHED 8116
57 TCP 127.0.0.1:51758 127.0.0.1:51759 ESTABLISHED 8008
58 TCP 127.0.0.1:51759 127.0.0.1:51758 ESTABLISHED 8008
59 TCP 127.0.0.1:51760 127.0.0.1:51761 ESTABLISHED 10420
60 TCP 127.0.0.1:51761 127.0.0.1:51760 ESTABLISHED 10420
61 TCP 127.0.0.1:51977 127.0.0.1:51978 ESTABLISHED 17828
62 TCP 127.0.0.1:51978 127.0.0.1:51977 ESTABLISHED 17828
63 TCP 127.0.0.1:51986 127.0.0.1:51987 ESTABLISHED 17244
64 TCP 127.0.0.1:51987 127.0.0.1:51986 ESTABLISHED 17244
65 TCP [2620:f3:8000:5060:5939:a4c0:4f5b:113f]:52372 [2606:4700:3035::ac43:ca7b]:443 TIME_WAIT 0
Loading…
Cancel
Save