JustArchiNET / ArchiSteamFarm

C# application with primary purpose of farming Steam cards from multiple accounts simultaneously.
Apache License 2.0
11.3k stars 1.05k forks source link

Add Lockdown check #469

Closed TheSergiooo closed 7 years ago

TheSergiooo commented 7 years ago

Well, at first. Hello Github! I am registered an account here just to give you a little feedback. :D

So, im often mess up with ASF code, wielding its together with some other c# and c++ projects, turning it into an unstable abomination.

What comes like surprise to me, is that ASF successfully logins into lockdowned accounts without mentioning it. I have got less than 1% of this issues, but they were unpleasant. And i think that this one improvement will be useful for community. So, what i did is i opened Bot.cs, and starting in line 1383 i found this

if (callback.AccountFlags.HasFlag(EAccountFlags.LimitedUser)) {
    IsLimitedUser = true;
    ArchiLogger.LogGenericWarning(Strings.BotAccountLimited);
}

Then i took a look into SteamKit2 source code and found definition of EAccountFlags. And there were such flags as EAccountFlags.Lockdown and EAccountFlags.Disabled.

Well, i dont know what Disabled mean, but looks like not something i want in my project, so i changed previous piece of code in bot.cs into

if (callback.AccountFlags.HasFlag(EAccountFlags.LimitedUser)) {
    IsLimitedUser = true;
    ArchiLogger.LogGenericWarning("SERGIOOO.STATUS:LIMITED");
    Stop();
    return;
}

if (callback.AccountFlags.HasFlag(EAccountFlags.Lockdown)) {
    IsLimitedUser = true;
    ArchiLogger.LogGenericWarning("SERGIOOO.STATUS:LOCKDOWN");
    Stop();
    return;                     
}                   

if (callback.AccountFlags.HasFlag(EAccountFlags.Disabled)) {
    IsLimitedUser = true;
    ArchiLogger.LogGenericWarning("SERGIOOO.STATUS:DISABLED");  
    Stop();
    return;                         
} 

Personally for me its vital to stop exactly on this point and dont let to OnLoggedOn continue.

Idea is simple, but for my purposes i need only two things: prevent account from being active and log that this account is locked, no more.

I think this would be nice if ASF would get more data from EAccountFlags and mentioning if is there something special about an account and doing some actions - like Stop(); in case of Lockdown.

Looks like some simple stuff, like

if (callback.AccountFlags.HasFlag(EAccountFlags.Lockdown)) {
    ArchiLogger.LogGenericWarning("Account is in a Lockdown.");
    Stop();
    return;                     
}   

could be added already. I think that someone would have a little bit of relief when he would know that there is only 49 out of 50 active bots, just before going to buy 50 games.

JustArchi commented 7 years ago

I think that someone would have a little bit of relief when he would know that there is only 49 out of 50 active bots, just before going to buy 50 games.

This is what !status ASF is for. Nothing guarantees you that other 49 accounts will log in successfully, regardless of their account flags.

I don't understand this suggestion at all - basically you want to stop bots in case of being limited, lockdown and disabled. For what reason? I can probably understand being disabled and in lockdown, as that could be permanent, but without data that backs up my theory I won't touch those flags as I don't know what they're responsible for. You shouldn't assume anything based on names alone - what matters for ASF is when and why those bits are being set, not the fact that they can be set. The fact is that being limited does not affect ability to log in, and it's absolutely inappropriate for ASF to force logoff in case of being limited, as there is crapload of people using limited accounts for executing commands to ASF, not to mention that being limited does not make it impossible for ASF to operate.

So the main question lies in - do you have any account that triggers lockdown/disabled bit and you can explain to me how that flag relates to account, and if it's permanent? Only then I can add support for it and decide how I want ASF to react to it - I don't agree at all with stopping bot in case of limitation, as it does not prevent ASF from working (such as receiving and answering to commands). If you for some reason don't want to use limited account in ASF, then simply don't enable given bot instance until you lift the restriction.

The entire logic in case of being limited was implemented only to solve questions like "why ASF doesn't idle my new account" and "why ASF idles my main account and doesn't drop cards anyway?". Since it's impossible to idle those accounts anymore, and we can check if account is limited in a nice way, I can also skip idling as it doesn't have a point, and people not aware of that can read the reason from the log. Even without that logic, ASF would work properly, with some features not working (like idling, hence I prefer to give a warning and stop trying instead of giving user false hope).

TheSergiooo commented 7 years ago

Account be either unlocked, or enabled, its depends of reasons of lockdown or suspension. Basically lockdown happens when someone gets an access to lost/stolen old mailboxes of an account. In this situation only way (if it even exists) to unlock an account is contact Steam Support and have a long nice chat. Lockdowns and disables may be both way permanent or untill contact with support or untill using unlock code. There is no lockdowns/suspensions that could be gived for a finite ammount of time. The only question that left, is that is disabled=suspended?

I didn't met a single disabled or suspended account, but looks like its something more serious than a lockdown. There is information about suspending an account on official website. Basic reasons to suspend an account is violation of Steam ToS or chargebacks. I checked EAccountFlags.Disabled bit on 100+ bots, and it's false on all of them. I don't have, and dont know exactly how to make a disabled account. I will try to ask people for this kind of account for an experiment.

But it's easy to cause a Lockdown. I registered an account with a lockdown: login:asflockdowntest, mail:asf_test_2@mail.ru, pass:asfqwerty, and checked EAccountFlags.Lockdown, its true on this account. ASF logs in without problem, just like in a regular account.

The fact is that being limited does not affect ability to log in, and it's absolutely inappropriate for ASF to force logoff in case of being limited, as there is crapload of people using limited accounts for executing commands to ASF, not to mention that being limited does not make it impossible for ASF to operate.

Well, now i agree that Stop(); was a hasty decision that i used to prevent unexpected behavior of ASF. But with stop of bot, there is a small chance of connection loss with ASF, which would be a terrible outcome.

Still, even just LogGenericWarning would be very helpful, as it indicates a problem. By now, it looks like there is no reliable way to discover that account is in a Lockdown. But EAccountFlags has great unused potential. There may be many interesting ideas with EAccountFlags and config file, but profits are questionable, while required much efforts. But even basic handling of some bits may be a simple and good solution. Only with mentioning that disabled/lockdown bit is true, ASF may help user to define a problem and make it less confusing.

TheSergiooo commented 7 years ago

Well, i think i found a neat solution. It would be nice to add [L] and [D] marks just after the state of a bot in !status ASF. I could code it and make a pull request in a few days. Don't mind if i try? :)

JustArchi commented 7 years ago

ASF logs in without problem, just like in a regular account.

Then why you want to Stop() it? The only reason for stopping a bot would be a situation in which logging in is in fact impossible, to avoid infinite reconnect loop that is not going to get us anywhere. From what you said I assume that account in lockdown works like normal one (but probably has some features limited). Since we don't have any disabled account to test ASF behaviour, like I said, you can't assume anything without testing, which means that you can use that info for saying if account is limited/locked/disabled in status, but you shouldn't make a decision whether to Stop() it, unless you carefully tested the outcome and you have a reason to do so (such as infinite reconnect loop). This is what is happening with IsLimitedUser - I don't start idling such account only because I know that it won't get us anywhere.

I could code it and make a pull request in a few days. Don't mind if i try? :)

I don't mind it at all, in fact, I'm rather happy that people want to contribute, as stated in guidelines. Just remember to handle this state in the same way as I handle IsLimitedUser. In fact, if we want to catch several different EAccountFlags, then it'd make sense to get rid of IsLimitedUser and create AccountFlags variable instead (but that is for PR itself, I'll respond with requesting changes if I need them).

Rudokhvist commented 7 years ago

@TheSergiooo could you please explain more about those limited accounts... If you'll try to login to such account manually in steam - will it let you in? What will it say, like, any notice, or something?

il-marc commented 7 years ago

Well, i dont know what Disabled mean, but looks like not something i want in my project, so i changed previous piece of code in bot.cs into

It's not possible to log in with disabled account. Nothing to worry about. And I think that logging account notifications from steamsupport can be useful.

il-marc commented 7 years ago

In addition

Since we don't have any disabled account to test ASF behaviour...

I can provide dumps if you are interested.

JustArchi commented 7 years ago

@il-marc Log from ASF attempting to log in on disabled account would be nice, same to that one in lockdown.

JustArchi commented 7 years ago

Basically the only thing I want to do is checking which case requires to Stop() given bot, and which case can work, but requires extra logic (like current limited account).

il-marc commented 7 years ago

Log for disabled account:

2017-02-24 00:23:56|ASF-9360|INFO|ASF|IsRuntimeSupported() Your .NET runtime version is OK.
2017-02-24 00:23:56|ASF-9360|INFO|ASF|IsRuntimeSupported() Required version: 4.6.1 | Found version: 4.6.1
2017-02-24 00:23:56|ASF-9360|INFO|ASF|InitGlobalDatabaseAndServices() It looks like it's your first launch of the program, welcome!
2017-02-24 00:23:56|ASF-9360|WARN|ASF|InitGlobalDatabaseAndServices() Please review our privacy policy section on the wiki if you're concerned about what ASF is in fact doing!
2017-02-24 00:24:11|ASF-9360|INFO|ASF|CheckForUpdate() ASF will automatically check for new versions every 24 hours.
2017-02-24 00:24:11|ASF-9360|INFO|ASF|CheckForUpdate() Checking for new version...
2017-02-24 00:24:12|ASF-9360|INFO|ASF|CheckForUpdate() Local version: 2.2.2.8 | Remote version: 2.2.2.4
2017-02-24 00:24:12|ASF-9360|INFO|ASF|InitializeCMs() Initializing SteamDirectory...
2017-02-24 00:24:13|ASF-9360|INFO|ASF|InitializeCMs() Success!
2017-02-24 00:24:13|ASF-9360|INFO|disabled|Start() Starting...
2017-02-24 00:24:13|ASF-9360|INFO|disabled|Connect() Connecting...
2017-02-24 00:24:13|ASF-9360|INFO|disabled|OnConnected() Connected to Steam!
2017-02-24 00:24:13|ASF-9360|INFO|disabled|OnConnected() Logging in...
2017-02-24 00:24:14|ASF-9360|ERROR|disabled|OnLoggedOn() Unable to login to Steam: AccountDisabled/AccountDisabled
2017-02-24 00:24:14|ASF-9360|INFO|disabled|Stop() Stopping...
2017-02-24 00:24:14|ASF-9360|INFO|ASF|OnBotShutdown() No bots are running, exiting...
il-marc commented 7 years ago

other one with account alert

2017-02-24 00:28:21|ASF-2060|INFO|ASF|InitASF() ASF V2.2.2.8
2017-02-24 00:28:21|ASF-2060|INFO|ASF|IsRuntimeSupported() Your .NET runtime version is OK.
2017-02-24 00:28:21|ASF-2060|INFO|ASF|IsRuntimeSupported() Required version: 4.6.1 | Found version: 4.6.1
2017-02-24 00:28:21|ASF-2060|INFO|ASF|InitGlobalDatabaseAndServices() It looks like it's your first launch of the program, welcome!
2017-02-24 00:28:21|ASF-2060|WARN|ASF|InitGlobalDatabaseAndServices() Please review our privacy policy section on the wiki if you're concerned about what ASF is in fact doing!
2017-02-24 00:28:36|ASF-2060|INFO|ASF|CheckForUpdate() ASF will automatically check for new versions every 24 hours.
2017-02-24 00:28:36|ASF-2060|INFO|ASF|CheckForUpdate() Checking for new version...
2017-02-24 00:28:37|ASF-2060|INFO|ASF|CheckForUpdate() Local version: 2.2.2.8 | Remote version: 2.2.2.4
2017-02-24 00:28:37|ASF-2060|INFO|ASF|InitializeCMs() Initializing SteamDirectory...
2017-02-24 00:28:37|ASF-2060|INFO|ASF|InitializeCMs() Success!
2017-02-24 00:28:37|ASF-2060|INFO|tos|Start() Starting...
2017-02-24 00:28:37|ASF-2060|INFO|tos|Connect() Connecting...
2017-02-24 00:28:38|ASF-2060|INFO|tos|OnConnected() Connected to Steam!
2017-02-24 00:28:38|ASF-2060|INFO|tos|OnConnected() Logging in...
2017-02-24 00:28:48|ASF-2060|INFO|tos|OnDisconnected() Disconnected from Steam!
2017-02-24 00:28:48|ASF-2060|INFO|tos|OnDisconnected() Reconnecting...
2017-02-24 00:28:48|ASF-2060|INFO|tos|Connect() Connecting...
2017-02-24 00:28:49|ASF-2060|INFO|tos|OnConnected() Connected to Steam!
2017-02-24 00:28:49|ASF-2060|INFO|tos|OnConnected() Logging in...
2017-02-24 00:28:49|ASF-2060|INFO|tos|OnLoggedOn() Successfully logged on!
2017-02-24 00:28:49|ASF-2060|INFO|tos|Init() Logging in to ISteamUserAuth...
2017-02-24 00:28:50|ASF-2060|INFO|tos|Init() Success!
2017-02-24 00:28:51|ASF-2060|INFO|tos|IsAnythingToFarm() Checking first badge page...
2017-02-24 00:28:53|ASF-2060|INFO|tos|StartFarming() We have a total of 4 games (16 cards) left to idle (~10 hours remaining)...
2017-02-24 00:28:53|ASF-2060|INFO|tos|StartFarming() Chosen idling algorithm: Complex
2017-02-24 00:28:53|ASF-2060|INFO|tos|FarmMultiple() Now idling: 395980, 368900, 410590, 432150
2017-02-24 00:28:53|ASF-2060|INFO|tos|FarmHours() Still idling: 395980, 368900, 410590, 432150

ss of notification

image

JustArchi commented 7 years ago

Thanks a lot @il-marc, I'll add one more thing to test for you, sec.

JustArchi commented 7 years ago

@il-marc If you could check both of those accounts with this build then I'd have everything I need.

In case of first account, I disabled shutdown, which should lead to infinite reconnect loop (ASF getting account disabled, OnDisconnected(), reconnect attempt, same result). You can stop after 2-3 tries, since this is intended and what I want to test. If by any chance ASF won't get OnDisconnected() or likewise (won't attempt to reconnect), let me know.

In case of second account, it should log in properly, and ASF will print debug message in the console with account flags for it - save those if you can and let me know what ASF returns. As an extra it'd be interesting if you could try to !redeem something on that second account which can log in, and let me know what Status of that try ASF outputs in chat message.

Relevant commit for both: https://github.com/JustArchi/ArchiSteamFarm/commit/c85de9ce9a94a97a8fd7cc087205c8c7379dafb7

That should be everything, with extra info I'll be able to add some misc bits to ASF logic, so ASF will be aware of those possibilities.

il-marc commented 7 years ago

@JustArchi it doesn't reconnect

2017-02-24 00:47:38|ASF-3812|INFO|ASF|CheckForUpdate() Local version: 2.2.2.9 | Remote version: 2.2.2.4
2017-02-24 00:47:38|ASF-3812|INFO|ASF|InitializeCMs() Initializing SteamDirectory...
2017-02-24 00:47:39|ASF-3812|INFO|ASF|InitializeCMs() Success!
2017-02-24 00:47:39|ASF-3812|INFO|disabled|Start() Starting...
2017-02-24 00:47:39|ASF-3812|INFO|disabled|Connect() Connecting...
2017-02-24 00:47:39|ASF-3812|INFO|tos|InitStart() Not starting this bot instance because it's disabled in config file!
2017-02-24 00:47:39|ASF-3812|INFO|disabled|OnConnected() Connected to Steam!
2017-02-24 00:47:39|ASF-3812|INFO|disabled|OnConnected() Logging in...
2017-02-24 00:47:40|ASF-3812|WARN|disabled|OnLoggedOn() Unable to login to Steam: AccountDisabled/AccountDisabled
2017-02-24 00:47:40|ASF-3812|INFO|disabled|OnDisconnected() Disconnected from Steam!
il-marc commented 7 years ago

@JustArchi

2017-02-24 00:50:20|ASF-9316|DEBUG|tos|OnLoggedOn() Flags: PersonaNameSet, Passw
ordSet, HWIDSet, EmailValidated, LogonExtraSecurity, Steam2MigrationComplete, Lo
ckdown
JustArchi commented 7 years ago

Ah yes, it won't reconnect because I returned from my call, I should disable that too in addition to Stop(), but yes this is what I needed - there is OnDisconnected(), which means that failure is permanent. Thanks a lot! Let me add some extra bits.

JustArchi commented 7 years ago

In the meantime feel free to check !redeem.

il-marc commented 7 years ago

should I redeem valid key? upd. nm

JustArchi commented 7 years ago

I don't know what will happen, it depends what logic Valve uses first - if keys get denied due to being invalid first, or due to account being in lockdown first. Best thing to try all cases -> invalid key, duplicate key, valid key as last resort if you won't trigger anything unusual with 2 previous attempts.

il-marc commented 7 years ago

invalid key

<tos> Key: WHYVO-LVOXD-DLMAO | Status: BadActivationCode

same results for valid and duplicate keys

<tos> Key: 9___B-N___X-W___R | Status: AccountLocked | Items: [67636, Ruzh Delta Z]
JustArchi commented 7 years ago

This is actually pretty freaking nice way to check if given key is valid without redeeming it... It'd be possible to check for what game given key is without triggering activation by accident 🤔

Thanks a lot!

il-marc commented 7 years ago

@JustArchi btw noticed warnings in log

2017-02-24 00:57:07|ASF-4192|WARN|ASF|ResponseRedeem() Received unknown value for PurchaseResultDetail, please report this: AccountLocked
2017-02-24 00:57:07|ASF-4192|INFO|ASF|HandleCommand() Answered to WCF command: !redeem tos 9___B-N___X-W___R with: 
<tos> Key: 9___B-N___X-W___R | Status: AccountLocked | Items: [67636, Ruzh Delta Z]
JustArchi commented 7 years ago

Yes, this is why I asked you to test this in the first place, because it's another valid case that is currently not being handled, and with extra info I can add proper logic for handling it, such as marking AccountLocked redeem response as "available for forward/distribute", same as AlreadyPurchased.

Basically ASF has several places where it's basing its logic on status, and the logic is "available" only for statuses that I know about, so I do not handle a Steam glitch or something unusual in "generic case" by accident. Because you verified how AccountLocked works, I can now add it to the list of statuses that ASF can handle, and react accordingly 👍 .

JustArchi commented 7 years ago

Mystery of the day: can accounts in lockdown actually farm cards? I mean for sure you can play, but I'm wondering if it yields in any card drops, since I could also disable CardsFarmer like in LimitedUser case.

JustArchi commented 7 years ago

I'm however not sure if you can test this, since you can't redeem keys and you'd probably need to spend actual money in Steam store for "science", but if you have some cards available for farming already, or you could buy something cheap and do "science", then it'd be interesting discovery and ASF could also benefit from this, whether there is a point in farming such account or not, @il-marc

Up to you though, I can't really expect anybody to spend his time/money only to help ASF development, especially because you already helped me a lot! 😃

il-marc commented 7 years ago

@JustArchi

Purchasing, gifting, trading, buying and selling items on the Community Market, and cd-key activation have been disabled.

Anyway I tried to buy a game and steam store said:

Oops, sorry! An error was encountered while processing your request: Purchasing has been disabled for your account.

JustArchi commented 7 years ago

I thought it's for keys only, my bad. I guess you don't have any games with cards still available to drop then? I mean, it's not like it matters, since you probably can't do anything with them, but it'd still be interesting to check.

il-marc commented 7 years ago

@JustArchi will try to farm cards and message about results.

Rudokhvist commented 7 years ago

Great way of checking the keys. We can even find out for what game this key is. Too bad it needs a locked account to work(

il-marc commented 7 years ago

After 9h of farming single game I didn't get any card. Seems card drops restricted too. At least for me.