m4dEngi / open-steamworks

Open Steamworks is a set of reverse engineered headers for the Valve's Steam Client
40 stars 10 forks source link

Logging in with protobuf #11

Closed Rosentti closed 1 year ago

Rosentti commented 1 year ago

Logging in using SetLoginInformation and SetTwoFactorCode followed with the LogIn call works fine, but it doesn't save the password. I'm assuming since the client log says "Using JWT" with the official client and "Using credential pair" with my client, it doesn't send the required protobufs itself, and I can't send them through SharedConnection. Am I missing something?

How I'm doing it right now:

  1. Retrieve RSA key for password encryption through https://steamcommunity.com/login/getrsakey?username=
  2. Use RSA key with openssl to encrypt the password.
  3. Fill out CAuthentication_BeginAuthSessionViaCredentials_Request
  4. Connect to the CMs with ClientUser->EConnect()
  5. Send the protobuf with SendMessageAndAwaitResponse
  6. Steam starts complaining about "Trying to send a message with mismatched session id for current cm connection"
  7. No callbacks are received and login isn't performed.

How can I use SharedConnection successfully? And is it possible to get the response data?

m4dEngi commented 1 year ago

IIRC you don't get callbacks for SharedConnections on incoming messages. You have to poll after allocating it. I haven't investigated the new login process yet.

Rosentti commented 1 year ago

Maybe I need to use SharedConnection->InitiateConnection. But that doesn't seem to change anything.

Rosentti commented 1 year ago

How can I get a response out? Currently after getting a response I'm notified by callback, however using BPopReceivedMessage crashes. I guess this is because it needs a CUtlBuffer passed in. But how can I create one?

Rosentti commented 1 year ago

Figured it out, you need to create and allocate a CUtlBuf yourself.

promo55 commented 1 year ago

@20PercentRendered Can you show an example of using a shared connection and creating a CUtlBuf ? Thank you.

Rosentti commented 1 year ago

I'm not currently on my PC, will share an example when I get home. However I used MiniUTL by FWGS and constructed a CUtlBuffer set with an initial allocation and growsize of 1.

Rosentti commented 1 year ago

@promo55 https://github.com/20PercentRendered/opensteamclient/blob/master/src/client/messaging/protomsg.hpp This class uses SharedConnection quite extensively. Note that you need to send protobuf or the other format. And be careful with endianness.

JustaP0tato commented 1 year ago

@promo55 @20PercentRendered Gentlemen, please tell a newbie what I'm doing wrong:

`IClientEngine clEngine = (IClientEngine)SteamInternal_CreateInterface(CLIENTENGINE_INTERFACE_VERSION);

HSteamPipe hSteamPipe = clEngine->CreateSteamPipe();

HSteamUser` hSteamUser = clEngine->CreateGlobalUser(&hSteamPipe);

IClientSharedConnection* shrConnection = clEngine->GetIClientSharedConnection(hSteamUser, hSteamPipe);

IClientUser* clUser = clEngine->GetIClientUser(hSteamUser, hSteamPipe);

clUser->EConnect();

HSharedConnection hcon = shrConnection->AllocateSharedConnection();

cout<<"say hello"<<endl;

vector test{0x4d,0x26,0x00,0x80,0x0e,0x00,0x00,0x00,0x09,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x80,0x02,0x01,0x08,0xac,0x80,0x04 };

shrConnection->SendMessage(hcon, test.data(), test.size());

cout<<"succes"<<endl;

while(true){

//do nothing

}`

I'm trying to send a test message using the interface sharedconnection, but my application just closes on the moment it's sent, without any error. The message is not sent and I don't see "success".

promo55 commented 1 year ago

If you are trying to login then:

  1. in IClientUser add this: virtual void LogOn( CSteamID steamID, bool UNC ) = 0; and del this: virtual void LogOn( CSteamID steamID ) = 0;
  2. clientUser->SetLoginInformation("accname", "accpass", false); clientUser->SetTwoFactorCode("2fa"); CSteamID steamID = clientUser->GetSteamID(); сlientUser->LogOn(steamID, true); I couldn't use sharedconnection but this login code was enough for me.
JustaP0tato commented 1 year ago

thanks, but I saw it in @20PercentRendered code. i want to use sharedconnection for many things, it is important for me to understand how it works

Rosentti commented 1 year ago

Your IClient classes and IClientEngine might be outdated. If you use my headers, you should also use the specific steamclient library version. Your message might also have an invalid header or emsg. I strongly recommend using the protobuf library.

JustaP0tato commented 1 year ago

I am using the latest version of steamclient. I tried both your(@20PercentRendered ) and @m4dEngi versions of the interfaces, but there is no difference, I came to a dead end.