Randomly Generating Rcon password.

[lua]
function GenerateRconPass()
local KEYS = {
“a”,
“b”,
“c”,
“d”,
“e”,
“f”,
“g”,
“h”,
“i”,
“j”,
“k”,
“l”,
“m”,
“n”,
“o”,
“p”,
“q”,
“r”,
“s”,
“t”,
“u”,
“v”,
“w”,
“x”,
“y”,
“z”,
“{”,
“[”,
“]”,
“}”,
“|”,
“:”,
“;”,
“’”,
“<”,
“>”,
“,”,
“.”,
“/”,
“?”,
“!”,
“@”,
“#”,
“$”,
“%”,
“^”,
“&”,
“*”,
“(”,
“)”,
“-”,
“_”,
“+”,
“=”,
“1”,
“2”,
“3”,
“4”,
“5”,
“6”,
“7”,
“8”,
“9”,
“0”
}

local str = "";

for i = 1, 1024 do
	
	str = str .. KEYS[math.random( 1, KEYS )];
	
end

game.ConsoleCommand( "rcon_password " .. str );

end
concommand.Add( “GenerateNewRcon”, GenerateRconPass )
[/lua]

Would this work? Is this efficient?

[lua]local function GenerateString( len )
local str = “”

for i=1, len do
	str = str .. string.char( math.random( 33, 125 ) )
end

-- Filtering any bad characters
return str:gsub( "[;]", "" )

end

concommand.Add( “rcon_generate”, function()
local str = GenerateString( 128 )
game.ConsoleCommand( "rcon_password " … str … "
" )
end )[/lua]

Why would you ever need a password 1024 chars long?

Paranoid people eh.

If i remember correctly you can’t execute rcon_password from lua

Well he could use a module to bypass that or make an alias of rcon_password in his server.cfg

I don’t see the point in changing rcon password tbh, when you can just not allow them not to use rcon.


alias what rcon_password

[lua]function GenPass()

local password = ""

for i = 1 , 100 do
	password = password..string.char(math.random(65 , 117))
end

MsgN(password)
return password

end

RunConsoleCommand(“what” , GenPass())[/lua]

this may can be used for rcon bruteforce, right ?

don’t you get auto-banned after 5 tries or so ?

also password will break if they contain this “;”

only if the server.cfg contain something like


sv_rcon_banpenalty 1440
sv_rcon_maxfailures 5