Jessecar96 / SteamBot

Automated bot software for interacting with Steam Trade
http://scrap.tf
MIT License
1.34k stars 910 forks source link

All bots can't login now, steam changed someting? #467

Closed baidusteambot closed 11 years ago

baidusteambot commented 11 years ago

Authentication failed,retrying in 2s

steam changed someting? or just steam network problem?

aketay commented 11 years ago

I believe valve must have changed something. I'm having the same problem.

sasuke200 commented 11 years ago

I am having the same problem, some other bot groups/sites's bots look to be offline too.

wlhvoieh commented 11 years ago

I'm having the same issue. All 4 of my bots are down. This is probably a steam security update that had unintended consequences.

Steam's response: "The remote server returned an error: (401) Unauthorized."

geel9 commented 11 years ago

ISteamUserAuth is now private. It seems this must be unintentional; if valve wanted to stop bots entirely, why bother making bots unable to craft earlier?

On Wed, Oct 16, 2013 at 10:08 PM, wlhvoieh notifications@github.com wrote:

I'm having the same issue. All 4 of my bots are down. This is probably a steam security update that had unintended consequences.

— Reply to this email directly or view it on GitHubhttps://github.com/Jessecar96/SteamBot/issues/467#issuecomment-26474446 .

aketay commented 11 years ago

@geel9 care to explain a bit further on your findings?

Nattfrosten commented 11 years ago

Scrap.tf seems to have gotten their bots working..

http://steamcommunity.com/groups/tf2scrap#announcements/detail/1549529149431705533

SephirothSG commented 11 years ago

Anyone have any idea when/if we can expect a commit with the fix?

geel9 commented 11 years ago

All I did was utilize DoLogin() in SteamWeb.Authenticate as opposed to ISteamUserAuth.

On Thu, Oct 17, 2013 at 3:19 AM, SephirothSG notifications@github.comwrote:

Anyone have any idea when/if we can expect a commit with the fix?

— Reply to this email directly or view it on GitHubhttps://github.com/Jessecar96/SteamBot/issues/467#issuecomment-26483690 .

baidusteambot commented 11 years ago

@geel9 hi,how to use DoLogin() ? do you have a fix

Nattfrosten commented 11 years ago

@geel9 Can you please elaborate?

voided commented 11 years ago

Alright, it looks like there isn't enough retry logic for how most steam bots are doing web auth. The root issue is that the Steam servers are giving clients a stale LoginKey that the ISteamUserAuth API is rejecting with a 401 error.

The solution here is to request a new LoginKey on failure, and attempt to perform web auth again.

This will require building bots against SteamKit tip, as the required code has been committed now just now.

The web auth flow should now look something like this (with more error handling and whatnot):

    new Callback<SteamUser.LoginKeyCallback>( OnLoginKey, callbackMgr );
    new JobCallback<SteamUser.WebAPIUserNonceCallback>( OnWebAPINonce, callbackMgr );

    ...

    static void OnLoginKey( SteamUser.LoginKeyCallback callback )
    {
        try
        {
            DoLogin( callback.LoginKey );
        }
        catch ( Exception ex )
        {
            Console.WriteLine( "Unable to perform web auth: {0}, retrying with new login key", ex.Message );
            steamUser.RequestWebAPIUserNonce();
        }
    }

    static void OnWebAPINonce( SteamUser.WebAPIUserNonceCallback callback, JobID jobId )
    {
        if ( callback.Result != EResult.OK )
        {
            Console.WriteLine( "Unable to get user nonce: {0}", callback.Result );
            return;
        }

        DoLogin( callback.Nonce );
    }

    static void DoLogin( string loginKeyString )
    {
        using ( dynamic userAuth = WebAPI.GetInterface( "ISteamUserAuth" ) )
        {
            // ... usual web auth code
        }
    }

If a SteamKit update isn't feasible, you can drop this standalone class into your project: http://www.privatepaste.com/c1fd726838

And then simply register this handler during SteamKit init:

        ...

        GameCoordinator = Client.GetHandler<SteamGameCoordinator>();
        Trading = Client.GetHandler<SteamTrading>();

        ...
        UserWebAPI = new SteamWebAPI();
        Client.AddHandler( UserWebAPI );
Nattfrosten commented 11 years ago

@VoiDeD Sorry for being a hassle, but where is steamkit initialized?

Also, the standalone class should be in SteamKit.Internal namespace, right?

voided commented 11 years ago

@Nattfrosten Depends on whatever framework you're using. If it's SteamBot, you'll probably have to wait until the maintainers update it.

Most of my comment is intended for anyone directly using SteamKit. The standalone class would be added to your own project (whatever is using SteamKit), into whatever namespace you like.

luongvm commented 11 years ago

according to the code in this file https://github.com/Jessecar96/SteamBot/blob/master/SteamBot/Bot.cs, the handlers are declared by this syntax msg.Handle<SteamUser.LoginKeyCallback>(callback => {//code}); (lambda statement, right?)

could you point out the nesseary changes need to this file, @VoiDeD ? i inserted the steamUser.RequestWebAPIUserNonce(); at the catch and stuck there... the LoginKeyCallback is around line 350

Nattfrosten commented 11 years ago

@VoiDeD Right, thanks.

doktokto commented 11 years ago

Hi, guys! I used DoLogin() like said geel9 and my bot loggined after typing SteamGuard Code, but trade not working, bot can't fetch backpack or something like this.

What I've done: In SteamWeb.cs commented this lines (without this action I recieved errors): //string capGID = loginJson == null ? null : Uri.EscapeDataString(loginJson.captcha_gid); //data.Add ("captcha_gid", captcha ? capGID : "");

In bot.cs changed msg.Handle (callback => { // delete while... and write this SteamWeb.DoLogin("username", "password"); // another code the same

Anyone have any idea?

Lagg commented 11 years ago

@VoiDeD Many thanks. Was kind of irked that I started writing my own patch for SteamKit and then suddenly fix happens. But that's okay, worth it.

tenosiswono commented 11 years ago

@Lagg How to fix it? I tried to make new callback for WebAPIUserNonceCallback but still not working. Please help me

doktokto commented 11 years ago

@Lagg how u fixed?

geel9 commented 11 years ago

Thanks for the assistance, Void

tenosiswono commented 11 years ago

@geel9 Please update SteamBot :+1: I haven't find the fix yet :(

grzgrzgrz3 commented 11 years ago

thank you guys

lazy1 commented 11 years ago

@VoiDeD Thanks for the info, now my bots work again.

lazy1 commented 11 years ago

In case anyone interested, to make bots work all you need to do is to store

callback.WebAPIUserNonce from

msg.Handle<SteamUser.LoggedOnCallback> 

and use it in

SteamWeb.Authenticate

instead of callback.LoginKey.

ghost commented 11 years ago

@lazy1 Can you write what need to be changed step by step?

lazy1 commented 11 years ago

OK, this fix is not clean: 1) Declare public string MyLoginKey in Bot.cs 2) Add

 if (callback.Result == EResult.OK)
                {
                    MyLoginKey = callback.WebAPIUserNonce;
                }

into

msg.Handle<SteamUser.LoggedOnCallback> (callback =>
            {

3) In the Bot.cs replace

bool authd = SteamWeb.Authenticate(callback, SteamClient, out sessionId, out token);

with

bool authd = SteamWeb.Authenticate(callback, SteamClient, out sessionId, out token, MyLoginKey);

4) In SteamWeb.cs change definition of Authenticate appropriately to

public static bool Authenticate (SteamUser.LoginKeyCallback callback, SteamClient client, out string sessionId, out string token, string MyLoginKey)

5) Change

Array.Copy (Encoding.ASCII.GetBytes (callback.LoginKey), loginKey, callback.LoginKey.Length);

to

Array.Copy (Encoding.ASCII.GetBytes (MyLoginKey), loginKey, MyLoginKey.Length);
Jessecar96 commented 11 years ago

Do not ask for step by step instructions. It was explained a few times above. If you're using the issue tracker here you need to be able to code.

waylaidwanderer commented 11 years ago

I was able to get my bots up again, thanks VoiDeD!

wlhvoieh commented 11 years ago

@lazy1 contact me at this email address please doms1337@gmail.com i'd like to thank you for helping everyone out

ausey00 commented 11 years ago

Surely someone should make a commit, rather than passing around bit and bobs in the issue tracker

wlhvoieh commented 11 years ago

ausey, to my knowledge, we still dont know if this is an intentional change by valve. so it wouldnt make sense to update the library if it will be changed back.

narugo commented 11 years ago

great job lazy, my bot worked with another type, but really your code do all with 50 words less i used in mine. ty

Jessecar96 commented 11 years ago

I'm not going to make the change yet in the repo. I don't know yet if it's intentional by valve.

gabrielmtzcarrillo commented 11 years ago

tyvm, guys!

kaevne commented 11 years ago

@lazy1 Thanks, @Jessecar96 I agree I feel like quite a shitty coder to just read what needed to be done instead of debug it myself, but thank you.

voided commented 11 years ago

It's highly unlikely that this was an intentional change. I see no reason not to implement the proper handling in SteamBot.

vudung45 commented 11 years ago

Ahhhh.... This makes me confused:( It would be better with a more clear instruction

BTW thanks alot :D I will try ...

My2ndLovE commented 11 years ago

@lazy1 i followed your instruction at https://github.com/Jessecar96/SteamBot/issues/467#issuecomment-26528765 and i able to login successfully. However, when i try to invite the bot to trade and it show below messsage: "[Tradebot] is not available to trade. More information will be shown to [Tradebot] if they invite you to trade." When i try to login into the bot account and trade as usual and everything just working fine. The issue just happen when i run the account as a trade bot.

I try to send trade request form the bot and receive below warning

[TestBot 2013-10-18 18:41:32] DEBUG: SteamKit2.SteamTrading+TradeResultCallback [TestBot 2013-10-18 18:41:32] WARN: Trade failed: 25

dandybreath commented 11 years ago

is trade api changed too? can't add items, the json result only return "can't add items/add items failed"

kaevne commented 11 years ago

@vudung45 I just followed what lazy1 did and it worked fine.

@mysecondlove @dandybreath I run a DotA bot: http://dota2lounge.com/profile?id=76561198085519752 and everything works fine for me after I made the changes recommended by lazy1. However, I've also made some changes to the code compared to the trunk so that it'd work with DotA. The recent changes to TradeSession.cs for fetching the inventory with the appid in the data don't work for me so I reverted those. Please email me at kaevne@gmail.com and I'll send you the source and you can do a windiff.

vudung45 commented 11 years ago

@kaevne: I'm coding dota 2 betting center 2 too Can i have your code for an example to continue?

Soni96pl commented 11 years ago

@lazy1 I got this on two bots: TryhardBrigade.com Slots BOT: Trade declined. Could not correctly fetch your backpack. StajniaOgarow.pl GIFTS: Trade declined. Could not correctly fetch your backpack.

Soni96pl commented 11 years ago

@lazy1 It started working :dart: Danke schön

teliosdev commented 11 years ago

@VoiDeD you're on github now? woa

dandybreath commented 11 years ago

the additem cmd didn't working yesterday but it's fine now.

piemo commented 11 years ago

Seems like the fix stopped working, at least for me. Still getting that 2 sec recconecting message

Soni96pl commented 11 years ago

Do you think they are intentionally trying to break bots?

geel9 commented 11 years ago

Still working for me

On Sat, Oct 19, 2013 at 11:50 AM, Kuba Chronowski notifications@github.comwrote:

Do you think they are intentionally trying to break bots?

— Reply to this email directly or view it on GitHubhttps://github.com/Jessecar96/SteamBot/issues/467#issuecomment-26652382 .

gabrielmtzcarrillo commented 11 years ago

Mine is working as well

piemo commented 11 years ago

Maybe I touched something then. I'll download the blank project again and I'll check if it' a problem in my program Il 19/ott/2013 18:48 "Gabriel Mtz" notifications@github.com ha scritto:

Mine is working as well

— Reply to this email directly or view it on GitHubhttps://github.com/Jessecar96/SteamBot/issues/467#issuecomment-26653729 .