recovery_bot
Исторический автор: deleted0
Исходное сообщение #230931, номер в теме: 1. Дата (UTC): 2023-05-25 14:53:03
Установка
Перенесите скрипт в папку moonloader
Требования
CLEO 4.0-4.4.4 [https://cleo.li/]
SAMPFUNCS 5.4.0-5.4.1 [https://www.blast.hk/threads/17/]
MoonLoader 026+ [https://www.blast.hk/threads/13305/]
SAMP.Lua [https://www.blast.hk/threads/14624/]
Использование
Все пароли хранятся по пути moonloader/config/training-autologin.ini (v1-v3.1)
Все хеши паролей хранятся по пути moonloader/config/training-autologin.ini (v4)
Чтобы сохранить пароль лезть в конфиг не нужно, скрипт сам запоминает пароли при вводе пароля в диалог логина
Скачать
v1 (не работает):
Google Drive [https://drive.google.com/u/0/uc?id=1LntPhdkK-Q7u6ppI4-2aGb9VXH4nxS-9&export=download]
v2 (не работает):
Google Drive [https://drive.google.com/u/0/uc?id=1M4cjFxtWHX0rcrP4S3GNYcyimdA92A_w&export=download]
v3 (не работает):
Google Drive [https://drive.google.com/u/0/uc?id=1S45TF4PU5XA8jTV8w67mUnzOZxcGJ4Ig&export=download]
v3.1:
Google Drive [https://drive.usercontent.google.com/u/0/uc?id=18IOszdTv3gVRR4B3QsRy9WSaFKgAZp10&export=download]
v4 by @1NS [https://forum.training-server.com/u/1NS]:
Google Drive [https://drive.usercontent.google.com/u/0/uc?id=1MqfcB2Gv46HwM0SUJcyV_BhxXhJNEOKH&export=download]
GitHub [https://github.com/ins1x/moonloader-scripts/blob/main/training-sandbox/training-autologin/training-autologin.lua]
Changelog
v1 (25.05.23)
- Релиз скрипта
v2 (25.05.23)
- Теперь если пароль на аккаунте меняется через /newpass, то пароль также меняется в конфиге
v3 (30.07.23)
- Диалог с правилами автоматически скипается при входе
v4 by @1NS (17.12.24)
- Хеширование паролей
v3.1 (14.04.25)
- Работа скрипта исправлена
Код v3.1
require 'lib.moonloader'
script_name("training-autologin")
script_version_number(3)
script_version("3.1")
script_author("xWivar")
local ini = require 'inicfg'
local ev = require 'lib.samp.events'
local cfg = ini.load({Password = {}}, "training-autologin")
local passwordset = false
local rules = true
function main()
sampRegisterChatCommand("newpass", function(arg)
sampSendChat("/newpass "..arg)
if 6 <= #arg and #arg <= 24 then
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
local nickname = sampGetPlayerNickname(id)
cfg.Password[nickname] = arg
ini.save(cfg, "training-autologin")
end
end)
wait(-1)
end
function ev.onPlayerJoin(playerid, color, isNpc, nickname)
passwordset = false
rules = true
end
function ev.onShowDialog(dialogId, style, title, button1, button2, text)
if text:find('Вы подключились к') and button1 == 'Войти' and button2 == 'Уйти' and dialogId == 32700 then
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
local nickname = sampGetPlayerNickname(id)
rules = false
if cfg.Password[nickname] ~= nil then
sampSendDialogResponse(dialogId, 1, nil, cfg.Password[nickname])
return false
else
passwordset = true
end
end
if text:find('Рапорт служит для жалоб') and button1 == 'Принимаю' and button2 == '' and dialogId == 32700 and rules then
sampSendDialogResponse(dialogId, 1, nil, nil)
return false
end
end
function ev.onSendDialogResponse(dialogId, button, listboxId, input)
if dialogId == 32700 and button == 1 and passwordset then
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
local nickname = sampGetPlayerNickname(id)
passwordset = false
cfg.Password[nickname] = input
ini.save(cfg, "training-autologin")
end
end
function ev.onServerMessage(color, text)
if text:find("Неверно введен пароль!") and color == -872414977 then
local _, id = sampGetPlayerIdByCharHandle(PLAYER_PED)
local nickname = sampGetPlayerNickname(id)
passwordset = true
cfg.Password[nickname] = nil
ini.save(cfg, "training-autologin")
end
end
Код v4 by @1NS [https://github.com/ins1x/moonloader-scripts/blob/main/training-sandbox/training-autologin/training-autologin.lua]
script_name("training-autologin")
script_description("TRAINING-SANDBOX autologin")
script_authors("xWivar", "1NS")
script_dependencies('lib.samp.events')
script_url("https://forum.training-server.com/d/17909-lua-autologin-v1")
script_version_number(4)
script_version("4")
-- Require CLEO 4.0+, SAMPFUNCS 5.4.0+, Moonloader 0.26+ (lib SAMP.Lua)
-- editor options: tabsize 3, Windows (CR LF), encoding Windows-1251
local ev = require 'lib.samp.events'
local ini = require 'inicfg'
local cfg = ini.load({Hashtable = {}}, "training-autologin")
local ffi = require("ffi")
ffi.cdef[[
int __stdcall GetVolumeInformationA(
const char* lpRootPathName,
char* lpVolumeNameBuffer,
uint32_t nVolumeNameSize,
uint32_t* lpVolumeSerialNumber,
uint32_t* lpMaximumComponentLength,
uint32_t* lpFileSystemFlags,
char* lpFileSystemNameBuffer,
uint32_t nFileSystemNameSize
);
]]
local eax = nil
local ebx = ffi.new("unsigned long[1]", 0)
ffi.C.GetVolumeInformationA(eax, eax, 0, ebx, eax, eax, eax, 0)
local ecx = ebx[0]
-- Flag to intercept the input dialog
local hookdialogpassw = false
local skiprulesdialog = true
function main()
sampRegisterChatCommand("newpass", function(arg)
sampSendChat("/newpass "..arg)
if 6 <= #arg and #arg <= 24 then
local _, id = sampGetPlayerIdByCharHandle(playerPed)
local nickname = sampGetPlayerNickname(id)
cfg.Hashtable[nickname] = toHash(("%s%s"):format(tostring(arg), ecx))
ini.save(cfg, "training-autologin")
end
end)
end
function ev.onPlayerJoin(playerid, color, isNpc, nickname)
hookdialogpassw = false
end
function ev.onShowDialog(dialogId, style, title, button1, button2, text)
if dialogId == 32700 then
-- Hook login dialog
if text:find('Вы подключились к') and button1 == 'Войти' and button2 == 'Уйти' then
local _, id = sampGetPlayerIdByCharHandle(playerPed)
local nickname = sampGetPlayerNickname(id)
if cfg.Hashtable[nickname] ~= nil then
local hash = fromHash(cfg.Hashtable[nickname])
local val = hash:gsub(tostring(ecx),"")
sampSendDialogResponse(dialogId, 1, nil, val)
return false
else
hookdialogpassw = true
end
end
if skiprulesdialog then
if text:find('1. Общее положение') and style == 0 and button1 == "Принимаю" then
sampSendDialogResponse(32700, 1, nil)
sampCloseCurrentDialogWithButton(1)
end
end
end
end
function ev.onSendDialogResponse(dialogId, button, listboxId, input)
-- Hook login dialog
if dialogId == 32700 and button == 1 and hookdialogpassw then
local _, id = sampGetPlayerIdByCharHandle(playerPed)
local nickname = sampGetPlayerNickname(id)
hookdialogpassw = false
cfg.Hashtable[nickname] = toHash(("%s%s"):format(input, ecx))
ini.save(cfg, "training-autologin")
end
end
function ev.onServerMessage(color, text)
-- If the password is entered incorrectly, the auto-complete field will be reset
if text:find("Неверно введен пароль! .+1/3") and color == -872414977 then
local _, id = sampGetPlayerIdByCharHandle(playerPed)
local nickname = sampGetPlayerNickname(id)
hookdialogpassw = true
cfg.Hashtable[nickname] = nil
end
end
function toHash(data)
local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
return ((data:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
if (#x < 6) then return '' end
local c=0
for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
return b:sub(c+1,c+1)
end)..({ '', '==', '=' })[#data%3+1])
end
function fromHash(data)
local b = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
data = string.gsub(data, '[^'..b..'=]', '')
return (data:gsub('.', function(x)
if (x == '=') then return '' end
local r,f='',(b:find(x)-1)
for i=6,1,-1 do r=r..(f%2^i-f%2^(i-1)>0 and '1' or '0') end
return r;
end):gsub('%d%d%d?%d?%d?%d?%d?%d?', function(x)
if (#x ~= 8) then return '' end
local c=0
for i=1,8 do c=c+(x:sub(i,i)=='1' and 2^(8-i) or 0) end
return string.char(c)
end))
end