• Welcome to Valhalla Legends Archive.
 

[C++] Strange problem...

Started by z-stars, November 07, 2004, 12:35 PM

Previous topic - Next topic

z-stars

I'm making a C++ bot using BNLS... I want it to, among other things, be able to try passwords. I have noticed that in the real BNET you can try as many accounts as you wish, as long as you only try each account once. My bot at the moment is able to send the packets till SID_LOGONRESPONSE2 (not included), and then try a password with an account, using BNLS to get the hash data. The problem comes when I repeat the Try Account process several times. After like 15 times, sometimes more sometimes less, BNET stops receiving SID_LOGONRESPONSE2. The recv() doesn't return error like when you are ip banned, but it just blocks. Trying to debug the problem, I have discovered some things:

-If you close the program, and run it again, it doesn't receive any SID_LOGONRESPONSE2. (Again blocking).
-Using the real D2 LOD client, it DOES receive it.
-Restarting the computer, my program DOES receive it again (till it tries around 15 accounts, then it starts blocking again).

That makes me think that the problem may be in my code.
Because it blocked and I had to close my program using the close button in the title bar, I thought that it may be that I wasn't closing the sockets, so I started using select() to check if recv() was gonna block, and if it was going to, I closed them and called WSACleanUp(). That didn't work, when select() detected that recv was gonna block, and closed the sockets, when I restarted the program it didn't receive SID_LOGONRESPONSE2 either.

Any idea what could be wrong?
Thx in advance everyone...

PS: I'll post the main function of my bot, if anyone wants me to post any other piece of code just tell me.

Main function

int main()
{
system("pause");
InitAll();
ReadConfig();
//Acc.Open(cfgAccDataFile);
Test1();
OpenBNLSConnection();
OpenBNETConnection();
BNETDoProtoByteToAuthCheck();
int n;
int i = 0;
while(i < 30)
{
Sleep(1000);
n = TryAccount(GenRndAccName(), "passss");
if(n == -2)
{
EndAll();
goto lblPROG_END;
CloseBNLSConnection();
CloseBNETConnection();
WSACleanup();
system("pause");
extern WSADATA wsainfo;
if(WSAStartup(MAKEWORD(1, 1), &wsainfo) != 0)
error(11, "WSAStartup() Failed");
log("WSAStartup() called...");
OpenBNLSConnection();
OpenBNETConnection();
BNETDoProtoByteToAuthCheck();
}
cout << "THIS IS N: " << n << endl;
i++;
}
//n = TryAccount(cfgAccount, cfgPassword);
//cout << "THIS IS N: " << n << endl;
// BNETDoAccountLog(cfgAccount, cfgPassword);
EndAll();
/* REMOVED SOME ATM NOT USED FUNCTIONS HERE */
EndAll();
lblPROG_END:
return 0;
}


UserLoser.

Quote from: z-stars on November 07, 2004, 12:35 PM
The problem comes when I repeat the Try Account process several times. After like 15 times, sometimes more sometimes less, BNET stops receiving SID_LOGONRESPONSE2.

That sounds about right, except for Battle.net just stops caring

z-stars

Quote from: UserLoser on November 07, 2004, 12:49 PM
Quote from: z-stars on November 07, 2004, 12:35 PM
The problem comes when I repeat the Try Account process several times. After like 15 times, sometimes more sometimes less, BNET stops receiving SID_LOGONRESPONSE2.

That sounds about right, except for Battle.net just stops caring

Yeah, but BNET stopping caring makes my bot completly useless : (

Skywing

This is part of Battle.net's anti-password-bruteforcer protection.

z-stars

#4
Quote from: Skywing on November 07, 2004, 03:23 PM
This is part of Battle.net's anti-password-bruteforcer protection.


It isn't. I'm trying with 12 letter completly random account names, so Battle.net's anti password bruteforcer doesn't take effect. Furthermore, when my program doesn't work, the real client does.  And when I restart my computer, my program works again too. (See my first post for more info).


EDIT: My program works again too after like 20 min, without restarting the computer. (Restarting the computer it works straight).

Skywing

Quote from: z-stars on November 07, 2004, 03:29 PM
Quote from: Skywing on November 07, 2004, 03:23 PM
This is part of Battle.net's anti-password-bruteforcer protection.


It isn't. I'm trying with 12 letter completly random account names, so Battle.net's anti password bruteforcer doesn't take effect. Furthermore, when my program doesn't work, the real client does.  And when I restart my computer, my program works again too. (See my first post for more info).
Have you measured the time between your trying it with the real client and your program no longer getting responses?  It's possible that depending on how long until you decided to try with the official client, the logon temp-ban wore off (a client that tries to log on while temp-banned will IIRC always have to reconnect as it will never got a response).

z-stars

My program does like 15 tries... then stops receiving SID_LOGONRESPONSE2... then I try restarting my program... it doesn't receive a single SID_LOGONRESPONSE2... then I start D2 client... I do a couple tries... work perfectly... I restart my program... still doesn't receive any SID_LOGONRESPONSE2... :(

The-FooL

Quote from: z-stars on November 07, 2004, 03:29 PM
Quote from: Skywing on November 07, 2004, 03:23 PM
This is part of Battle.net's anti-password-bruteforcer protection.


It isn't.

Are you so sure?  I'm not sure of Battle.net's methods for determining whether or not to lock you out of account logon, but I think failing to access accounts 15 times might trigger it.  Then by the time you pull out your client, BNET has cut back the ban.  Bnet's anti-password-bruteforcer does not terminate connections, it just "stops caring" when you try to logon.

z-stars

#8
Quote from: The-FooL on November 07, 2004, 06:14 PM
Quote from: z-stars on November 07, 2004, 03:29 PM
Quote from: Skywing on November 07, 2004, 03:23 PM
This is part of Battle.net's anti-password-bruteforcer protection.


It isn't.

Are you so sure?  I'm not sure of Battle.net's methods for determining whether or not to lock you out of account logon, but I think failing to access accounts 15 times might trigger it.  Then by the time you pull out your client, BNET has cut back the ban.  Bnet's anti-password-bruteforcer does not terminate connections, it just "stops caring" when you try to logon.


I know, but as I said, when my program's SID_LOGONRESPONSE2 stops working, after seeing it works when I try with the real client, my program still does not work. An example:

12:00 AM -> I start my program.
12:30 AM -> My program starts receiving SID_LOGONRESPONSE2. It has done 16 tries.
12:31 AM -> I close my program. I restart it. It doesn't receive a single SID_LOGONRESPONSE2.
12:32 AM -> I open D2 real client. It works perfectly, and I try 5 accounts.
12:34 AM -> I restart my program again. Still doesn't receive a single SID_LOGONRESPONSE2.


[HYPOTHETICAL WAY NUMBER 1]
12:35 AM -> I restart my computer. I restart my program. It works again.

[HYPOTHETICAL WAY NUMBER 2]
12:35 AM -> I do nothing. I wait for around 20 minutes.
12:55 AM -> My program sends SID_LOGONRESPONSE2 again.


__________________________________________________

I hope that clarifies it a bit...

z-stars

HAHA I THINK I GOT IT  ;D

Apparently, each realm has several ip's. My program was obtaining the ip using gethostbyname using x.battle.net (being x the realm name) and that returned always the same ip. Normally that wouldn't care, but apparently, the anti password brute forcing protection of battle.net DOES ban you for some time (except that it only bans you in a certain ip, so for the real client, that uses many ip's, doesn't have effect).


Ok so now I need to somehow get all the ip's (or at least a random ip) of the chosen realm... does anyone know how does D2 client get a random (assuming it is random) ip to connect to?

Skywing

The anti-bruteforce protection bans you on all servers on the gateway...

z-stars

Quote from: Skywing on November 08, 2004, 12:18 PM
The anti-bruteforce protection bans you on all servers on the gateway...

It seems to ban you from all servers on the gateway only for trying with the same account name. If you try with different account names, it only bans you from one of the ip's of the gateway.

z-stars

Nobody knows how can I get all the servers of a gateway?

Skywing

Quote from: z-stars on November 08, 2004, 02:01 PM
Nobody knows how can I get all the servers of a gateway?
Perhaps look at the additional addresses returned by gethostbyname()?

z-stars

Quote from: Skywing on November 08, 2004, 02:04 PM
Quote from: z-stars on November 08, 2004, 02:01 PM
Nobody knows how can I get all the servers of a gateway?
Perhaps look at the additional addresses returned by gethostbyname()?


cool that seems to work :)