yourmnbbn / tiny-csgo-client

Tiny csgo client for connecting dedicated server
62 stars 9 forks source link

Ticket authentication, real csgo server #19

Open tv1993 opened 1 year ago

tv1993 commented 1 year ago

I have a running steam instance and connect to a real csgo server. Connect via: tiny-csgo-client.exe -name xyz1 -ip 192.168.xxx.xxx -port 27015 -cport 28001 Client generates reservation id successfully and connects to server, server confirms.

Trying to request server reservation id from GC, this may take a while...
Get server reservation id 0xBC7381309601E192

That works fine.

But now, I'd like to join with pregenerated ticket via ticketgen. Account is logged into steam. ticketgen.exe executed to display the ticket and still running. Executing tiny-csgo-client.exe -name xyz2 -ip 192.168.xxx.xxx -port 27015 -cport 28002 -ticket \x14\x00[...]

Connecting to server 192.168.xxx.xxx:27015, using nickname xyz2, using password
Server using 'public' lobbies, requiring pw no, lobby id ffffffffffffffff
Get server challenge number : 0x6431E89, auth prorocol: 0x03, server steam: 8556839292XXXXXX, vac on, dcFriendsReqd 0, officialValveServer 0
STEAM ID: 7656119906XXXXXXX, len:240
Connection refused! - #Valve_Reject_Connect_From_Lobby
Authentication failed! retry...(#1)
...
 STEAM ID: 7656119906XXXXXXX, len:240
Connection refused! - #Valve_Reject_Connect_From_Lobby
Authentication failed! retry...(#31)
 Error: Max retry limit(30) exceeded

Server just rejects connection RejectConnection: 192.168.xxx.xxx:28002 - #Valve_Reject_Connect_From_Lobby Looks like client is not generating the reservation id? What am I missing? It's also possible to generate ticket from steam-user node library and pass the ticket to tiny client. Should I also request reservation id via protobuf k_EMsgGCCStrike15_v2_ClientRequestJoinServerData via node an pass reservation_id to tiny client as well? Im not that into protobuf, but probably im missing something when authenticating with -ticket option.

yourmnbbn commented 1 year ago

Since -ticket option has many flaws and has been deprecated. So many parts of the code related to that option is not updated including GC support and with that option enabled there won't be any reservation id request. -ticket was originally designed for limited version with the purpose of being independent from steam instance, which means emulating all the steam network protocol just like steam-user node library. I don't have time now to bring all that feature to c++.

yourmnbbn commented 1 year ago

Remove condition !m_ArgParser.HasOption("-ticket") it might work fine. https://github.com/yourmnbbn/tiny-csgo-client/blob/8ee400728e5e4fa001bb86f8a54b2afb60e59895/include/client.hpp#L1102

tv1993 commented 1 year ago

Commit 40f5107 has fixed this, now you can use tiny client to connect to any redirecting enabled servers or tiny server(without option -ts), the client will retry to the target server now.

Hi, thanks for your work. I've tried your new commit and I've also tried today to get the reservation id when authenticating with ticket. Process exits in GCClient Init() function on line 55 so the GetServerReservationId function of GCClient won't even gets called when you don't have any steam client running.

yourmnbbn commented 1 year ago

These checks are there for a reason. If you’re not really clear what you’re doing, any attempt to bypass would cause unexpected behavior like what you just encountered. https://github.com/yourmnbbn/tiny-csgo-client/blob/40f5107d3aa5d98e3a73f31a25d92818993e394a/include/client.hpp#L767-L789 GC communication is part of the steam api and require a running steam instance. If you want to use GC without steam, steam-user node library would help you.

tv1993 commented 1 year ago

To join an official community server as authenticated user I need to gernerate the ticket via node and also request the reservation id for the target server and pass it via args to the client.hpp and set m_nServerReservationCookie the value of the received message from an externally GC instance. That should work. I was hoping to use your c++ GC Class to send other messages to GC after the user joined the community server. But probably it would still work if the user is connected to the server via the c++ process and the gc instance in node is sending the messages for the user. Your project is very interesting and has a lot of potential to work guiless with csgo.

yourmnbbn commented 1 year ago

To join an official community server as authenticated user I need to gernerate the ticket via node and also request the reservation id for the target server and pass it via args to the client.hpp and set m_nServerReservationCookie the value of the received message from an externally GC instance. That should work.

Exactly. And if you only want to authenticate players you can bypass the reservation id check on the server side and get rid of the whole GC implementation.

I was hoping to use your c++ GC Class to send other messages to GC after the user joined the community server.

Indeed it can send other messages so I leave an async receive implementation for further development. I've tested commending players using tiny client and it works fine.

tv1993 commented 1 year ago

Thats exactly what I am trying to do 😄 But without a running steam instance, I have an idea how to solve this now. I will post my idea when I've tested it

SebastianKunz commented 1 year ago

@tv1993 were you able to figure something out?

TempJannik commented 1 year ago

To join an official community server as authenticated user I need to gernerate the ticket via node and also request the reservation id for the target server and pass it via args to the client.hpp and set m_nServerReservationCookie the value of the received message from an externally GC instance. That should work.

Exactly. And if you only want to authenticate players you can bypass the reservation id check on the server side and get rid of the whole GC implementation.

I tried this (creating ticket and reservation with an external GC), however without a running steam instance (actual instance, the external GC is still running) after a short time (~10 seconds) the client gets kicked when connected to a VAC Secured Community Server.

Log from client:

Server tick:114, host_computationtime: 0x109, host_computationtime_std_deviation: 0x8c11, host_framestarttime_std_deviation: 0x9AFA
Receive NetMessage CSVCMsg_UpdateStringTable_t
Receive NetMessage CSVCMsg_UpdateStringTable_t
Receive NetMessage CSVCMsg_PacketEntities_t
Error: Got unhandled message type 0x5C
Unknown message size(24) greater than bytes left(6) in the message, abort parsing
Disconnect from server : VAC authentication error

Log from server:

PutClientInServer: no info_player_start on level
STEAMAUTH: Client ~clientname~ received failure code 5
Dropped ~clientname~ from server: VAC authentication error
-> Reservation cookie 0:  reason reserved(yes), clients(no), reservationexpires(0.00)

@yourmnbbn have you dealt with this/seen it before? Do I need to emulate vac entirely or am I missing something?