PDA

View Full Version : [SHARE] Prevent passwords bruteforcing


kembl
31.08.2006, 08:55
I know that some game passwords online checkers are exists now, so there a way to make this process slowly.

This is SQL Server side modification, already checked under SQL2005 EXPRESSS

1) you need to add table user_auth_log to lin2db


USE [lin2db]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[user_auth_log](
[sid] [int] IDENTITY(1,1) NOT NULL,
[account] [varchar](14) COLLATE Cyrillic_General_CI_AS NULL,
[success] [tinyint] NOT NULL CONSTRAINT [DF_user_auth_log_success] DEFAULT ((2)),
[dt] [datetime] NOT NULL CONSTRAINT [DF_user_auth_log_dt] DEFAULT (getdate())
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF


than, set rights to your lineage2 server SQL account to INSERT and SELECT from this table.

2) You need to modify lin2db..ap_GPwd stored procedure:



set ANSI_NULLS OFF
set QUOTED_IDENTIFIER OFF
GO

ALTER PROCEDURE [dbo].[ap_GPwd] @account varchar(14), @pwd binary(16) output
AS
--exec ap_GPwd_log @account

-- Created By darkangel
-- 20xx.xx.19
-- updated 20xx.xx.14 by KEMBL
-- set Account's auth logging
-- updated 20xx.xx.31 Logrus, Drone
-- added login counts per time check

SET NOCOUNT ON

if (SELECT COUNT(*) FROM lin2db..user_auth_log WHERE account=@account AND DATEDIFF(mi, dt, GETDATE()) < 16) > 4
OR
(SELECT COUNT(*) FROM lin2db..user_auth_log WHERE account=@account AND DATEDIFF(ss, dt, GETDATE()) < 3) > 0
BEGIN
INSERT INTO user_auth_log (account,success) VALUES (@account, 0)
SET NOCOUNT OFF
SELECT @pwd = 0xC3371572F8F9BF71A8D31A1EB2436D6C
END
ELSE
BEGIN
INSERT INTO user_auth_log (account,success) VALUES (@account, 1)
SET NOCOUNT OFF
SELECT @pwd=password FROM user_auth with (nolock) WHERE account=@account
END


thats all.

So, now rules are: 5 login tryes per 15 minutes and not less than 2 seconds between tryes.

One more bad things exists with this code

Change binary 16 string in value @pwd

SELECT @pwd = 0xC3371572F8F9BF71A8D31A1EB2436D6


to some else which nobody knows, cause if some one finds password for this value, he gets access to any one account on your server after 5 mistakes. It's better to random generate there some unique every time, but in this way procedure will be more slowly.

P.S. If you have got hex fix (or other) to login two users with one char (for self clone, selling and dupe resources), please share it. Torune's patch is great, but ability for char cloning still exists.

Mirror
31.08.2006, 10:53
cypher's dll fixes cloning issues

top-gear
31.08.2006, 10:55
thanks for the share. i think there is a setting that if someone is already logged and you try to login, it doesn't kick the first person. So that way the cloning or duping has to be impossible

TofA
31.08.2006, 12:45
Well as the title of this topic says..this should prevent "stealing" out players acc via bruteforce, there is no word about cloning.

Aikeleer
31.08.2006, 21:05
Thanks a lot for sharing man.

kembl
01.09.2006, 08:38
So, today i check prevent system SQL table user_auth_log, and i think it works fine. But for now i see that bruteforce spot target to account web manager. Add similar block for it, is a nice idea.

if you dont know yet, lineage2 password hash system, is a fake, look there https://postpacific.loc-online.com/forums/showthread.php?t=4421

password la2hash
passw950 0xB5394575C865BD7247DEF8F835AF8989
passw951 0xB5394575C865BD7247DEF8F835AF8989
passw952 0xB5394575C865BD7247DEF8F835AF8989
passw953 0xB5394575C865BD7247DEF8F835AF8989
passw954 0xB5394575C865BD7247DEF8F835AF8989

so bruteforcing is not so hard on several passwords

Well as the title of this topic says..this should prevent "stealing" out players acc via bruteforce, there is no word about cloning.

I'am only ask about it, cause there is big problem not resolved yet on our server :)

>cypher's dll fixes cloning issues

Who can get a link to it? Forum search returns wrong matches :(

forsage
26.10.2006, 05:13
One more bad things exists with this code
Change binary 16 string in value @pwd

SELECT @pwd = 0xC3371572F8F9BF71A8D31A1EB2436D6


to some else which nobody knows, cause if some one finds password forthis value, he gets access to any one account on your server after 5 mistakes. It's better to random generate there some unique every time, but in this way procedure will be more slowly.


Hi
I'm not good in SQL , but this , in my mind , fixed problem with static @PWD...
Decrypt password is easy , if I use , for example only small letter , it take about 3 minutes at my computer... This is more security, if randomise generate password every time.


set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[ap_GPwd] @account varchar(14), @pwd binary(16) output
AS
--exec ap_GPwd_log @account

-- Created By darkangel
-- 20xx.xx.19
-- updated 20xx.xx.14 by KEMBL
-- set Account's auth logging
-- updated 20xx.xx.31 Logrus, Drone
-- added login counts per time check
-- update 20xx.xx.25 by Stpavel
-- added random generate password

DECLARE @RandPass varchar(32)
DECLARE @counter smallint
DECLARE @RandNum float
DECLARE @RandNumInt tinyint
DECLARE @CurrChar varchar(1)
DECLARE @ValidChar varchar(255)
SET @ValidChar = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz0123456789-=+&$'
DECLARE @ValidCharLength int
SET @ValidCharLength = len(@ValidChar)
SET @CurrChar = ''
SET @RandNum = 0
SET @RandNumInt = 0
SET @RandPass = ''


SET NOCOUNT ON

if (SELECT COUNT(*) FROM lin2db..user_auth_log WHERE account=@account AND DATEDIFF(mi, dt, GETDATE()) < 16) > 4
OR
(SELECT COUNT(*) FROM lin2db..user_auth_log WHERE account=@account AND DATEDIFF(ss, dt, GETDATE()) < 3) > 0
BEGIN
INSERT INTO user_auth_log (account,success) VALUES (@account, 0)

SET @counter = 1;
WHILE @counter < (17)
BEGIN
SET @RandNum = Rand();
SET @RandNumInt = Convert(tinyint, ((@ValidCharLength - 1) * @RandNum + 1))

SELECT @CurrChar = SUBSTRING(@ValidChar, @RandNumInt, 1);
SET @counter = @counter + 1;
SET @RandPass = @RandPass + @CurrChar;
END

SET NOCOUNT OFF

SELECT @pwd=convert(binary(16),@RandPass);

END
ELSE
BEGIN
INSERT INTO user_auth_log (account,success) VALUES (@account, 1)
SET NOCOUNT OFF
SELECT @pwd=password FROM user_auth with (nolock) WHERE account=@account
END

mcrabben7
02.11.2006, 06:03
Why not make the built-in password you use when they fail the check really long, like 25-32 binary characters? It would be impossible for an L2 password hash to ever exceed 16 binary characters, afaik.

I'm not an SQL guru, and stored procedures are not my specialty, but if someone knows if making the hash extremely long would make it impossible to get access to an account after the 5 fails, let me know. It'd be safer than using the random password of 16 characters since that can still randomly match (tho extremely rare chance).

zekillers
02.11.2006, 07:07
There's a major flaw... if you know a persons account name you can spam login and basically lock their account.

I've created a real time logging feature that'll log not only account names, but will log ips.

so it'll keep track of x failed logins in x minutes, and ban that ip for x amount of time.

Ban by adding ip to BlockIPS.txt

will use this in conjunction with https://postpacific.loc-online.com/forums/showthread.php?t=6078&highlight=BlockIPS.txt

khelben
10.04.2007, 19:07
Why not make the built-in password you use when they fail the check really long, like 25-32 binary characters? It would be impossible for an L2 password hash to ever exceed 16 binary characters, afaik.

I'm not an SQL guru, and stored procedures are not my specialty, but if someone knows if making the hash extremely long would make it impossible to get access to an account after the 5 fails, let me know. It'd be safer than using the random password of 16 characters since that can still randomly match (tho extremely rare chance).

Wouldn't it just get truncated?

There's a major flaw... if you know a persons account name you can spam login and basically lock their account.

I've created a real time logging feature that'll log not only account names, but will log ips.

so it'll keep track of x failed logins in x minutes, and ban that ip for x amount of time.

Ban by adding ip to BlockIPS.txt

will use this in conjunction with https://postpacific.loc-online.com/forums/showthread.php?t=6078&highlight=BlockIPS.txt

Care to Share?