-
Notifications
You must be signed in to change notification settings - Fork 160
/
main.py
241 lines (191 loc) · 8.23 KB
/
main.py
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
####################################################################################
# BLACKMAMBA BY: LOSEYS (https://github.com/loseys)
#
# QT GUI INTERFACE BY: WANDERSON M.PIMENTA (https://github.com/Wanderson-Magalhaes)
# ORIGINAL QT GUI: https://github.com/Wanderson-Magalhaes/Simple_PySide_Base
####################################################################################
import sys
import os
import platform
import threading
import socket
from cryptography.fernet import Fernet
#from PySide2 import QtCore, QtGui, QtWidgets
#from PySide2.QtCore import (QCoreApplication, QPropertyAnimation, QDate, QDateTime, QMetaObject, QObject, QPoint, QRect, QSize, QTime, QUrl, Qt, QEvent)
#from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QCursor, QFont, QFontDatabase, QIcon, QKeySequence, QLinearGradient, QPalette, QPainter, QPixmap, QRadialGradient)
#from PySide2.QtWidgets import *
from PyQt5 import QtGui, QtCore, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtWidgets import *
from bin.set_key import server_key
from bin.config import SERVER_IP, PORT, PORT_VIDEO
# GUI FILE
from clientui.app_modules import *
class MainWindow(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
try:
import ctypes
self.setWindowIcon(QtGui.QIcon('icons/others/icon_2.png'))
myappid = 'Loseys.BlackMamba.C2.Alpha'
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
except:
self.setWindowIcon(QtGui.QIcon('icons/others/icon_2.png'))
path = str(os.path.abspath(__file__))
path = path.replace('\main.py', '').replace('/main.py', '')
try:
os.remove(f'{path}/bin/hosts/.gitkeep')
except:
pass
try:
os.remove(f'{path}/bin/request/transfer/execute/.gitkeep')
except:
pass
try:
os.remove(f'{path}/bin/request/transfer/stdin/.gitkeep')
except:
pass
try:
os.remove(f'{path}/bin/request/transfer/stdout/.gitkeep')
except:
pass
try:
os.remove(f'{path}/bin/resources/cache/.gitkeep')
except:
pass
## PRINT ==> SYSTEM
#print('System: ' + platform.system())
#print('Version: ' +platform.release())
########################################################################
## START - WINDOW ATTRIBUTES
########################################################################
## REMOVE ==> STANDARD TITLE BAR
UIFunctions.removeTitleBar(True)
## ==> END ##
## SET ==> WINDOW TITLE
self.setWindowTitle('BlackMamba')
UIFunctions.labelTitle(self, 'BlackMamba')
UIFunctions.labelDescription(self, '')
## ==> END ##
## WINDOW SIZE ==> DEFAULT SIZE
startSize = QSize(1000, 720)
#startSize = QSize(1000, 200)
self.resize(startSize)
self.setMinimumSize(startSize)
# UIFunctions.enableMaximumSize(self, 500, 720)
## ==> END ##
## ==> CREATE MENUS
########################################################################
## ==> TOGGLE MENU SIZE
self.ui.btn_toggle_menu.clicked.connect(lambda: UIFunctions.toggleMenu(self, 220, True))
## ==> END ##
## ==> ADD CUSTOM MENUS
#self.ui.stackedWidget.setMinimumWidth(20)
#UIFunctions.addNewMenu(self, "HOME", "btn_home", "url(:/16x16/icons/16x16/cil-home.png)", True)
#UIFunctions.addNewMenu(self, "Add User", "btn_new_user", "url(:/16x16/icons/16x16/cil-user-follow.png)", True)
#UIFunctions.addNewMenu(self, "Custom Widgets", "btn_widgets", "url(:/16x16/icons/16x16/cil-equalizer.png)", False)
## ==> END ##
# START MENU => SELECTION
UIFunctions.selectStandardMenu(self, "btn_home")
## ==> END ##
## ==> START PAGE
#self.ui.stackedWidget.setCurrentWidget(self.ui.page_home)
## ==> END ##
## USER ICON ==> SHOW HIDE
UIFunctions.userIcon(self, "WM", "", True)
## ==> END ##
## ==> MOVE WINDOW / MAXIMIZE / RESTORE
########################################################################
def moveWindow(event):
# IF MAXIMIZED CHANGE TO NORMAL
if UIFunctions.returStatus() == 1:
UIFunctions.maximize_restore(self)
# MOVE WINDOW
if event.buttons() == Qt.LeftButton:
self.move(self.pos() + event.globalPos() - self.dragPos)
self.dragPos = event.globalPos()
event.accept()
# WIDGET TO MOVE
self.ui.frame_label_top_btns.mouseMoveEvent = moveWindow
UIFunctions.uiDefinitions(self)
self.show()
@staticmethod
def decrypt(msg, key):
cipher_suite = Fernet(key)
decoded_text_f = cipher_suite.decrypt(msg)
return decoded_text_f
###################################################
def Button(self):
# GET BT CLICKED
btnWidget = self.sender()
# PAGE HOME
if btnWidget.objectName() == "btn_home":
self.ui.stackedWidget.setCurrentWidget(self.ui.page_home)
UIFunctions.resetStyle(self, "btn_home")
UIFunctions.labelPage(self, "Home")
btnWidget.setStyleSheet(UIFunctions.selectMenu(btnWidget.styleSheet()))
# PAGE NEW USER
if btnWidget.objectName() == "btn_new_user":
self.ui.stackedWidget.setCurrentWidget(self.ui.page_home)
UIFunctions.resetStyle(self, "btn_new_user")
UIFunctions.labelPage(self, "New User")
btnWidget.setStyleSheet(UIFunctions.selectMenu(btnWidget.styleSheet()))
# PAGE WIDGETS
if btnWidget.objectName() == "btn_widgets":
self.ui.stackedWidget.setCurrentWidget(self.ui.page_widgets)
UIFunctions.resetStyle(self, "btn_widgets")
UIFunctions.labelPage(self, "Custom Widgets")
btnWidget.setStyleSheet(UIFunctions.selectMenu(btnWidget.styleSheet()))
## ==> END ##
########################################################################
## START ==> APP EVENTS
########################################################################
## EVENT ==> MOUSE DOUBLE CLICK
########################################################################
def eventFilter(self, watched, event):
if watched == self.le and event.type() == QtCore.QEvent.MouseButtonDblClick:
pass
#print("pos: ", event.pos())
## ==> END ##
## EVENT ==> MOUSE CLICK
########################################################################
def mousePressEvent(self, event):
self.dragPos = event.globalPos()
if event.buttons() == Qt.LeftButton:
pass
#print('Mouse click: LEFT CLICK')
if event.buttons() == Qt.RightButton:
pass
#print('Mouse click: RIGHT CLICK')
if event.buttons() == Qt.MidButton:
pass
#print('Mouse click: MIDDLE BUTTON')
## ==> END ##
## EVENT ==> KEY PRESSED
########################################################################
def keyPressEvent(self, event):
pass
#print('Key: ' + str(event.key()) + ' | Text Press: ' + str(event.text()))
## ==> END ##
## EVENT ==> RESIZE EVENT
########################################################################
def resizeEvent(self, event):
self.resizeFunction()
return super(MainWindow, self).resizeEvent(event)
def resizeFunction(self):
pass
#print('Height: ' + str(self.height()) + ' | Width: ' + str(self.width()))
## ==> END ##
########################################################################
## END ==> APP EVENTS
############################## ---/--/--- ##############################
if __name__ == "__main__":
app = QApplication(sys.argv)
QtGui.QFontDatabase.addApplicationFont('fonts/segoeui.ttf')
QtGui.QFontDatabase.addApplicationFont('fonts/segoeuib.ttf')
window = MainWindow()
sys.exit(app.exec_())