Compare commits
2 Commits
1665462364
...
master
Author | SHA1 | Date | |
---|---|---|---|
4298d8da16 | |||
f80115da99 |
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,8 +0,0 @@
|
|||||||
__pycache__/
|
|
||||||
build/
|
|
||||||
config.yaml
|
|
||||||
0xf44ee3942e7dgendata.csv
|
|
||||||
0xf44ee3942e7agendata.csv
|
|
||||||
admin-key.ppk
|
|
||||||
token.txt
|
|
||||||
*.zip
|
|
BIN
IPPigeon.lnk
BIN
IPPigeon.lnk
Binary file not shown.
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Binary file not shown.
17
config.yml
17
config.yml
@ -1,17 +0,0 @@
|
|||||||
sftp:
|
|
||||||
host: ec2-34-232-29-46.compute-1.amazonaws.com
|
|
||||||
user: ec2-user
|
|
||||||
port: 22
|
|
||||||
keyfile: keyfile-admin.pem
|
|
||||||
filepath:
|
|
||||||
send: /home/ec2-user/Incoming/Incoming_Data
|
|
||||||
login: /home/ec2-user/Incoming/Login
|
|
||||||
recieve: /home/ec2-user/Outgoing
|
|
||||||
|
|
||||||
ui:
|
|
||||||
darkmode: true
|
|
||||||
|
|
||||||
core:
|
|
||||||
autokill: false
|
|
||||||
localadmin: true
|
|
||||||
interval: 10
|
|
119
helloWorld.py
119
helloWorld.py
@ -1,45 +1,34 @@
|
|||||||
import glob
|
import glob
|
||||||
import wx
|
import wx
|
||||||
import wx.adv
|
import wx.lib.buttons as buttons
|
||||||
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):
|
class ServerPanel(wx.Panel):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
main_sizer = wx.BoxSizer(wx.VERTICAL)
|
main_sizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
secondary_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
self.row_obj_dict = {}
|
self.row_obj_dict = {}
|
||||||
|
|
||||||
self.list_ctrl = wx.ListCtrl(
|
self.list_ctrl = wx.ListCtrl(
|
||||||
self, size=(-1, 100),
|
self, size=(-1, 100),
|
||||||
style=wx.LC_REPORT | wx.BORDER_SUNKEN
|
style=wx.LC_REPORT | wx.BORDER_SUNKEN
|
||||||
)
|
)
|
||||||
|
# self.pnl1.SetBackgroundColour(wx.BLACK)
|
||||||
self.list_ctrl.InsertColumn(0, 'Server name', width=140)
|
self.list_ctrl.InsertColumn(0, 'Server name', width=140)
|
||||||
self.list_ctrl.InsertColumn(1, 'Port number', width=140)
|
self.list_ctrl.InsertColumn(1, 'Port number', width=140)
|
||||||
self.list_ctrl.InsertColumn(2, 'Status', width=200)
|
self.list_ctrl.InsertColumn(2, 'Status', width=200)
|
||||||
main_sizer.Add(self.list_ctrl, 0, wx.ALL | wx.EXPAND, 5)
|
main_sizer.Add(self.list_ctrl, 0, wx.ALL | wx.EXPAND, 5)
|
||||||
start_button = wx.Button(self, label='Start')
|
start_button = wx.Button(self, label='Start')
|
||||||
|
start_button.SetBackgroundColour((205, 215, 206))
|
||||||
start_button.Bind(wx.EVT_BUTTON, self.on_edit)
|
start_button.Bind(wx.EVT_BUTTON, self.on_edit)
|
||||||
stop_button = wx.Button(self, label='Stop')
|
stop_button = wx.Button(self, label='Stop')
|
||||||
|
stop_button.SetBackgroundColour('#F08080')
|
||||||
|
# wx.BORDER(stop_button, wx.BORDER_NONE)
|
||||||
stop_button.Bind(wx.EVT_BUTTON, self.on_edit)
|
stop_button.Bind(wx.EVT_BUTTON, self.on_edit)
|
||||||
main_sizer.Add(start_button, 0, wx.ALL | 100, 5)
|
main_sizer.Add(start_button, 0, wx.CENTER | wx.ALL | 100, 5)
|
||||||
main_sizer.Add(stop_button, 0, wx.ALL | 100, 5)
|
main_sizer.Add(stop_button, 0, wx.CENTER | 100, 5)
|
||||||
|
# start_button.SetWindowStyleFlag(wx.SIMPLE_BORDER)
|
||||||
|
# stop_button.SetWindowStyleFlag(wx.SIMPLE_BORDER)
|
||||||
|
# wx.StaticBitmap(self, -1, png, (500, 300), (png.GetWidth(), png.GetHeight()))
|
||||||
self.SetSizer(main_sizer)
|
self.SetSizer(main_sizer)
|
||||||
|
|
||||||
def on_edit(self, event):
|
def on_edit(self, event):
|
||||||
@ -52,87 +41,13 @@ class ServerFrame(wx.Frame):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(parent=None,
|
super().__init__(parent=None,
|
||||||
title='Server Dashboard')
|
title='Server Dashboard')
|
||||||
|
self.SetBackgroundColour((44, 51, 51))
|
||||||
self.panel = ServerPanel(self)
|
self.panel = ServerPanel(self)
|
||||||
|
# image = wx.StaticBitmap(self, wx.ID_ANY)
|
||||||
|
# image.SetBitmap(wx.Bitmap('WXPython.png'))
|
||||||
self.Show()
|
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__':
|
if __name__ == '__main__':
|
||||||
background()
|
app = wx.App(False)
|
||||||
|
frame = ServerFrame()
|
||||||
|
app.MainLoop()
|
139
ippigeon.py
139
ippigeon.py
@ -1,139 +0,0 @@
|
|||||||
import os
|
|
||||||
import sys
|
|
||||||
import subprocess
|
|
||||||
from multiprocessing import Process, Manager, Pool, TimeoutError, freeze_support, active_children
|
|
||||||
from sys import platform
|
|
||||||
from time import sleep
|
|
||||||
import uuid
|
|
||||||
import yaml
|
|
||||||
from util import find_data_file
|
|
||||||
from util import fprint
|
|
||||||
import taskbartool
|
|
||||||
import util
|
|
||||||
import netstat
|
|
||||||
import ssh
|
|
||||||
|
|
||||||
displaydata = None
|
|
||||||
settings = None
|
|
||||||
netdata_res = None
|
|
||||||
procdata_res = None
|
|
||||||
killme = None
|
|
||||||
datafile = ""
|
|
||||||
#print(datafile)
|
|
||||||
config = None
|
|
||||||
interval = 10
|
|
||||||
win32 = platform == "win32"
|
|
||||||
linux = platform == "linux" or platform == "linux2"
|
|
||||||
macos = platform == "darwin"
|
|
||||||
# Get unique system values
|
|
||||||
if win32:
|
|
||||||
sysid = hex(uuid.getnode())
|
|
||||||
datafile += sysid
|
|
||||||
datafile += "gendata.csv"
|
|
||||||
# Python is running as Administrator (so netstat can get filename, to block, etc),
|
|
||||||
# so we use this to see who is actually logged in
|
|
||||||
# it's very hacky
|
|
||||||
startupinfo = subprocess.STARTUPINFO()
|
|
||||||
#if not getattr(sys, "frozen", False):
|
|
||||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW # hide powershell window
|
|
||||||
res = subprocess.check_output(["WMIC", "ComputerSystem", "GET", "UserName"], universal_newlines=True, startupinfo=startupinfo)
|
|
||||||
_, username = res.strip().rsplit("\n", 1)
|
|
||||||
userid, sysdom = username.rsplit("\\", 1)
|
|
||||||
|
|
||||||
def netstat_done(res):
|
|
||||||
fprint("netstat done, processing")
|
|
||||||
procdata_res = pool.apply_async(netstat.process, (res,), callback=process_done)
|
|
||||||
#netstat.process(res)
|
|
||||||
|
|
||||||
def process_done(res):
|
|
||||||
fprint("uploading to sftp...")
|
|
||||||
#ssh.sftp_send_data(res, config, datafile)
|
|
||||||
procdata_res = pool.apply_async(ssh.sftp_send_data, (res, config, datafile))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def killall():
|
|
||||||
kids = active_children()
|
|
||||||
for kid in kids:
|
|
||||||
kid.kill()
|
|
||||||
fprint("Every child has been killed")
|
|
||||||
os.kill(os.getpid(), 9) # dirty kill of self
|
|
||||||
|
|
||||||
def mainloop(pool):
|
|
||||||
# worker pool: netstat, netstat cleanup, upload, download, ui tasks
|
|
||||||
fprint("start loop")
|
|
||||||
|
|
||||||
global netdata_res
|
|
||||||
global procdata_res
|
|
||||||
global rawdata
|
|
||||||
global killme
|
|
||||||
#print(killme)
|
|
||||||
if killme.value > 0:
|
|
||||||
#print("killing")
|
|
||||||
killall()
|
|
||||||
#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))
|
|
||||||
fprint("netstat starting")
|
|
||||||
netdata_res = pool.apply_async(netstat.start, callback=netstat_done)
|
|
||||||
#fprint(netdata_res.successful())
|
|
||||||
sleep(interval)
|
|
||||||
|
|
||||||
class Logger(object):
|
|
||||||
def __init__(self, filename="output.log"):
|
|
||||||
self.log = open(filename, "a")
|
|
||||||
self.terminal = sys.stdout
|
|
||||||
|
|
||||||
def write(self, message):
|
|
||||||
self.log.write(message)
|
|
||||||
#close(filename)
|
|
||||||
#self.log = open(filename, "a")
|
|
||||||
try:
|
|
||||||
self.terminal.write(message)
|
|
||||||
except:
|
|
||||||
sleep(0)
|
|
||||||
|
|
||||||
def flush(self):
|
|
||||||
print("")
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
freeze_support() # required if packaged into single EXE
|
|
||||||
# create manager to share data to me, background, foreground
|
|
||||||
# create worker pool
|
|
||||||
|
|
||||||
sys.stdout = Logger(filename=find_data_file("output.log"))
|
|
||||||
sys.stderr = Logger(filename=find_data_file("output.log"))
|
|
||||||
|
|
||||||
with Pool(processes=5) as pool:
|
|
||||||
with Manager() as manager:
|
|
||||||
with open(find_data_file('config.yml'), 'r') as file:
|
|
||||||
#global config
|
|
||||||
config = yaml.safe_load(file)
|
|
||||||
#print(config['sftp']['host'])
|
|
||||||
interval = config['core']['interval']
|
|
||||||
displaydata = manager.list(range(2)) # data to be printed
|
|
||||||
settings = manager.list(range(20)) # configuration
|
|
||||||
killme = manager.Value('d', 0)
|
|
||||||
#killme = False
|
|
||||||
# launch background UI app as process
|
|
||||||
p = Process(target=taskbartool.background, args=(displaydata,settings,killme))
|
|
||||||
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 - non-blocking!
|
|
||||||
while(keeprunning):
|
|
||||||
mainloop(pool)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEpQIBAAKCAQEAkKf5kPTTHIvL44Tfe7QO13K/JVfD+DbIwWQBURqa60ohVldN
|
|
||||||
mWg7dngpMeHcr27JXLHfAT1c2ztbZR13ZZzKTpu1IbUtecVhCsduNtMzLehB8seQ
|
|
||||||
0lPLAUeE76IK7KfYBUXNXnA5n9oFTS2DJwnYgSqAODbILOxbUpdRajTbacE3Mo0p
|
|
||||||
nMLwvqcCwXXfKEhlcccclckDKkZYpwLfmuw7veD007NlBfq/lOezdFBERezEUIgr
|
|
||||||
+A22JP5KCsVeuQBJuuRrXdz8p334n2xaR4RDjN3p0cmMi2Oohm7M7MbhAImC/J+P
|
|
||||||
HXOJMQpdEgD6Ea17Jr9ORPf08HrrjaZzA/SW7QIDAQABAoIBAEe07LKdmjTxW42a
|
|
||||||
JUpl9GF6gSRawEs/pP6wuzJgFOGD6sipGE9uauOMJyeSBdp0+Z5YkepEZ85JO0IB
|
|
||||||
fFlDgsm6x+xAqp1NaZB1Ub4draYZFu/pW3HXla85q706P14Wya+7bVVeHkKOSch7
|
|
||||||
QiNM7yUAU3UKOuqB87caSYJzVzyxhUd5S6/ro2VNbXT/7vHSsKCja2scy+JaRhKn
|
|
||||||
m4cc3P+ggI06JLfZsMZY1zJKDhbWiHGmB5ZdzqAJsu/bAtXWY25QsHowYAqPG7Uq
|
|
||||||
7rcJlbbdkCASE4MXqi427uJfeqBB0vfykttSriBpQVBKus5wpcCEOMkpEho0zU0Z
|
|
||||||
yx9bdeECgYEA9d0PDjAqIwrVSxjeOd6eXcSwmMzaK5fc5beptKRQA0U/O4swhn2+
|
|
||||||
NOio6v6fTWuDwNHAsMZiDvW3boO357GCm2N7YkqvdarydfOt7IccsUnEROaAxOqx
|
|
||||||
1wlnl0NkVIwaTo3XoRSWIcIqE3mCAaz8peqtRmIcXcQ/S9RGm3QeiAUCgYEAlp67
|
|
||||||
vmn6Z1U0XLILnf4i9D3ECJlwJXEP64pB4XnXiHU/StaXY7CSRaCX+SxfgUR8pATQ
|
|
||||||
ySYDRY1Ag6cHxSVIo1vkotT3P11x7/8yWnomvnEwRJqTMdN+/VuTi4tPzU1ScNXX
|
|
||||||
F7aRqkNoGEkmsmi2wdszbJcruI74k4TGLcbNj8kCgYEAgG37AVRTjn6IMHRLETui
|
|
||||||
yiSGgyrvBDqN30lzUrNKQIsZnsb0kCx7ATRPmIFtQYnaBw0KdM0MR/g+23HezR7C
|
|
||||||
tNzghNWyleq4QLkLrzRc3pdD+SHXPgXC5Cs7e55ueGO/Ei2x56jTS8sbI5UjPjDY
|
|
||||||
wOq3nL5/RtPOpJO8VlPv5ukCgYEAjytM/D9SdNyJzD61SjWiVhVL/HyVHBHvdw3R
|
|
||||||
d5jQZfZE9kcqWekh8KspKgGiuoY2D9Y/+6N1YqxUkY+4lA3PkPAtURYr+wBA6Ebk
|
|
||||||
PxpzL3z5y4w+tBL8V6mvguomLdj8ryKktPamWXh/Pu5xqQ5eAcDxjZvYRDMqV1bS
|
|
||||||
5fpdtPkCgYEAoRVdlDSaj9u3NPoFkschl1bOZlJpm9tJVU+LoWxRe8tuLIwVDvXP
|
|
||||||
JsZMcpfinEPWSrJN+hlGDuaq7k5LtSNeQoruaafhlE+CV54G7J2Khn8pRKWT+n/p
|
|
||||||
36PfgGbhuLsZl8KDy+PXjS+L5A1kuTxB4rOBdHXIHm60aNCqB0BRcTM=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
@ -1 +0,0 @@
|
|||||||
ec2-34-232-29-46.compute-1.amazonaws.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBM8sLlu0mu1PqYXk+a9XYHXXFiOaxk/2tIS5O3q+3ah13bd5Iz+NSxS0bXT7TdMTA/lD1kWMUXROEauADgIfT98=
|
|
80
netstat.py
80
netstat.py
@ -1,80 +0,0 @@
|
|||||||
from util import find_data_file
|
|
||||||
from util import setup_child
|
|
||||||
from util import fprint
|
|
||||||
from util import run_ps
|
|
||||||
from util import win32
|
|
||||||
import util
|
|
||||||
import time
|
|
||||||
import csv
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def process(data):
|
|
||||||
setup_child()
|
|
||||||
fprint("netstat processing")
|
|
||||||
if win32:
|
|
||||||
#output = data.stdout
|
|
||||||
#print(output)
|
|
||||||
output = data.stdout.decode().split('\r\n') # split stdout into lines
|
|
||||||
#print(output)
|
|
||||||
if output[0].find("The requested operation requires elevation.") >= 0:
|
|
||||||
#print("test3")
|
|
||||||
raise PermissionError("Unable to acquire netstat data without admin!")
|
|
||||||
#print("test2")
|
|
||||||
output2 = list()
|
|
||||||
output2.append([util.sysid, util.userid, util.sysdom, util.time()]) # add metadata
|
|
||||||
#print(output2)
|
|
||||||
procname = ""
|
|
||||||
"""for x in range(4, len(output)):
|
|
||||||
tmp = output[x].split(" ")
|
|
||||||
print(tmp)
|
|
||||||
tmp = [i for i in output[x] if i]
|
|
||||||
print(tmp)
|
|
||||||
print(len(tmp))
|
|
||||||
if len(len(tmp) == 1):
|
|
||||||
procname = tmp[0]
|
|
||||||
print(x)
|
|
||||||
else:
|
|
||||||
print(x)
|
|
||||||
output2[x] = list()
|
|
||||||
output2[x].append(procname)
|
|
||||||
output2[x].append(output[x].split(" "))
|
|
||||||
output2[x] = [i for i in output2[x] if i]
|
|
||||||
output2 = [i for i in output2 if i]
|
|
||||||
print(output2)"""
|
|
||||||
x = len(output) - 1 # start at the end because filename comes after connection
|
|
||||||
procname = "Unknown" # if the very last connection happens to have no file (yes, it's possible), we can say unknown
|
|
||||||
while x > 3:
|
|
||||||
string = output[x]
|
|
||||||
#print("LINE: ", string)
|
|
||||||
string_split = string.split(" ")
|
|
||||||
string_split = [i for i in string_split if i]
|
|
||||||
if string.find("Can not obtain ownership information") >= 0: # Higher privilige than us, must be system
|
|
||||||
procname = "Windows System"
|
|
||||||
elif string.find("]") >= 0 and string.find("[") == 1: # generic [file.exe]
|
|
||||||
procname = string[2:-1]
|
|
||||||
elif len(string_split) == 5: # actual netstat line
|
|
||||||
tmp = [procname,] # add executable name first
|
|
||||||
tmp.extend(string.split(" "))
|
|
||||||
tmp = [i for i in tmp if i]
|
|
||||||
#print(tmp)
|
|
||||||
output2.append(tmp)
|
|
||||||
#else: # In case of an extra line above file, or an empty line, ignore it
|
|
||||||
#print("Garbage data", string)
|
|
||||||
x = x - 1
|
|
||||||
#output2 = output2[2:]
|
|
||||||
#print(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()
|
|
||||||
|
|
||||||
if win32:
|
|
||||||
data = run_ps("netstat -n -o -b")
|
|
||||||
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
|
|
|
11831
output.log
11831
output.log
File diff suppressed because it is too large
Load Diff
54
release.sh
54
release.sh
@ -1,54 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
#set -x
|
|
||||||
|
|
||||||
TOKEN=$(< token.txt)
|
|
||||||
EDITOR=nano git commit -a
|
|
||||||
git push
|
|
||||||
|
|
||||||
COMMIT=$(git log | head -n 1 | cut -d' ' -f2)
|
|
||||||
echo $COMMIT
|
|
||||||
export PATH=$PATH:"C:\Program Files\7-Zip"
|
|
||||||
TAG=$(date +%s)
|
|
||||||
"C:/Program Files/Python310/python.exe" setup.py build
|
|
||||||
sleep 2
|
|
||||||
mv ./build/exe.win-amd64-3.10/ ./build/ippigeon-win
|
|
||||||
7z a -r release-$COMMIT.zip ./build/ippigeon-win
|
|
||||||
7z a -sfx7z.sfx IPPigeon-install.exe ./build/ippigeon-win
|
|
||||||
mv ./build/ippigeon-win/ ./build/exe.win-amd64-3.10
|
|
||||||
#sleep 30
|
|
||||||
DATA='{
|
|
||||||
"body": "Autogenerated release",
|
|
||||||
"draft": false,
|
|
||||||
"name": "Development release",
|
|
||||||
"prerelease": true,
|
|
||||||
"tag_name": "'$TAG'",
|
|
||||||
"target_commitish": "'$COMMIT'"
|
|
||||||
}'
|
|
||||||
OUT=$(curl -X 'POST' \
|
|
||||||
'https://git.deck.sh/api/v1/repos/Interfaz/ff/releases?token='$TOKEN'' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Content-Type: application/json' \
|
|
||||||
-d "$DATA")
|
|
||||||
|
|
||||||
ID=$(echo $OUT | cut -d',' -f 1 | cut -d':' -f 2)
|
|
||||||
|
|
||||||
OUT=$(curl -X 'POST' \
|
|
||||||
'https://git.deck.sh/api/v1/repos/Interfaz/ff/releases/'$ID'/assets?token='$TOKEN'' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Content-Type: multipart/form-data' \
|
|
||||||
-F 'attachment=@IPPigeon-install.exe;type=application/octet-stream')
|
|
||||||
|
|
||||||
URL=$(echo $OUT | cut -d',' -f 7 | cut -d\" -f4)
|
|
||||||
|
|
||||||
curl -d "$URL" https://notify.deck.sh/ipro-release
|
|
||||||
echo $URL
|
|
||||||
|
|
||||||
OUT=$(curl -X 'POST' \
|
|
||||||
'https://git.deck.sh/api/v1/repos/Interfaz/ff/releases/'$ID'/assets?token='$TOKEN'' \
|
|
||||||
-H 'accept: application/json' \
|
|
||||||
-H 'Content-Type: multipart/form-data' \
|
|
||||||
-F 'attachment=@'release-$COMMIT.zip';type=application/x-zip-compressed')
|
|
||||||
|
|
||||||
|
|
||||||
rm release-$COMMIT.zip
|
|
||||||
rm IPPigeon-install.exe
|
|
21
setup.py
21
setup.py
@ -1,21 +0,0 @@
|
|||||||
import sys
|
|
||||||
from cx_Freeze import setup, Executable
|
|
||||||
|
|
||||||
debug = True
|
|
||||||
#debug = not debug
|
|
||||||
# Dependencies are automatically detected, but it might need fine tuning.
|
|
||||||
# "packages": ["os"] is used as example only
|
|
||||||
build_exe_options = {"packages": ["os"], "excludes": ["tkinter"], "include_msvcr": True, "include_files": ["icon.png", "config.yml", "keyfile-admin.pem"], "optimize": 2}
|
|
||||||
|
|
||||||
# base="Win32GUI" should be used only for Windows GUI app
|
|
||||||
base = None
|
|
||||||
if sys.platform == "win32" and not debug:
|
|
||||||
base = "Win32GUI"
|
|
||||||
|
|
||||||
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")],
|
|
||||||
)
|
|
14
ssh.py
14
ssh.py
@ -1,14 +0,0 @@
|
|||||||
from fabric import Connection
|
|
||||||
from util import find_data_file
|
|
||||||
from util import setup_child
|
|
||||||
from util import fprint
|
|
||||||
|
|
||||||
def sftp_send_data(res, config, filename):
|
|
||||||
setup_child()
|
|
||||||
fprint("Connecting over SSH to " + config['sftp']['host'])
|
|
||||||
c = Connection(host=config['sftp']['host'], user=config['sftp']['user'], port=config['sftp']['port'], connect_kwargs={"key_filename": find_data_file(config['sftp']['keyfile']),})
|
|
||||||
fprint("Sending data over SFTP: " + filename)
|
|
||||||
fprint(c.put(find_data_file(filename), remote=config['sftp']['filepath']['send']))
|
|
||||||
fprint("Data sent over SFTP sucessfully")
|
|
||||||
#command = 'ls ' + config['sftp']['filepath']['send']
|
|
||||||
#fprint(c.run(command))
|
|
@ -1,74 +0,0 @@
|
|||||||
import glob
|
|
||||||
import wx
|
|
||||||
import wx.adv
|
|
||||||
import os
|
|
||||||
from time import sleep
|
|
||||||
from sys import platform
|
|
||||||
import sys
|
|
||||||
from util import find_data_file
|
|
||||||
from util import fprint
|
|
||||||
|
|
||||||
TRAY_TOOLTIP = 'IP Pigeon'
|
|
||||||
|
|
||||||
displaydata = None
|
|
||||||
settings = None
|
|
||||||
|
|
||||||
killme = False
|
|
||||||
|
|
||||||
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):
|
|
||||||
fprint ('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()
|
|
||||||
#print("kill cmd")
|
|
||||||
global killme
|
|
||||||
killme.value += 1
|
|
||||||
|
|
||||||
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, kill):
|
|
||||||
global killme
|
|
||||||
killme = kill
|
|
||||||
app = TaskbarApp(False)
|
|
||||||
displaydata = data
|
|
||||||
settings = sets
|
|
||||||
app.MainLoop()
|
|
||||||
|
|
||||||
TRAY_ICON = find_data_file('icon.png')
|
|
@ -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()
|
|
98
util.py
98
util.py
@ -1,98 +0,0 @@
|
|||||||
import inspect
|
|
||||||
import sys
|
|
||||||
import subprocess
|
|
||||||
import os
|
|
||||||
from sys import platform
|
|
||||||
import time as t
|
|
||||||
import uuid
|
|
||||||
|
|
||||||
win32 = platform == "win32"
|
|
||||||
linux = platform == "linux" or platform == "linux2"
|
|
||||||
macos = platform == "darwin"
|
|
||||||
datafile = ""
|
|
||||||
|
|
||||||
if win32:
|
|
||||||
sysid = hex(uuid.getnode())
|
|
||||||
datafile += sysid
|
|
||||||
datafile += "gendata.csv"
|
|
||||||
# Python is running as Administrator (so netstat can get filename, to block, etc),
|
|
||||||
# so we use this to see who is actually logged in
|
|
||||||
# it's very hacky
|
|
||||||
startupinfo = subprocess.STARTUPINFO()
|
|
||||||
#if not getattr(sys, "frozen", False):
|
|
||||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW # hide powershell window
|
|
||||||
res = subprocess.check_output(["WMIC", "ComputerSystem", "GET", "UserName"], universal_newlines=True, startupinfo=startupinfo)
|
|
||||||
_, username = res.strip().rsplit("\n", 1)
|
|
||||||
userid, sysdom = username.rsplit("\\", 1)
|
|
||||||
|
|
||||||
def time():
|
|
||||||
return int(t.time())
|
|
||||||
|
|
||||||
def fprint(msg):
|
|
||||||
#if not getattr(sys, "frozen", False):
|
|
||||||
setup_child()
|
|
||||||
try:
|
|
||||||
frm = inspect.stack()[1]
|
|
||||||
|
|
||||||
mod = inspect.getmodule(frm[0])
|
|
||||||
print('[' + mod.__name__ + ":" + frm.function + ']:', msg)
|
|
||||||
except Exception as e:
|
|
||||||
try:
|
|
||||||
print('[????:' + frm.function + ']:', msg)
|
|
||||||
except:
|
|
||||||
print('[????]:', msg)
|
|
||||||
|
|
||||||
|
|
||||||
# else:
|
|
||||||
#print(msg)
|
|
||||||
|
|
||||||
def find_data_file(filename):
|
|
||||||
if getattr(sys, "frozen", False):
|
|
||||||
# The application is frozen
|
|
||||||
datadir = os.path.dirname(sys.executable)
|
|
||||||
else:
|
|
||||||
# The application is not frozen
|
|
||||||
# Change this bit to match where you store your data files:
|
|
||||||
datadir = os.path.dirname(__file__)
|
|
||||||
return os.path.join(datadir, filename)
|
|
||||||
|
|
||||||
def run_ps(cmd):
|
|
||||||
fprint("init PS")
|
|
||||||
if win32:
|
|
||||||
startupinfo = subprocess.STARTUPINFO()
|
|
||||||
#print("DICKS")
|
|
||||||
#if not getattr(sys, "frozen", False):
|
|
||||||
# print("test")
|
|
||||||
#
|
|
||||||
#completed = subprocess.run(["powershell", "-Command", cmd], capture_output=True, startupinfo=startupinfo)
|
|
||||||
#else:
|
|
||||||
# print("alt")
|
|
||||||
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW # , "-WindowStyle", "hidden"
|
|
||||||
fprint("running PS command: " + cmd)
|
|
||||||
completed = subprocess.run(["powershell", "-Command", cmd], capture_output=True, startupinfo=startupinfo)
|
|
||||||
fprint("ran PS command sucessfully")
|
|
||||||
#completed = subprocess.run(["powershell", "-WindowStyle", "hidden", "-Command", cmd], capture_output=True, startupinfo=startupinfo)
|
|
||||||
|
|
||||||
return completed
|
|
||||||
|
|
||||||
def setup_child():
|
|
||||||
if not getattr(sys, "frozen", False):
|
|
||||||
sys.stdout = Logger(filename=find_data_file("output.log"))
|
|
||||||
sys.stderr = Logger(filename=find_data_file("output.log"))
|
|
||||||
|
|
||||||
class Logger(object):
|
|
||||||
def __init__(self, filename="output.log"):
|
|
||||||
self.log = open(filename, "a")
|
|
||||||
self.terminal = sys.stdout
|
|
||||||
|
|
||||||
def write(self, message):
|
|
||||||
self.log.write(message)
|
|
||||||
#close(filename)
|
|
||||||
#self.log = open(filename, "a")
|
|
||||||
try:
|
|
||||||
self.terminal.write(message)
|
|
||||||
except:
|
|
||||||
sleep(0)
|
|
||||||
|
|
||||||
def flush(self):
|
|
||||||
print("")
|
|
Loading…
x
Reference in New Issue
Block a user