Помощь с автологином

qioxun

Участник
Автор темы
41
9
Версия MoonLoader
Другое
Недавно заметил, что фикс автологина раксампа для Родины (с марта 25 года) работать перестал. Пытался как-то пофиксить с мониторингом цефа и пакетов, но не вышло. Может есть умельцы, которые помогут?


Lua:
local authorization = {
    nick = "Test_Acc",
    password = "testpassword",
}

function sampev.onSendClientJoin(version, mod, nickname, challengeResponse, joinAuthKey, clientVer, challengeResponse2)
    print("[DEBUG] Client joining")
    newTask(function()
        wait(1000)
        Validation()
        
        wait(1000)
        emulcef("svelteReady")
        print("[DEBUG] Sent svelteReady")

        wait(500)
        emulcef17("window.executeEvent('event.setActiveView', '[ null ]')")
        print("[DEBUG] Sent setActiveView null")
        
        wait(500)
        emulcef17("window.executeEvent('cef.hud.updateVisibleComponents', JSON.stringify([['walletMoney','needsInformation','serverInformation','wanted','weaponInformation','voiceChatSpeakers','questsInformation','radio','levelInformation','speedometer','banner','playerVipDuration','customizedCounter',]]))")
        print("[DEBUG] Sent updateVisibleComponents")
        
        wait(500)
        emulcef17("window.executeEvent('event.setActiveView', '[\"Auth\"]')")
        print("[DEBUG] Sent setActiveView Auth")
        
        wait(500)
        emulcef17("console.log('cursor: 1, app: 24')")
        print("[DEBUG] Sent console.log")
        
        wait(500)
        emulcef17("window.executeEvent('cef.hud.updateVisibleComponents', JSON.stringify([[]]))")
        print("[DEBUG] Sent updateVisibleComponents empty")
        
        wait(500)
        emulcef17("window.executeEvent('event.auth.updateVideoBackgroundVisible', '[true]')")
        print("[DEBUG] Sent updateVideoBackgroundVisible")
        
        wait(500)
        emulcef("onActiveViewChanged|")
        print("[DEBUG] Sent onActiveViewChanged empty")
        
        wait(500)
        emulcef("onActiveViewChanged|Auth")
        print("[DEBUG] Sent onActiveViewChanged Auth")
        
        wait(1000)
        if authorization.nick ~= "" and authorization.password ~= "" then
            print("[DEBUG] Starting auth process for:", authorization.nick)
            sendAuthorization(authorization.nick, authorization.password)
        end
    end)
end

function sampev.onSendPacket(id, bs)
    local initialOffset = bs:getReadOffset()
    local text, array = bitStreamStructure(bs)
    print(string.format("[DEBUG] Outgoing packet id: %s | Content: %s | Bytes: %s", tostring(id), text, table.concat(array, ", ")))
    bs:setReadOffset(initialOffset)
end

function bitStreamStructure(bs)
    local text, array = '', {}
    local initialOffset = bs:getReadOffset()
    
    for i = 1, bs:getNumberOfBytesUsed() do
        local byte = bs:readInt8()
        if byte >= 32 and byte <= 255 and byte ~= 37 then
            text = text .. string.char(byte)
        end
        table.insert(array, byte)
    end
    
    bs:setReadOffset(initialOffset)
    return text, array
end

function onReceivePacket(id, bs)
    local initialOffset = bs:getReadOffset()
    local text, bytes = bitStreamStructure(bs)
    print(string.format("[DEBUG] Incoming packet id: %s | Content: %s | Bytes: %s", tostring(id), text, table.concat(bytes, ", ")))
    bs:setReadOffset(initialOffset)
    if id == 220 then
        bs:ignoreBits(8)
        local subType = bs:readInt8()
        print("[DEBUG] Packet subtype:", subType)
        
        if subType == 18 then
            bs:ignoreBits(16)
            local response = bs:readString()
            print("[DEBUG] Server response:", response)
            
            if response:find("authorization") then
                print("[DEBUG] Authorization response received")
                if response:find("success") then
                    print("[DEBUG] Authorization successful!")
                    newTask(function()
                        wait(1000)
                        emulcef17("window.executeEvent('event.auth.updateVideoBackgroundVisible', '[false]')")
                        print("[DEBUG] Sent updateVideoBackgroundVisible false")
                        
                        wait(500)
                        emulcef17("window.executeEvent('event.setActiveView', '[ null ]')")
                        print("[DEBUG] Sent setActiveView null after auth")
                        
                        wait(500)
                        emulcef17("window.executeEvent('cef.hud.updateVisibleComponents', JSON.stringify([['walletMoney','needsInformation','serverInformation','wanted','weaponInformation','voiceChatSpeakers','questsInformation','radio','levelInformation','speedometer','banner','playerVipDuration','customizedCounter',]]))")
                        print("[DEBUG] Sent updateVisibleComponents after auth")
                    end)
                elseif response:find("error") then
                    print("[DEBUG] Authorization failed!")
                elseif response:find("invalid") then
                    print("[DEBUG] Invalid credentials!")
                end
            end
        end
    end
end

function emulcef(str)
    local bs = bitStream.new()
    bs:writeInt8(220)
    bs:writeInt8(18)
    bs:writeInt8(#str)
    bs:writeString(str)
    bs:sendPacketEx(2, 9, 6)
    bs:reset()
    print("[DEBUG] Emulcef sent:", str)
end

function emulcef17(str)
    local bs = bitStream.new()
    bs:writeInt8(220)
    bs:writeInt8(17)
    bs:writeInt8(#str)
    bs:writeString(str)
    bs:sendPacketEx(2, 9, 6)
    bs:reset()
    print("[DEBUG] Emulcef17 sent:", str)
end

function Validation()
    local bs = bitStream.new()
    bs:writeInt8(220)
    bs:writeInt8(20)
    bs:writeInt8(128)
    bs:writeInt8(7)
    bs:writeInt8(0)
    bs:writeInt8(0)
    bs:writeInt8(56)
    bs:writeInt8(4)
    bs:writeInt8(0)
    bs:writeInt8(0)
    bs:sendPacketEx(2, 9, 6)
    bs:reset()

    local bs = bitStream.new()
    bs:writeInt8(220)
    bs:writeInt8(38)
    bs:writeInt8(101)
    bs:writeInt8(7)
    bs:writeInt8(0)
    bs:writeInt8(0)
    bs:writeInt8(56)
    bs:writeInt8(4)
    bs:writeInt8(0)
    bs:writeInt8(0)
    bs:sendPacketEx(2, 9, 6)
    bs:reset()

    local bs = bitStream.new()
    bs:writeInt8(220)
    bs:writeInt8(50)
    bs:writeInt8(1)
    bs:writeInt16(1)
    bs:sendPacketEx(2, 9, 6)
    bs:reset()

    local bs = bitStream.new() -- TEST
    bs:writeInt8(220)
    bs:writeInt8(10)
    bs:writeInt8(0)
    bs:writeInt16(1)
    bs:sendPacketEx(2, 9, 6)
    bs:reset()

    local bs = bitStream.new() -- TEST
    bs:writeInt8(220)
    bs:writeInt8(10)
    bs:writeInt8(1)
    bs:writeInt16(1)
    bs:sendPacketEx(2, 9, 6)
    bs:reset()
    print("[DEBUG] Validation done")
end

function sendDialogResponse(id, button, list, input)
    local string = string.format("@0, sendResponse, %s, %s, %s, %s", id, list, button, input)
    local bs = bitStream.new()
    bs:writeInt8(220)
    bs:writeInt8(18)
    bs:writeInt8(#string)
    bs:writeString(string)
    bs:sendPacketEx(2, 9, 6)
    bs:reset()
end

function sendAuthorization(nick, pass)
    print("[DEBUG] Starting sendAuthorization")
    local authString = string.format("authorization|%s|%s|1", nick, pass)
    print("[DEBUG] Auth string:", authString)

    local bs = bitStream.new()
    bs:writeInt8(220)
    bs:writeInt8(18)
    bs:writeInt8(#authString)
    bs:writeString(authString)
    bs:sendPacketEx(2, 9, 6)
    bs:reset()
    print("[DEBUG] Authorization packet sent (subType 18)")
    
    wait(1000)
    local bs2 = bitStream.new()
    bs2:writeInt8(220)
    bs2:writeInt8(17)
    bs2:writeInt8(#authString)
    bs2:writeString(authString)
    bs2:sendPacketEx(2, 9, 6)
    bs2:reset()
    print("[DEBUG] Authorization packet sent (subType 17)")
end