-
Notifications
You must be signed in to change notification settings - Fork 1
/
keypadlogger.lua
353 lines (198 loc) · 7.43 KB
/
keypadlogger.lua
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
local grad = Material( "gui/gradient" )
function Vision()
local me = LocalPlayer()
if !me:IsValid() then return end
local e = me:GetEyeTrace().Entity
-- if IsValid(e) and string.find( e:GetClass(), "Keypad") then
-- local text;
-- local color;
-- if(e.code && e.code != "") then
-- text = e.code;
-- color = Color( 105, 255, 105, 150 )
-- elseif(e.tempCode && e.tempCode != "") then
-- text = e.tempCode;
-- color = Color( 250, 150, 150, 150 )
-- else
-- text = "Unknown"
-- color = Color(255,255,255)
-- end
-- -- draw.WordBox( 8, ScrW() / 2, ScrH() / 2, text, "Default", color, Color(255,255,255,255) )
-- surface.SetDrawColor( Color( 0,0,50, 150 ) )
-- surface.SetMaterial( grad )
-- surface.DrawTexturedRect( ScrW() / 2 + 57, ScrH() / 2 - 7, 50, 15 )
-- draw.SimpleText(text, "DermaDefault", ScrW() / 2 + 60, ScrH() / 2, color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
-- end
for k,v in pairs(ents.GetAll()) do
if IsValid(v) and string.find( v:GetClass(), "Keypad") then
if v != e and me:GetPos():Distance( v:GetPos() ) < 8000 then
local pos = v:GetPos():ToScreen()
if pos.x > 0 and pos.x < ScrW() and pos.y > 0 and pos.y < ScrH() then
if (v.code && v.code != "") then
-- surface.SetDrawColor( Color( 0,0,50, 150 ) )
-- surface.SetMaterial( grad )
-- surface.DrawTexturedRect( pos.x, pos.y, 50, 15 )
draw.SimpleText( v.code, "TargetID", pos.x + 5, pos.y + 6, Color( 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
-- draw.WordBox( 8, pos.x-5, pos.y-5, v.code, "Default", Color( 0, 255, 0, 150 ), Color(255,255,255,255) )
else
if(v.tempCode && v.tempCode != "") then
-- surface.SetDrawColor( Color( 0,0,50, 150 ) )
-- surface.SetMaterial( grad )
-- surface.DrawTexturedRect( pos.x, pos.y, 50, 15 )
draw.SimpleText( v.tempCode, "TargetID", pos.x + 5, pos.y + 6, Color( 255, 255, 255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
-- else
-- surface.SetDrawColor( Color( 0,0,50, 150 ) )
-- surface.SetMaterial( grad )
-- surface.DrawTexturedRect( pos.x, pos.y, 50, 15 )
-- draw.SimpleText( "Unknown", "DermaDefault", pos.x + 5, pos.y + 6, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
end
end
end
end
end
end
end
hook.Add("HUDPaint", "HUD", Vision)
local elements = {
{ -- Screen
x = 0.075,
y = 0.04,
w = 0.85,
h = 0.25,
},
{ -- ABORT
x = 0.075,
y = 0.04 + 0.25 + 0.03,
w = 0.85 / 2 - 0.04 / 2 + 0.05,
h = 0.125,
text = "ABORT",
},
{ -- OK
x = 0.5 + 0.04 / 2 + 0.05,
y = 0.04 + 0.25 + 0.03,
w = 0.85 / 2 - 0.04 / 2 - 0.05,
h = 0.125,
text = "OK",
}
}
do
for i = 1, 9 do
local column = (i - 1) % 3
local row = math.floor((i - 1) / 3)
local element = {
x = 0.075 + (0.3 * column),
y = 0.175 + 0.25 + 0.05 + ((0.5 / 3) * row),
w = 0.25,
h = 0.13,
text = tostring(i),
}
table.insert(elements, element)
end
end
function CalculateKeypadCursorPos(ply, ent)
if !ply:IsValid() then return end
local tr = util.TraceLine( { start = ply:EyePos(), endpos = ply:EyePos() + ply:GetAimVector() * 65, filter = ply } )
if !tr.Entity or tr.Entity ~= ent then return 0, 0 end
local scale = ent.Scale
if !scale then return 0, 0 end
local pos, ang = ent:CalculateRenderPos(), ent:CalculateRenderAng()
if !pos or !ang then return 0, 0 end
local normal = ent:GetForward()
local intersection = util.IntersectRayWithPlane(ply:EyePos(), ply:GetAimVector(), pos, normal)
if !intersection then return 0, 0 end
local diff = pos - intersection
local x = diff:Dot( -ang:Forward() ) / scale
local y = diff:Dot( -ang:Right() ) / scale
return x, y
end
function KPGetHoveredElement(ply, ent)
local scale = ent.Scale
local w, h = ent.Width2D, ent.Height2D
local x, y = CalculateKeypadCursorPos(ply, ent)
for _, element in ipairs(elements) do
local element_x = w * element.x
local element_y = h * element.y
local element_w = w * element.w
local element_h = h * element.h
if element_x < x and element_x + element_w > x and
element_y < y and element_y + element_h > y
then
return element
end
end
end
function Logic()
local me = LocalPlayer()
if !me:IsValid() then return end
for k, v in pairs(player.GetAll()) do
local kp = v:GetEyeTrace().Entity
if IsValid(kp) && IsValid(v) and string.find( kp:GetClass(), "Keypad") and v:EyePos():Distance(kp:GetPos()) <= 120 then
kp.tempCode = kp.tempCode or ""
kp.tempText = kp.tempText or ""
kp.tempStatus = kp.tempStatus or 0
if kp:GetText() != kp.tempText or kp:GetStatus() != kp.tempStatus then
kp.tempText = kp:GetText()
kp.tempStatus = kp:GetStatus()
if(kp.tempText && !kp:GetSecure()) then
kp.tempCode = kp.tempText
timer.Simple(0, function()
if kp:GetStatus() == 1 && kp.tempCode && kp.tempCode != "" then
kp.code = kp.tempCode
end
end)
else
local i = KPGetHoveredElement(v, kp)
if (i) then i = i.text end
if kp.tempText then
timer.Simple(0, function()
if kp:GetStatus() == 1 && kp.tempCode && kp.tempCode != "" then
kp.code = kp.tempCode
end
end)
end
if kp.tempText == "" || kp:GetStatus() == 2 then
kp.tempCode = ""
end
timer.Simple(0, function()
if(tonumber(i) && kp:GetText():len() != 0) then
kp.tempCode = kp.tempCode..i
end
end)
end
end
end
end
end
hook.Add("Think", "logic", Logic)
local function GetGays()
return ents.FindByClass("Keypad")
end
hook.Add( "Think", "Gaypads" , function()
local gays = GetGays()
for k,v in pairs(gays) do
if IsValid(v) then
if !isbool(v.hacked) then
v.hacked = false
end
if !v.hacked then
if(v:GetStatus() == 1)then
if(v:GetText() != "****")then
v.hacked = true
v.passi = v:GetText()
end
end
end
end
end
end)
hook.Add( "HUDPaint", "Gaypads", function()
for k,v in pairs(GetGays())do
if(v.hacked)then
local pos = ( v:GetPos() ):ToScreen()
draw.SimpleText(v.passi,"TargetID",pos.x + 25,pos.y + 20,Color(255,0,0),1,1)
end
end
end)
concommand.Add("stop_hack_gaypads",function()
hook.Remove( "Think", "Gaypads" )
hook.Remove( "HUDPaint", "Gaypads" )
end)