Compare commits
7 Commits
1665470225
...
1666032655
Author | SHA1 | Date | |
---|---|---|---|
578eea1c1f | |||
5c7cd9b0a5 | |||
a374ec73b4 | |||
b0457865d6 | |||
832cd45239 | |||
eb3d5c8910 | |||
4fb575ba62 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,3 +6,4 @@ admin-key.ppk
|
||||
token.txt
|
||||
*.zip
|
||||
output.log
|
||||
output.log
|
||||
|
BIN
IPPigeon.lnk
BIN
IPPigeon.lnk
Binary file not shown.
13
auth.py
13
auth.py
@ -16,11 +16,20 @@ def login(config, user, password, sysid):
|
||||
ssh.run_ssh(config, command, 'scripts')
|
||||
sleep(1)
|
||||
filename = sysid + "success.txt"
|
||||
if ssh.check_for_file(config, filename, 'receivelogin') == False:
|
||||
output = ssh.check_for_file(config, filename, 'receivelogin')
|
||||
if output == False:
|
||||
filename = sysid + "fail.txt"
|
||||
if ssh.check_for_file(config, filename, 'receivelogin') == False:
|
||||
# ALERT: DIRTY HACK: SECURITY VULNERABILITY
|
||||
#return True
|
||||
raise ValueError("Unable to determine login status")
|
||||
else:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
fprint(type(output))
|
||||
if str(output).find("admin") >= 0 or str(output).find("Admin") >= 0:
|
||||
fprint("Authorized as admin!")
|
||||
return True
|
||||
else:
|
||||
fprint("Not admin")
|
||||
return False
|
138
helloWorld.py
138
helloWorld.py
@ -1,138 +0,0 @@
|
||||
import glob
|
||||
import wx
|
||||
import wx.adv
|
||||
import os
|
||||
from time import sleep
|
||||
from multiprocessing import Process, Pipe
|
||||
from sys import platform
|
||||
|
||||
|
||||
TRAY_TOOLTIP = 'IP Pigeon'
|
||||
TRAY_ICON = 'icon.png'
|
||||
|
||||
"""if platform == "linux" or platform == "linux2":
|
||||
# linux
|
||||
elif platform == "darwin":
|
||||
# OS X
|
||||
elif platform == "win32":
|
||||
# Windows...
|
||||
"""
|
||||
displaydata = None
|
||||
settings = None
|
||||
|
||||
class ServerPanel(wx.Panel):
|
||||
def __init__(self, parent):
|
||||
super().__init__(parent)
|
||||
main_sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.row_obj_dict = {}
|
||||
|
||||
self.list_ctrl = wx.ListCtrl(
|
||||
self, size=(-1, 100),
|
||||
style=wx.LC_REPORT | wx.BORDER_SUNKEN
|
||||
)
|
||||
self.list_ctrl.InsertColumn(0, 'Server name', width=140)
|
||||
self.list_ctrl.InsertColumn(1, 'Port number', width=140)
|
||||
self.list_ctrl.InsertColumn(2, 'Status', width=200)
|
||||
main_sizer.Add(self.list_ctrl, 0, wx.ALL | wx.EXPAND, 5)
|
||||
start_button = wx.Button(self, label='Start')
|
||||
start_button.Bind(wx.EVT_BUTTON, self.on_edit)
|
||||
stop_button = wx.Button(self, label='Stop')
|
||||
stop_button.Bind(wx.EVT_BUTTON, self.on_edit)
|
||||
main_sizer.Add(start_button, 0, wx.ALL | 100, 5)
|
||||
main_sizer.Add(stop_button, 0, wx.ALL | 100, 5)
|
||||
self.SetSizer(main_sizer)
|
||||
|
||||
def on_edit(self, event):
|
||||
print('in on_edit')
|
||||
|
||||
def update_mp3_listing(self, folder_path):
|
||||
print(folder_path)
|
||||
|
||||
class ServerFrame(wx.Frame):
|
||||
def __init__(self):
|
||||
super().__init__(parent=None,
|
||||
title='Server Dashboard')
|
||||
self.panel = ServerPanel(self)
|
||||
self.Show()
|
||||
|
||||
### Taskbar Icon
|
||||
|
||||
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
|
||||
|
||||
class FullApp(wx.App):
|
||||
def OnInit(self):
|
||||
fullframe=ServerFrame()
|
||||
return True
|
||||
|
||||
def background():
|
||||
app = TaskbarApp(False)
|
||||
#with Manager() as manager:
|
||||
app.MainLoop()
|
||||
#displaydata = manager.list()
|
||||
#settings = manager.list()
|
||||
|
||||
|
||||
#rawdata = manager.list()
|
||||
#logdata = manager.list()
|
||||
#uploaddata = manager.list()
|
||||
#downloaddata = manager.list()
|
||||
|
||||
|
||||
def open_fg(outputdata, uisettings):
|
||||
app = FullApp(False)
|
||||
app.MainLoop()
|
||||
|
||||
def foreground():
|
||||
# Open the foreground in a separate process so that UI acts independently of the taskbar icon
|
||||
p = Process(target=open_fg, args=(displaydata, settings))
|
||||
p.start()
|
||||
#p.join()
|
||||
print("Launched foreground")
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
background()
|
35
ippigeon.py
35
ippigeon.py
@ -13,12 +13,14 @@ import util
|
||||
import netstat
|
||||
import ssh
|
||||
import auth
|
||||
import panel
|
||||
|
||||
displaydata = None
|
||||
settings = None
|
||||
netdata_res = None
|
||||
procdata_res = None
|
||||
killme = None
|
||||
ppanel = None
|
||||
datafile = ""
|
||||
#print(datafile)
|
||||
config = None
|
||||
@ -41,6 +43,16 @@ if win32:
|
||||
_, username = res.strip().rsplit("\n", 1)
|
||||
userid, sysdom = username.rsplit("\\", 1)
|
||||
|
||||
if linux:
|
||||
sysid = hex(uuid.getnode())
|
||||
#fprint(sysid)
|
||||
datafile += sysid
|
||||
datafile += "gendata.csv"
|
||||
res = subprocess.check_output(["who",], universal_newlines=True)
|
||||
userid = res.strip().split(" ")[0]
|
||||
sysdom = subprocess.check_output(["hostname",], universal_newlines=True).strip()
|
||||
#fprint(hostname)
|
||||
|
||||
def netstat_done(res):
|
||||
fprint("netstat done, processing")
|
||||
procdata_res = pool.apply_async(netstat.process, (res,), callback=process_done)
|
||||
@ -57,6 +69,8 @@ def login_done(res):
|
||||
settings["message"] = "Login failure"
|
||||
else:
|
||||
fprint("Login result in main: " + str(res))
|
||||
settings["loggedin"] = res
|
||||
settings["continueui"] = True
|
||||
|
||||
|
||||
def killall():
|
||||
@ -74,6 +88,7 @@ def mainloop(pool):
|
||||
global procdata_res
|
||||
global rawdata
|
||||
global killme
|
||||
global ppanel
|
||||
#print(killme)
|
||||
if killme.value > 0:
|
||||
#print("killing")
|
||||
@ -89,10 +104,26 @@ def mainloop(pool):
|
||||
#fprint(netdata_res.successful())
|
||||
|
||||
# runs every 50ms
|
||||
|
||||
if settings["continueui"] == True:
|
||||
settings["continueui"] = False
|
||||
if ppanel is not None:
|
||||
# login panel is already open
|
||||
ppanel.terminate()
|
||||
ppanel = Process(target=panel.openwindow, args=(displaydata,settings,killme))
|
||||
ppanel.start()
|
||||
|
||||
if settings["showui"] == True:
|
||||
settings["showui"] = False
|
||||
ppanel = Process(target=panel.openwindow, args=(displaydata,settings,killme))
|
||||
ppanel.start()
|
||||
|
||||
if settings["login"] == True:
|
||||
login_res = pool.apply_async(auth.login, (config, settings["username"], settings["password"], sysid), callback=login_done)
|
||||
#fprint(auth.login(config, settings["username"], settings["password"], sysid))
|
||||
settings["login"] = False
|
||||
|
||||
|
||||
|
||||
sleep(interval / (interval * 20.0))
|
||||
counter += 1
|
||||
@ -114,7 +145,7 @@ class Logger(object):
|
||||
sleep(0)
|
||||
|
||||
def flush(self):
|
||||
print("")
|
||||
print("",end="")
|
||||
|
||||
if __name__ == '__main__':
|
||||
freeze_support() # required if packaged into single EXE
|
||||
@ -135,6 +166,8 @@ if __name__ == '__main__':
|
||||
settings = manager.dict() # configuration
|
||||
settings["login"] = False
|
||||
settings["loggedin"] = False
|
||||
settings["showui"] = False
|
||||
settings["continueui"] = False
|
||||
killme = manager.Value('d', 0)
|
||||
#killme = False
|
||||
# launch background UI app as process
|
||||
|
0
keyfile-admin.pem
Normal file → Executable file
0
keyfile-admin.pem
Normal file → Executable file
51
netstat.py
51
netstat.py
@ -1,8 +1,9 @@
|
||||
from util import find_data_file
|
||||
from util import setup_child
|
||||
from util import fprint
|
||||
from util import run_ps
|
||||
from util import run_cmd
|
||||
from util import win32
|
||||
from util import linux
|
||||
import util
|
||||
import time
|
||||
import csv
|
||||
@ -68,13 +69,57 @@ def process(data):
|
||||
writer = csv.writer(f)
|
||||
writer.writerows(output2)
|
||||
fprint("done creating csv")
|
||||
|
||||
if linux:
|
||||
output = data.stdout.decode().split('\n') # split stdout into lines
|
||||
output = [i for i in output if i]
|
||||
if output[0].find("Not all processes could be identified") >= 0:
|
||||
fprint("Not enough permissions")
|
||||
raise PermissionError("Unable to acquire netstat data without admin!")
|
||||
output2 = list()
|
||||
output2.append([util.sysid, util.userid, util.sysdom, util.time()]) # add metadata
|
||||
for line in output:
|
||||
string_split = line.split(" ")
|
||||
string_split = [i for i in string_split if i]
|
||||
#fprint("Input: " + str(string_split))
|
||||
|
||||
if string_split[0].find("Active") >= 0 or string_split[0].find("Proto") >= 0:
|
||||
continue
|
||||
|
||||
if len(string_split) == 6: # no connection status
|
||||
#fprint(string_split)
|
||||
string_split.append(string_split[-1])
|
||||
string_split[-2] = "UNKNOWN"
|
||||
#fprint(string_split)
|
||||
|
||||
procname = string_split[6]
|
||||
if procname != "-":
|
||||
string_split2 = procname.split("/")
|
||||
procname = string_split2[1]
|
||||
pid = string_split2[0]
|
||||
else:
|
||||
pid = "Unknown"
|
||||
|
||||
output2.append([procname, string_split[0], string_split[3], string_split[4], string_split[5], pid])
|
||||
#fprint(output2)
|
||||
|
||||
with open(find_data_file(util.datafile), "w", newline="") as f:
|
||||
writer = csv.writer(f)
|
||||
writer.writerows(output2)
|
||||
fprint("done creating csv")
|
||||
|
||||
|
||||
def start():
|
||||
fprint("netstat started")
|
||||
setup_child()
|
||||
fprint("netstat started")
|
||||
|
||||
if win32:
|
||||
data = run_ps("netstat -n -o -b")
|
||||
data = run_cmd("netstat -n -o -b")
|
||||
fprint("data acquired")
|
||||
return data
|
||||
|
||||
if linux:
|
||||
data = run_cmd("netstat -atunpw")
|
||||
fprint("data acquired")
|
||||
return data
|
||||
|
||||
|
81
out.csv
81
out.csv
@ -1,81 +0,0 @@
|
||||
0xf44ee3942e7d,FRAMEWORKWIN,Cole,1664323651
|
||||
firefox.exe,TCP,[2620:f3:8000:5050:2c24:f8cf:930c:11ae]:54350,[2600:9000:2026:d600:a:da5e:7900:93a1]:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,[2620:f3:8000:5050:2c24:f8cf:930c:11ae]:54323,[2606:4700::6812:c039]:443,TIME_WAIT,0
|
||||
firefox.exe,TCP,[2620:f3:8000:5050:2c24:f8cf:930c:11ae]:54295,[2606:4700::6812:8b2f]:443,TIME_WAIT,0
|
||||
tailscale-ipn.exe,TCP,127.0.0.1:63227,127.0.0.1:41112,ESTABLISHED,13244
|
||||
nxnode.bin,TCP,127.0.0.1:63192,127.0.0.1:22753,ESTABLISHED,11476
|
||||
nxnode.bin,TCP,127.0.0.1:63191,127.0.0.1:1550,ESTABLISHED,11476
|
||||
nxnode.bin,TCP,127.0.0.1:63190,127.0.0.1:21667,ESTABLISHED,11476
|
||||
nxclient.bin,TCP,127.0.0.1:62772,127.0.0.1:15334,ESTABLISHED,12168
|
||||
nxclient.bin,TCP,127.0.0.1:62771,127.0.0.1:14346,ESTABLISHED,12168
|
||||
nxclient.bin,TCP,127.0.0.1:62770,127.0.0.1:32580,ESTABLISHED,12168
|
||||
nxnode.bin,TCP,127.0.0.1:62769,127.0.0.1:25001,ESTABLISHED,11476
|
||||
nxnode.bin,TCP,127.0.0.1:62767,127.0.0.1:24790,ESTABLISHED,11476
|
||||
nxnode.bin,TCP,127.0.0.1:62764,127.0.0.1:4831,ESTABLISHED,11476
|
||||
firefox.exe,TCP,127.0.0.1:54101,127.0.0.1:54100,ESTABLISHED,2220
|
||||
firefox.exe,TCP,127.0.0.1:54100,127.0.0.1:54101,ESTABLISHED,2220
|
||||
firefox.exe,TCP,127.0.0.1:54099,127.0.0.1:54098,ESTABLISHED,16812
|
||||
firefox.exe,TCP,127.0.0.1:54098,127.0.0.1:54099,ESTABLISHED,16812
|
||||
python.exe,TCP,127.0.0.1:53388,127.0.0.1:53387,ESTABLISHED,6380
|
||||
python.exe,TCP,127.0.0.1:53387,127.0.0.1:53388,ESTABLISHED,6380
|
||||
VSCodium.exe,TCP,127.0.0.1:53380,127.0.0.1:53379,ESTABLISHED,9272
|
||||
VSCodium.exe,TCP,127.0.0.1:53379,127.0.0.1:53380,ESTABLISHED,9272
|
||||
nxserver.bin,TCP,127.0.0.1:53359,127.0.0.1:17141,ESTABLISHED,7620
|
||||
nxserver.bin,TCP,127.0.0.1:53352,127.0.0.1:25137,ESTABLISHED,7620
|
||||
nxservice64.exe,TCP,127.0.0.1:49777,127.0.0.1:19492,ESTABLISHED,5244
|
||||
nxserver.bin,TCP,127.0.0.1:49772,127.0.0.1:7426,ESTABLISHED,7620
|
||||
nxserver.bin,TCP,127.0.0.1:49768,127.0.0.1:15484,ESTABLISHED,7620
|
||||
nxserver.bin,TCP,127.0.0.1:49767,127.0.0.1:7973,ESTABLISHED,7620
|
||||
nxserver.bin,TCP,127.0.0.1:49766,127.0.0.1:4362,ESTABLISHED,7620
|
||||
nxserver.bin,TCP,127.0.0.1:49765,127.0.0.1:5244,ESTABLISHED,7620
|
||||
nxserver.bin,TCP,127.0.0.1:49764,127.0.0.1:2739,ESTABLISHED,7620
|
||||
nxserver.bin,TCP,127.0.0.1:49704,127.0.0.1:32876,ESTABLISHED,7620
|
||||
AppleMobileDeviceService.exe,TCP,127.0.0.1:49674,127.0.0.1:5354,ESTABLISHED,4888
|
||||
AppleMobileDeviceService.exe,TCP,127.0.0.1:49670,127.0.0.1:5354,ESTABLISHED,4888
|
||||
tailscaled.exe,TCP,127.0.0.1:41112,127.0.0.1:63227,ESTABLISHED,7688
|
||||
nxserver.bin,TCP,127.0.0.1:32876,127.0.0.1:49704,ESTABLISHED,7620
|
||||
nxclient.bin,TCP,127.0.0.1:32580,127.0.0.1:62770,ESTABLISHED,12168
|
||||
nxserver.bin,TCP,127.0.0.1:25137,127.0.0.1:53352,ESTABLISHED,7620
|
||||
nxclient.bin,TCP,127.0.0.1:25001,127.0.0.1:62769,ESTABLISHED,12168
|
||||
nxserver.bin,TCP,127.0.0.1:24790,127.0.0.1:62767,ESTABLISHED,7620
|
||||
nxnode.bin,TCP,127.0.0.1:22753,127.0.0.1:63192,ESTABLISHED,11476
|
||||
nxnode.bin,TCP,127.0.0.1:21667,127.0.0.1:63190,ESTABLISHED,11476
|
||||
nxservice64.exe,TCP,127.0.0.1:19492,127.0.0.1:49777,ESTABLISHED,5244
|
||||
nxserver.bin,TCP,127.0.0.1:17141,127.0.0.1:53359,ESTABLISHED,7620
|
||||
nxserver.bin,TCP,127.0.0.1:15484,127.0.0.1:49768,ESTABLISHED,7620
|
||||
nxclient.bin,TCP,127.0.0.1:15334,127.0.0.1:62772,ESTABLISHED,12168
|
||||
nxclient.bin,TCP,127.0.0.1:14346,127.0.0.1:62771,ESTABLISHED,12168
|
||||
nxserver.bin,TCP,127.0.0.1:7973,127.0.0.1:49767,ESTABLISHED,7620
|
||||
nxserver.bin,TCP,127.0.0.1:7426,127.0.0.1:49772,ESTABLISHED,7620
|
||||
mDNSResponder.exe,TCP,127.0.0.1:5354,127.0.0.1:49674,ESTABLISHED,4948
|
||||
mDNSResponder.exe,TCP,127.0.0.1:5354,127.0.0.1:49670,ESTABLISHED,4948
|
||||
nxserver.bin,TCP,127.0.0.1:5244,127.0.0.1:49765,ESTABLISHED,7620
|
||||
nxnode.bin,TCP,127.0.0.1:4831,127.0.0.1:62764,ESTABLISHED,11476
|
||||
nxserver.bin,TCP,127.0.0.1:4362,127.0.0.1:49766,ESTABLISHED,7620
|
||||
nxserver.bin,TCP,127.0.0.1:2739,127.0.0.1:49764,ESTABLISHED,7620
|
||||
nxnode.bin,TCP,127.0.0.1:1550,127.0.0.1:63191,ESTABLISHED,11476
|
||||
nxnode.bin,TCP,104.194.96.68:54361,208.59.79.12:443,TIME_WAIT,0
|
||||
firefox.exe,TCP,104.194.96.68:54352,52.84.125.26:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,104.194.96.68:54348,35.244.181.201:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,104.194.96.68:54347,52.84.52.31:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,104.194.96.68:54346,52.84.52.31:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,104.194.96.68:54345,52.84.52.31:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,104.194.96.68:54344,52.84.52.31:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,104.194.96.68:54343,52.84.52.31:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,104.194.96.68:54342,52.84.52.31:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,104.194.96.68:54341,52.84.52.87:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,104.194.96.68:54340,54.185.157.183:443,TIME_WAIT,0
|
||||
firefox.exe,TCP,104.194.96.68:54339,35.186.227.140:443,ESTABLISHED,16812
|
||||
firefox.exe,TCP,104.194.96.68:54338,54.201.164.58:443,TIME_WAIT,0
|
||||
firefox.exe,TCP,104.194.96.68:54330,52.84.125.36:443,TIME_WAIT,0
|
||||
firefox.exe,TCP,104.194.96.68:54293,141.193.213.11:443,TIME_WAIT,0
|
||||
firefox.exe,TCP,104.194.96.68:54276,104.21.42.46:443,TIME_WAIT,0
|
||||
firefox.exe,TCP,104.194.96.68:54271,104.21.42.46:443,TIME_WAIT,0
|
||||
firefox.exe,TCP,104.194.96.68:54110,52.41.253.170:443,ESTABLISHED,16812
|
||||
syncthing.exe,TCP,104.194.96.68:53909,128.173.88.78:22067,ESTABLISHED,6668
|
||||
tailscaled.exe,TCP,104.194.96.68:53392,18.156.90.224:80,ESTABLISHED,7688
|
||||
tailscaled.exe,TCP,104.194.96.68:53214,199.38.182.118:443,ESTABLISHED,7688
|
||||
svchost.exe,TCP,104.194.96.68:49420,13.64.180.106:443,ESTABLISHED,5456
|
||||
VcomSvc.exe,TCP,100.106.209.107:63898,192.168.1.173:5000,ESTABLISHED,5424
|
||||
Windows System,TCP,100.106.209.107:53857,192.168.1.11:445,ESTABLISHED,4
|
||||
Windows System,TCP,100.106.209.107:53856,192.168.1.216:445,ESTABLISHED,4
|
|
56765
output.log
56765
output.log
File diff suppressed because one or more lines are too long
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@ -0,0 +1,5 @@
|
||||
fabric
|
||||
paramiko
|
||||
wxpython
|
||||
cx_Freeze
|
||||
pandas
|
7
setup.py
7
setup.py
@ -12,10 +12,15 @@ base = None
|
||||
if sys.platform == "win32" and not debug:
|
||||
base = "Win32GUI"
|
||||
|
||||
if sys.platform == "linux" or sys.platform == "linux2" or sys.platform == "darwin":
|
||||
name = "IPPigeon"
|
||||
else:
|
||||
name = "IPPigeon.exe"
|
||||
|
||||
setup(
|
||||
name="IP Pigeon",
|
||||
version="0.2.4",
|
||||
description="IP Pigeon client application",
|
||||
options={"build_exe": build_exe_options},
|
||||
executables=[Executable("ippigeon.py", base=base, icon="icon.ico", uac_admin=True, target_name="IPPigeon.exe")],
|
||||
executables=[Executable("ippigeon.py", base=base, icon="icon.ico", uac_admin=True, target_name=name)],
|
||||
)
|
@ -7,6 +7,7 @@ from sys import platform
|
||||
import sys
|
||||
from util import find_data_file
|
||||
from util import fprint
|
||||
from util import setup_child
|
||||
|
||||
TRAY_TOOLTIP = 'IP Pigeon'
|
||||
|
||||
@ -44,20 +45,21 @@ class TaskBarIcon(wx.adv.TaskBarIcon):
|
||||
fprint ('Tray icon was left-clicked.')
|
||||
|
||||
def on_open(self, event):
|
||||
foreground()
|
||||
#self.close_popup()
|
||||
settings["showui"] = True
|
||||
self.close_popup()
|
||||
|
||||
def on_login(self, event):
|
||||
settings["username"] = "Cole"
|
||||
settings["password"] = "12345"
|
||||
settings["username"] = "frontend"
|
||||
settings["password"] = "qwertyuiop"
|
||||
settings["login"] = True
|
||||
|
||||
def on_exit(self, event):
|
||||
wx.CallAfter(self.Destroy)
|
||||
self.close_popup()
|
||||
#print("kill cmd")
|
||||
global killme
|
||||
killme.value += 1
|
||||
self.close_popup()
|
||||
#print("kill cmd")
|
||||
|
||||
|
||||
def close_popup(self):
|
||||
self.frame.Close()
|
||||
@ -67,9 +69,11 @@ class TaskbarApp(wx.App):
|
||||
frame=wx.Frame(None)
|
||||
self.SetTopWindow(frame)
|
||||
TaskBarIcon(frame)
|
||||
|
||||
return True
|
||||
|
||||
def background(data, sets, kill):
|
||||
setup_child()
|
||||
global killme
|
||||
global settings
|
||||
global displaydata
|
||||
@ -77,6 +81,10 @@ def background(data, sets, kill):
|
||||
app = TaskbarApp(False)
|
||||
displaydata = data
|
||||
settings = sets
|
||||
fprint("Creating taskbar icon")
|
||||
app.MainLoop()
|
||||
|
||||
TRAY_ICON = find_data_file('icon.png')
|
||||
TRAY_ICON = find_data_file('icon.png')
|
||||
|
||||
if __name__ == "__main__":
|
||||
background(list(), dict(), int())
|
94
taskbartool2.py
Normal file
94
taskbartool2.py
Normal file
@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env pythonw
|
||||
|
||||
import wx
|
||||
import wx.adv
|
||||
import wx.lib.embeddedimage
|
||||
|
||||
WXPdemo = wx.lib.embeddedimage.PyEmbeddedImage(
|
||||
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABHNCSVQICAgIfAhkiAAAAWlJ"
|
||||
"REFUWIW1V1sSwjAIBMebeBU9db2KZ8EPmxbCI4TUnXGskWaXDQktwhjErjERP4XRhER08iPi"
|
||||
"5SKiyQR5JyI7xxB3j7wn5GI6V2hFxM0gJtjYANFBiIjQu7L/1lYlwR0QxLDZhE0II1+CtwRC"
|
||||
"RI8riBva7DL7CC9VAwDbbxwKtdDXwBi7K+1zCP99T1vDFedd8FBwYd6BCAUXuACEF7QsbET/"
|
||||
"FaHs+gDQw4vOLNHkMojAnTw8nlNipIiwmR0DCXJbjCXkFCAL23BnpQgRWt1EMbyujCK9AZzZ"
|
||||
"f+b3sX0oSqJQ6EorFeT4NiL6Wtj0+LXnQAzThYoAAsN6ehqR3sHExmcEqGeFApQLcTvm5Kt9"
|
||||
"wkHGgb+RZwSkyc1dwOcpCtCoNKSz6FRCUQ3o7Nn+5Y+Lg+y5CIXlcyAk99ziiQS32+svz/UY"
|
||||
"vClJoLpIC8gi+VwwfDecEiEtT/WZTJDf94uk1Ru8vbz0cvoF7S2DnpeVL9UAAAAASUVORK5C"
|
||||
"YII=")
|
||||
|
||||
class DemoTaskBarIcon(wx.adv.TaskBarIcon):
|
||||
TBMENU_RESTORE = wx.NewId()
|
||||
TBMENU_CLOSE = wx.NewId()
|
||||
TBMENU_CHANGE = wx.NewId()
|
||||
TBMENU_REMOVE = wx.NewId()
|
||||
|
||||
def __init__(self, frame):
|
||||
wx.adv.TaskBarIcon.__init__(self)
|
||||
self.frame = frame
|
||||
|
||||
# Set the image
|
||||
icon = self.MakeIcon(WXPdemo.GetImage())
|
||||
self.SetIcon(icon, "wxPython Demo")
|
||||
self.imgidx = 1
|
||||
|
||||
# bind some events
|
||||
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DCLICK, self.OnTaskBarActivate)
|
||||
self.Bind(wx.EVT_MENU, self.OnTaskBarActivate, id=self.TBMENU_RESTORE)
|
||||
self.Bind(wx.EVT_MENU, self.OnTaskBarClose, id=self.TBMENU_CLOSE)
|
||||
|
||||
|
||||
def CreatePopupMenu(self):
|
||||
"""
|
||||
This method is called by the base class when it needs to popup
|
||||
the menu for the default EVT_RIGHT_DOWN event. Just create
|
||||
the menu how you want it and return it from this function,
|
||||
the base class takes care of the rest.
|
||||
"""
|
||||
menu = wx.Menu()
|
||||
menu.Append(self.TBMENU_RESTORE, "Restore wxPython Demo")
|
||||
menu.Append(self.TBMENU_CLOSE, "Close wxPython Demo")
|
||||
return menu
|
||||
|
||||
|
||||
def MakeIcon(self, img):
|
||||
"""
|
||||
The various platforms have different requirements for the
|
||||
icon size...
|
||||
"""
|
||||
if "wxMSW" in wx.PlatformInfo:
|
||||
img = img.Scale(16, 16)
|
||||
elif "wxGTK" in wx.PlatformInfo:
|
||||
img = img.Scale(22, 22)
|
||||
# wxMac can be any size upto 128x128, so leave the source img alone....
|
||||
icon = wx.Icon("icon.png")
|
||||
#self.SetIcon(icon, TRAY_TOOLTIP)
|
||||
return icon
|
||||
|
||||
|
||||
def OnTaskBarActivate(self, evt):
|
||||
if self.frame.IsIconized():
|
||||
self.frame.Iconize(False)
|
||||
if not self.frame.IsShown():
|
||||
self.frame.Show(True)
|
||||
self.frame.Raise()
|
||||
|
||||
|
||||
def OnTaskBarClose(self, evt):
|
||||
wx.CallAfter(self.frame.Close)
|
||||
|
||||
|
||||
|
||||
class MainFrame(wx.Frame):
|
||||
def __init__(self, parent):
|
||||
wx.Frame.__init__(self, parent, title="Hello World")
|
||||
self.tbicon = DemoTaskBarIcon(self)
|
||||
self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
|
||||
|
||||
def OnCloseWindow(self, evt):
|
||||
self.tbicon.Destroy()
|
||||
evt.Skip()
|
||||
|
||||
|
||||
app = wx.App(redirect=False)
|
||||
frame = MainFrame(None)
|
||||
frame.Show(True)
|
||||
app.MainLoop()
|
@ -1,55 +0,0 @@
|
||||
import wx.adv
|
||||
import wx
|
||||
TRAY_TOOLTIP = 'Name'
|
||||
TRAY_ICON = 'icon.png'
|
||||
|
||||
|
||||
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, 'Site', self.on_hello)
|
||||
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_hello(self, event):
|
||||
print ('Hello, world!')
|
||||
|
||||
def on_exit(self, event):
|
||||
wx.CallAfter(self.Destroy)
|
||||
self.frame.Close()
|
||||
|
||||
class App(wx.App):
|
||||
def OnInit(self):
|
||||
frame=wx.Frame(None)
|
||||
self.SetTopWindow(frame)
|
||||
TaskBarIcon(frame)
|
||||
return True
|
||||
|
||||
def main():
|
||||
app = App(False)
|
||||
app.MainLoop()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
28
util.py
28
util.py
@ -25,6 +25,17 @@ if win32:
|
||||
_, username = res.strip().rsplit("\n", 1)
|
||||
userid, sysdom = username.rsplit("\\", 1)
|
||||
|
||||
if linux:
|
||||
sysid = hex(uuid.getnode())
|
||||
#fprint(sysid)
|
||||
datafile += sysid
|
||||
datafile += "gendata.csv"
|
||||
res = subprocess.check_output(["who",], universal_newlines=True)
|
||||
userid = res.strip().split(" ")[0]
|
||||
sysdom = subprocess.check_output(["hostname",], universal_newlines=True).strip()
|
||||
#fprint(sysdom)
|
||||
#fprint("d")
|
||||
|
||||
def time():
|
||||
return int(t.time())
|
||||
|
||||
@ -35,12 +46,12 @@ def fprint(msg):
|
||||
frm = inspect.stack()[1]
|
||||
|
||||
mod = inspect.getmodule(frm[0])
|
||||
print('[' + mod.__name__ + ":" + frm.function + ']:', msg)
|
||||
print('[' + mod.__name__ + ":" + frm.function + ']:', str(msg))
|
||||
except Exception as e:
|
||||
try:
|
||||
print('[????:' + frm.function + ']:', msg)
|
||||
print('[????:' + frm.function + ']:', str(msg))
|
||||
except:
|
||||
print('[????]:', msg)
|
||||
print('[????]:', str(msg))
|
||||
|
||||
|
||||
# else:
|
||||
@ -56,8 +67,7 @@ def find_data_file(filename):
|
||||
datadir = os.path.dirname(__file__)
|
||||
return os.path.join(datadir, filename)
|
||||
|
||||
def run_ps(cmd):
|
||||
fprint("init PS")
|
||||
def run_cmd(cmd):
|
||||
if win32:
|
||||
startupinfo = subprocess.STARTUPINFO()
|
||||
#print("DICKS")
|
||||
@ -72,7 +82,11 @@ def run_ps(cmd):
|
||||
completed = subprocess.run(["powershell", "-Command", cmd], capture_output=True, startupinfo=startupinfo)
|
||||
fprint("ran PS command successfully")
|
||||
#completed = subprocess.run(["powershell", "-WindowStyle", "hidden", "-Command", cmd], capture_output=True, startupinfo=startupinfo)
|
||||
|
||||
return completed
|
||||
if linux:
|
||||
fprint("running sh command: " + cmd)
|
||||
completed = subprocess.run(["sh", "-c", cmd], capture_output=True)
|
||||
fprint("ran sh command successfully")
|
||||
return completed
|
||||
|
||||
def setup_child():
|
||||
@ -95,4 +109,4 @@ class Logger(object):
|
||||
sleep(0)
|
||||
|
||||
def flush(self):
|
||||
print("")
|
||||
print("", end="")
|
Reference in New Issue
Block a user