-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathScript_Runner.py
More file actions
301 lines (243 loc) · 10.4 KB
/
Script_Runner.py
File metadata and controls
301 lines (243 loc) · 10.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
from tkinter import *
from tkinter.ttk import *
import tkinter as tk #used to force certain widget type
import tkinter.font as tkFont
import subprocess as sub
from sys import platform #for knowing if it is windows
from mmfunctions import *
import time
from threading import *
from pathlib import Path
import ugmfunctions
import distro #for figuring out what linux distro
#global variables
OS = distro.linux_distribution()
ops = OS[0]
def resource_path(relative_path):
""" Get absolute path to resource, works for dev and for PyInstaller """
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
#THIS_FOLDER = os.path.dirname(os.path.abspath(__file__))
#print(THIS_FOLDER + ' HELLO')
#print(os.getcwd())
#def findCWD():
# print(os.getcwd())
# for root, dirs, files, in os.walk('Q:\\'):
# if 'Script_Runner.py' in files:
# newPath = os.chdir(os.path.join(root, 'Script_Runner.py'))
# print(newPath)
# print(os.getcwd())
#findCWD()
def rmvusrgrubutton(widget):
#scrip = scriptrunnerGUI()
#print(scrip.usrd)
#scrip.usrd = 1
#print(scrip.usrd)
print(widget)
print('Removing User / Group Settings buttons')
#scrip.usrgru()
widget.grid_remove()
def chngTOusr():
scrip = scriptrunnerGUI()
print(scrip.usrd)
print(scrip.mmd)
scrip.usrd = 0
scrip.mmd = 1
print(scrip.usrd)
print(scrip.mmd)
scrip.usrgru()
def rmvmmbuttons():
scrip = scriptrunnerGUI()
print(scrip.mmd)
scrip.mmd = 1
print(scrip.mmd)
print('Removing main menu buttons...')
scrip.mmenu()
def chngTOmm():
scrip = scriptrunnerGUI()
print(scrip.mmd)
print(scrip.usrd)
scrip.mmd = 0
scrip.usrd = 1
print(scrip.mmd)
print(scrip.usrd)
scrip.usrgru()
def aboutHowtoUse():
window = Toplevel(root)
window.iconphoto(False, tk.PhotoImage(file="cup2.png"))
aboutContent = Label(window, text="""
+----------------------------------------+
| H o w T o U s e T h e P r o g r a m |
+----------------------------------------+
1.) Run as root
2.) Choose command that you would like to use
3.) Click it
4.) Sit back and relax while the command runs :)
""", background='lightgreen')
aboutContent.grid()
window.configure(bg='lightgreen')
def aboutCreators():
window = Toplevel(root)
window.iconphoto(False, tk.PhotoImage(file="cup2.png"))
aboutContent = Label(window, text="""
+----------------------+
| A P P L E C I D R |
+----------------------+
This program/Application/Script was made by and for the Apple Cidr Cyber Patriot team
Creator: Michael Brenner
""", background='lightgreen')
aboutContent.grid()
window.configure(bg='lightgreen')
class scriptrunnerGUI():
ssh = ''
ftp = ''
proftpd = ''
vsftpd = ''
web = ''
apaweb = ''
nginweb = ''
smb = ''
sql = ''
rsnc = ''
buttons = []
usrgrubuttons = []
usrd = 0
mmd = 0
fconf = 0
#commands = [mmfunc.search_media, mmfunc.updates, self.usrgru]
#def __init__(self):
# print('')
# self.firstConf()
def __init__(self):
# buttonNames=[]
cwd = os.getcwd()
#if platform == 'win32':
variableCheck = Path(cwd + '/config.py')
#elif ops == 'Ubuntu' or ops == 'debian' or ops == 'darwin':
# variableCheck = Path()
print(variableCheck)
print(cwd)
variableCheck.is_file()
if variableCheck.is_file():
print('Configuration file has been loaded...')
self.mmenu()
else:
print('Ello, you have some configurations to do!')
self.mmenu()
#Use Radio buttons for the yes or no questions
#self.header = Label(text='First Time Configuration')
#self.header.config(font=24, background='lightblue')
#self.header.grid(row=0, sticky='W')
#self.qalbl = Label(text='Does your system require the following services?')
#self.qalbl.config(font=14, background='lightblue')
#self.qalbl.grid(row=1)
# Box Labels
#self.sshlbl = Label(text='SSH [y/n] : ')
#self.sshlbl.config(background='lightblue')
#self.sshlbl.grid(row=2, column=0, sticky='W', pady='20')
#self.ftplbl = Label(text='FTP [y/n] : ')
#self.ftplbl.config(background='lightblue')
#self.ftplbl.grid(row=3, column=0, sticky='W')
# Entry/Checkbuttons Boxes
#self.ssh1 = Checkbutton(root, text='yes', offvalue=0, onvalue=1)
#self.ssh1.config()
#self.ssh2 = Checkbutton(root, text='no', offvalue=0, onvalue=1)
#self.ssh2.config()
#self.ssh1.grid(row=2, column=0, sticky='W', padx='60')
#self.ssh2.grid(row=2, column=0, sticky='W', padx='100')
#self.ftp1 = Entry(textvariable=self.ftp)
#self.ftp1.grid(row=3, column=0, sticky='W', padx='60')
#self.cont = Button(text='Continue', command=self.mmenu)
#self.cont.grid(row=1, column=1, sticky='SW')
def mmenu(self):
buttonNames = ['Search For Prohibited Media', 'Updates', 'User / Group Settings', 'Firewall Settings', 'Services Settings', 'Malware Removal', 'Audit System', 'Basic Configurations', 'Remove Prohibited Software']
thred = ThreadmmFunc()
commands = [thred.threaderSRCH, thred.threaderUPDT, chngTOusr, thred.threaderFWL, thred.threaderServ, thred.threaderMALREM, thred.threaderALYN, thred.threaderBASEconf, thred.threaderRMproCont]
# commands = [mmfunc.search_media, mmfunc.updates, self.usrgru]
gridrow = ['5', '1', '1', '2', '2', '3', '4', '4', '3']
gridcolumn = ['0', '0', '1', '0', '1', '1', '0', '1', '0']
fontSize = tkFont.Font(size=24)
for i in range(0, len(buttonNames)):
self.quit = Button(footerR, text='Quit', width=20, command=root.destroy)
self.header = Label(fHead, text='Main Menu')
self.buttons.append(Button(fCont, text=buttonNames[i], width='40', command=commands[i]))
if self.mmd == 0:
self.quit.grid_rowconfigure(0, weight=1)
self.quit.grid(row=0, sticky='E', padx=30, pady=10)
self.header.config(font=fontSize, background='lightblue')
self.header.grid(row=0, sticky='WE', padx=30, pady=20)
self.buttons[i].grid(row=gridrow[i], column=gridcolumn[i], pady='2', padx='5')
print('In Main Menu')
else:
self.quit.grid_remove()
self.header.grid_remove()
self.buttons[i].grid_remove()
def usrgru(self):
buttonNames = ['Add User to System', 'Remove User from System', 'Add Group to System', 'Remove Group from System', 'Add User to Group', 'Remove User from Group', 'List Local Users', 'List Local Groups', 'List Members of Group', 'List the Groups an User is in', 'Change all Users Passwords at Once']
gridrow = ['1', '1', '2', '2', '3', '3', '4', '4', '5', '5', '6']
gridcolumn = ['0', '1', '0', '1', '0', '1', '0', '1', '0', '1', '0']
usrgru = ugmfunctions.usrGruFunc()
targets = [usrgru.addusr, usrgru.rmuser, usrgru.adgru, usrgru.rmgru, usrgru.adusrtogru, usrgru.rmusrfrogru, usrgru.lslocausr, usrgru.lslocagru, usrgru.lsmemgru, usrgru.lsgruusrin, usrgru.chngusrspass]
fontSize = tkFont.Font(size=24)
for i in range(0, len(buttonNames)):
self.Back = Button(footerL, text='Back to Main Menu', width=20, command=chngTOmm)
self.header2 = Label(fHead, text='User and Group Settings')
self.usrgrubuttons.append(Button(fCont, text=buttonNames[i], width='40', command= lambda i=i: threader(i)))
if self.usrd == 0:
self.Back.grid(row=0, sticky='W', padx=30, pady=10)
self.Back.grid_rowconfigure(1, weight=0)
self.header2.grid(row=0, sticky='WE', padx=30, pady=20)
self.header2.config(font=fontSize, background='lightblue')
self.usrgrubuttons[i].grid(row=gridrow[i], column=gridcolumn[i], pady='2', padx='5')
print('In user / group menu')
else:
print('starting to delete buttons')
self.Back.grid_remove()
self.header2.grid_remove()
self.usrgrubuttons[i].grid_remove()
def threader(com):
try:
print(targets[com])
threader = Thread(target=targets[com])
threader.start()
except Exception as e:
print(e)
print('Could not start thread')
###################################################
if __name__ == '__main__':
# creation of GUI
root = Tk()
root.title('Apple CIDR Script Runner')
root.iconphoto(False, tk.PhotoImage(file="cup2.png"))
if platform == 'win32':
root.geometry("520x350")
elif ops == 'darwin':
root.geometry("735x350")
else:
root.geometry("680x350")
# root.resizable(0, 0)
root.grid_rowconfigure(0, weight=1)
root.grid_columnconfigure(0, weight=1)
fCont = tk.Frame(root, background='black')
fCont.grid(row=0, column=0, columnspan=2, sticky='nsew')
#fCont.grid_rowconfigure(1, weight=1)
#fCont.grid_columnconfigure(0, weight=1)
fHead = tk.Frame(fCont, background='blue')
fHead.grid(row=0, column=0, columnspan=2, sticky='ew')
footerR = tk.Frame(root, background='red')
footerR.grid(row=1, column=1, sticky='se')
footerL = tk.Frame(root, background='green')
footerL.grid(row=1, column=0, sticky='sw')
menubar = Menu(root)
aboutmenu = Menu(menubar, tearoff=0)
menubar.add_cascade(label='Help', menu=aboutmenu)
aboutmenu.add_command(label='About Creator', command=aboutCreators)
aboutmenu.add_command(label='How To Use', command=aboutHowtoUse)
main = scriptrunnerGUI()
root.configure(menu=menubar, bg='lightblue')
root.mainloop()
####################################################