-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpSpy.lua
More file actions
402 lines (338 loc) · 8.57 KB
/
Copy pathHttpSpy.lua
File metadata and controls
402 lines (338 loc) · 8.57 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
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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
local DEBUG = false
--// Libraries
local Hook = {}
local Http = {}
--// ReGui
local ReGui = loadstring(game:HttpGet('https://raw.githubusercontent.com/depthso/Dear-ReGui/refs/heads/main/ReGui.lua'))()
local PrefabsId = `rbxassetid://{ReGui.PrefabsId}`
ReGui:Init({
Prefabs = game:GetObjects(PrefabsId)[1]
})
local HttpService = game:GetService("HttpService")
--// Globals
local GlobalENV = getgenv()
local Typeof = typeof
--// Config
local UrlIntercepts = {
["http://127.0.0.1:6463/rpc?v=1"] = {
Callback = function()
warn("Blocked discord inivite!")
return ""
end,
},
}
local function AddHooks()
Hook:AddRefernce(game, {
Globals = {"game", "Game"},
Hooks = {
["HttpGet"] = "HTTP_HOOK",
["HttpGetAsync"] = "HTTP_HOOK",
["HttpPost"] = "HTTP_HOOK",
["HttpPostAsync"] = "HTTP_HOOK"
}
})
Hook:AddRefernce(GlobalENV, {
Hooks = {
["http_request"] = "HTTP_HOOK",
["request"] = "HTTP_HOOK",
}
})
Hook:AddRefernce(http, {
Hooks = {
["request"] = "HTTP_HOOK",
}
})
Hook:AddRefernce(syn, {
Hooks = {
["request"] = "HTTP_HOOK",
}
})
end
----// Main script
type table = {
[any]: any
}
--// Create window
local Console = nil
local Paused = false
local function Log(...)
return Console:AppendText(...)
end
local Window = ReGui:Window({
Title = "Http Spy | By: Depso",
Theme = "ImGui",
Size = UDim2.new(0, 350, 0, 370),
NoScroll = true
}):Center()
--// Buttons
local ButtonsRow = Window:Row()
ButtonsRow:Button({
Text = "Clear",
Callback = function()
Console:Clear()
end
})
ButtonsRow:Button({
Text = "Copy",
Callback = function()
local Content = Console:GetValue()
toclipboard(Content)
end
})
ButtonsRow:Button({
Text = "Pause",
Callback = function(self)
Paused = not Paused
local Text = Paused and "Paused" or "Pause"
self.Text = Text
--// Update console
Console.Enabled = not Paused
end,
})
ButtonsRow:Expand()
--// Create console
Console = Window:Console({
Text = "-- Created by depso",
ReadOnly = true,
Border = false,
Fill = true,
Enabled = true,
AutoScroll = true,
RichText = true,
MaxLines = 50
})
--// HTTP detection functions
type ScanRequest = {
Url: string,
Body: (string|nil),
IsPost: boolean?,
IsTable: boolean?,
}
function Http:ScanHTTPRequest(Args: {}): ScanRequest
local Request = {}
--// Search string/table for string content
for Index: number, Arg in next, Args do
--// Log each parameter for debugging
if DEBUG then
warn(`{Index}: {Arg}`)
end
--// :HttpGet
if Typeof(Arg) == "string" then
Request.Url = Arg
if not DEBUG then break end
--// request
elseif Typeof(Arg) == "table" then
local Url = Arg.Url or Arg.url
if not Url then continue end
--// Unpack content
local Body = Arg.Body or Arg.body
Request.Url = Url
Request.Body = Body
Request.IsPost = Body and true or false
Request.IsTable = true
Request.Headers = Arg.Headers
if not DEBUG then break end
warn(`Found! {Index}: {Arg.Url}, {Arg.url}`)
end
end
return Request
end
function Http:FindIntercept(Url: string): table?
for UrlMatch, Data in next, UrlIntercepts do
if Url:match(UrlMatch) then
warn(`Matched {UrlMatch} with {Url}`)
return Data
end
end
return
end
local function HttpCallback(OldFunc, ...)
local Args = {...}
--// Scan arguments for HTTP request infomation
local Request = Http:ScanHTTPRequest(Args)
if not Request then return end
--// Unpack arguments
local IsPost = Request.IsPost
local IsTable = Request.IsTable
local Url = Request.Url
local Body = Request.Body
local Headers = Request.Headers
if not Url then
return OldFunc(...)
end
--// Log HTTP request infomation
Log("HTTP", `[{IsPost and "POST" or "GET"}]:`, Url)
--// Post request
if Body then
Log("> [Body] ", Body)
Log("> [Headers] ", HttpService:JSONEncode(Headers))
end
local Responce = nil
--// Check for URL intercepts
local Intercept = Http:FindIntercept(Url)
--// Fetch HTTP request responce
if not Intercept or Intercept.PassResponce then
Responce = OldFunc(...)
end
--// Return responce if there is no intercept
if not Intercept then return Responce end
--// Check if spoof is a function
local Spoofed = Intercept.Callback
if Typeof(Spoofed) == "function" then
if Intercept.PassResponce then
Spoofed = Spoofed(Responce, Request)
else
Spoofed = Spoofed(Request)
end
end
--// Hook table reponse type
if IsTable then
local Base = Responce or {}
return Hook:Hook(Base, {
["Body"] = Spoofed
})
end
return Spoofed
end
--// Hook service
type Hook = {
Hooks: {[string]: any},
Globals: {[number]: string}?,
}
type Hooks = {
[Instance]: Hook
}
Hook.Hooks = {}
Hook.Cache = setmetatable({}, {__mode = "k"})
Hook.Alliases = {
["HTTP_HOOK"] = HttpCallback
}
function Hook:GetHooks(): Hooks
return self.Hooks
end
function Hook:IsObject(Object: Instance?)
local Type = Typeof(Object)
--local Accepted = {"userdata", "Instance"}
--return table.find(Accepted, Type)
return Type == "Instance"
end
function Hook:GetHooksForObject(Instance): Hook
return self.Hooks[Instance]
end
function Hook:AddRefernce(Instance, Hooks: Hook)
if not Instance then return end
self.Hooks[Instance] = Hooks
end
function Hook:GetCached(Instance)
return self.Cache[Instance]
end
function Hook:AddCached(Instance, Proxy)
self.Cache[Instance] = Proxy
end
function Hook:Hook(Object: Instance, Hooks: table)
--// Cache check
local Cached = self:GetCached(Object)
if Cached then return Cached end
local Proxy = newproxy(true)
local Meta = getmetatable(Proxy)
Meta.__index = function(self, Key: string)
local Hook = Hooks[Key]
-- __index hook
if Hook then
if DEBUG then
Log("> Spoofed", Key)
end
return Hook
end
local Value = Object[Key]
-- __namecall patch
if type(Value) == "function" then
return function(self, ...)
return Value(Object, ...)
end
end
return Value
end
Meta.__newindex = function(self, Key: string, New)
Object[Key] = New
end
Meta.__tostring = function()
return tostring(Object)
end
Meta.__metatable = getmetatable(Object)
--// Cache proxy
self:AddCached(Object, Proxy)
return Proxy
end
function Hook:ApplyHooks()
local AllHooks = self:GetHooks()
local Alliases = self.Alliases
for Object, Data in next, AllHooks do
local IsObject = self:IsObject(Object)
local Hooks = Data.Hooks
local Globals = Data.Globals
--// Check table for read-only
local IsReadOnly = false
if typeof(Object) == "table" then
IsReadOnly = table.isfrozen(Object)
end
--// Set writable
if IsReadOnly then
setreadonly(Object, false)
end
--// Add hooks to object or enviroment
for Key: string, Value in next, Hooks do
local Success, OldValue = xpcall(function()
return Object[Key]
end, warn)
if not Success then continue end
if Typeof(OldValue) == "function" then
--// Patch namecall methods
if IsObject then
local OldFunc = OldValue
OldValue = function(self, ...)
return OldFunc(Object, ...)
end
end
--// Closure type patch
if iscclosure(OldValue) then
OldValue = newcclosure(OldValue)
end
end
--// Find Allias
if typeof(Value) == "string" then
local Callback = Alliases[Value]
--// Patch allias function
if Callback then
Value = function(...)
return Callback(OldValue, ...)
end
end
end
--// Apply new value
Hooks[Key] = Value
--// For others such as tables
if not IsObject then
Object[Key] = Value
end
end
-- Hook functions of a instance
if IsObject then
local Proxy = self:Hook(Object, Hooks)
if not Globals then continue end
--// Add global references to environment
for _, Global: string in next, Globals do
GlobalENV[Global] = Proxy
end
continue
end
--// Set read only
if IsReadOnly then
setreadonly(Object, true)
end
end
end
--// Init
AddHooks()
Hook:ApplyHooks()
Log("Loaded successfully!")