-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzappies.py
169 lines (135 loc) · 4.13 KB
/
zappies.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
import configparser
import pickle
from threading import Timer, active_count
from time import sleep
import random
import numpy as np
import tensorflow as tf
from keras_preprocessing.sequence import pad_sequences
from pynput import keyboard
from piShockWrapper import piShock
global keys_pressed
global sleep_time
sleep_time = 5
keys_pressed = []
global num_keys_pressed
num_keys_pressed = 0
global keys_to_keep
keys_to_keep = 10
model_sav_loc = "./model/"
config = configparser.ConfigParser()
config.read("config.ini")
# Auth
username = config["auth"]["username"]
apikey = config["auth"]["apikey"]
sharecode = config["auth"]["sharecode"]
name = config["auth"]["name"]
# Settings
mode = config["settings"]["mode"]
duration = int(config["settings"]["duration"])
intensity = int(config["settings"]["intensity"])
# Warning Settings
warning = int(config["warning"]["warning"])
global randomenable
randomenable = True
#randomenable = config["warning"]["random"]
global minwait
minwait = 1
#minwait = int(config["warning"]["minwait"])
global maxwait
maxwait = 15
#maxwait = int(config["warning"]["maxwait"])
# Load the model and the tokenizer
model = tf.keras.models.load_model("model/model.h5")
with open(model_sav_loc + "tokenizer.pickle", "rb") as handle:
tk = pickle.load(handle)
# Functions that do the shock stuff
# Define some functions to help with processing
def bigger(input1: int, input2: int):
if input1 > input2:
return 1
else:
return 2
def unfuck_predict(input: np.ndarray) -> list:
"""unfuck_predict unfucks the prediction output
:param input: the fucked prediction
:type input: np.ndarray
:return: the unfucked prediction
:rtype: list
"""
unfucked = input.tolist()
unfucked = str(unfucked)
unfucked = unfucked.replace("[", "").replace("]", "").replace(" ", "")
unfucked = unfucked.split(",")
return unfucked
def predict_smash(input: str):
"""predict_smash _summary_
Args:
input (str): _description_
Returns:
list: returns a list in the follow format
"""
seq = tk.texts_to_sequences([input])
padded = pad_sequences(seq, maxlen=15)
prediction = model.predict(padded)
unfucked = unfuck_predict(prediction)
bottom = unfucked[0]
notbottom = unfucked[1]
bigger_value = bigger(unfucked[0], unfucked[1])
return unfucked, bottom, notbottom, bigger_value
def to_string(input: list) -> str:
stringed = "".join(input)
return stringed
# Keylogger Stuff
def on_press(key):
try:
keys_pressed.append(key.char)
except AttributeError:
pass
def on_release(key):
global num_keys_pressed
global keys_pressed
global keys_to_keep
if num_keys_pressed >= keys_to_keep:
predict_output = predict_smash(to_string(keys_pressed))
if predict_output[3] == 2:
action()
num_keys_pressed = 0
print("Done")
print(keys_pressed)
keys_pressed = []
return False
else:
num_keys_pressed += 1
pass
def create_listener():
with keyboard.Listener(on_press=on_press, on_release=on_release) as listener:
listener.join()
def warning_handler() -> int:
if randomenable == True:
warning = random.randint(minwait, maxwait)
return warning
elif warning != 0:
return warning
# Actions
def zap(username=username, apikey=apikey, sharecode=sharecode, name=name, duration=duration, intensity=intensity):
piShock(username, apikey, sharecode, name, duration, intensity, warning_handler()).shock()
print("ZAP")
def vibe(username=username, apikey=apikey, sharecode=sharecode, name=name, duration=duration, intensity=intensity):
piShock(username, apikey, sharecode, name, duration, intensity).vibe()
print("BUZZ")
def tone(username: str, apikey: str, sharecode: str, name: str, duration: int):
piShock(username, apikey, sharecode, name, duration).beep()
print("BEEP")
def action():
if mode == "shock":
zap()
elif mode == "buzz":
vibe()
elif mode == "tone":
tone()
else:
print("WHAT THE HELLS GOING ON?")
while True:
create_listener()
sleep(sleep_time)