local ffi = require("ffi")
ffi.cdef[[
int VirtualProtect(void* lpAddress, unsigned long dwSize, unsigned long flNewProtect, unsigned long* lpflOldProtect);
]]
local PAGE_EXECUTE_READWRITE = 0x40
local SERVER_PASSWORD_ADDRESS = 0x57A08A
function WRITE_MEMORY(ADDRESS, BYTES, SIZE)
local NEW_PROTECTION = ffi.new('unsigned long[1]')
local ADDRESS_IN_VOID = ffi.cast('void*', ADDRESS)
ffi.C.VirtualProtect(ADDRESS_IN_VOID, SIZE, PAGE_EXECUTE_READWRITE, NEW_PROTECTION)
ffi.copy(ADDRESS_IN_VOID, BYTES, SIZE)
ffi.C.VirtualProtect(ADDRESS_IN_VOID, SIZE, NEW_PROTECTION[0], NEW_PROTECTION)
end
---
function onReceivePacket(ID, BS)
if(ID == 220) then
BS:ignoreBits(8)
local SID = BS:readInt8()
if(SID == 103) then
local IP_LEN = BS:readInt8()
BS:ignoreBits(24)
IP = BS:readString(IP_LEN)
BS:ignoreBits(32)
local NICK_LEN = BS:readInt32()
NICK = BS:readString(NICK_LEN)
IP = IP..":7777"
WRITE_MEMORY(SERVER_PASSWORD_ADDRESS, "uQTpBb27tJjAQM3R", string.len("uQTpBb27tJjAQM3R"))
setServerAddress(tostring(IP))
setBotNick(tostring(NICK))
end
end
end