yourmnbbn / tiny-csgo-client

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

Compiling the code #1

Closed HexMr closed 2 years ago

HexMr commented 2 years ago

Hello, how do I compile this repository?

yourmnbbn commented 2 years ago
HexMr commented 2 years ago

I'd like to help you, but I'm having trouble compiling this code. I spent a lot of time on this, but I was unable to run this code. If you help me get it started, I can take a peek at it. As for quick help, you can see in the repository: https://github.com/Leystryku/leysourceengineclient , https://github.com/Leystryku/LeySourceEngineProxyServ ,https://github.com/DuckyC/gmsv_query , https://www.unknowncheats.me/forum/counterstrike-global-offensive/438794-csgo-console-mode.html , https://www.unknowncheats.me/forum/counterstrike-global-offensive/206828-csgo-client-emulation.html , https://www.unknowncheats.me/forum/counterstrike-global-offensive/335207-csgo-network-traffic.html , https://www.unknowncheats.me/forum/counterstrike-global-offensive/414765-steamkit2-connect-server-game-client.html , https://developer.valvesoftware.com/wiki/Server_queries#A2S_INFO , https://steamcommunity.com/discussions/forum/14/2974028351344359625/ , https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/engine/baseserver.cpp#L3161 , https://github.com/perilouswithadollarsign/cstrike15_src/blob/f82112a2388b841d72cb62ca48ab1846dfcc11c8/engine/sv_main.cpp#L3264 I hope it helps you, and you can help me in return. You have to simulate a "heartbeat". I guess you need to return some steam ID to the server so that the server can verify you as a real player. You need to implement protobuf and set signon state to be fully authenticated and visible as a player.

HexMr commented 2 years ago

https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers https://www.unknowncheats.me/wiki/Valve_Anti-Cheat https://www.unknowncheats.me/forum/counterstrike-global-offensive/478513-recommend-vac-bypass.html https://www.unknowncheats.me/forum/counterstrike-global-offensive/372394-vac-measure-3.html https://github.com/danielkrupinski/VAC-Bypass

yourmnbbn commented 2 years ago

Hey, thanks for your work and help, but the problems is not about lack of information and resources, the leaked source code and some reverse engineering via IDA could solve pretty much everything. It's about too much TODOs and detail to implement.

Authentication is done when you send C2S_CONNECT packet with steam auth ticket got by steamworks api. Server will validate the ticket. If passes, server will send you the last connection-less packet with header S2C_CONNECT to tell you that your netchannel is properly configured and you're fully authenticated and connected, it's time to use netmessages instead of connection-less packets to communicate. Implementation should be step by step.

For now, sending netmessage is already supported after the latest commits, the tiny client can now send any netmessages defined in common/netmessages.h. Receive and parse netmessage is still working in progress, maybe not that quick because I have little free time left.

I'm guessing you have trouble configuring the hl2sdk-csgo, I'll later comment the required libs and pre-defined macros.

yourmnbbn commented 2 years ago

Pre-defined macros:

COMPILER_MSVC
COMPILER_MSVC32
_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING

Required libs:

tier1.lib
tier0.lib
legacy_stdio_definitions.lib
steam_api.lib
libprotobuf.lib (from release/vs2017)

Required sources:

netmessages.pb.cc

CRT options:

/MT

Compile the code on release mode.

Note that you have to move steam_api.dll and tier0.dll from your csgo game files to where next to the project executable as required dependencies, and put steam_appid.txt in the same dir as a required configuration to initialize steam api.

toorisrael commented 2 years ago

For begginers (like me) it's still extremally hard to compile, if you could provide something more ready to compile, I would appreciate.

yourmnbbn commented 2 years ago

For begginers (like me) it's still extremally hard to compile, if you could provide something more ready to compile, I would appreciate.

I'll make this a more proper project when I finish implementing the connection process and make the client fully active in the server. Like I said, it's not for general use now. And anyone who wants to help at this has to play around with hl2sdk-csgo without engine environment and ambuild, ofc you can refer to some of the official ambuild scripts, that will help a lot.

For now it's still far from complete and need more progress, but I can put the test console output here. If you still wants to get help compiling this, contact me by email yourmnbbn@gmail.com.

Setting breakpad minidump AppID = 730
SteamInternal_SetMinidumpSteamID:  Caching Steam ID:  76561198303323332 [API loaded no]
Connecting to server 127.0.0.1:27016, using nickname yourmnbbn, using password qiaodadiao1
Server using 'friends' lobbies, requiring pw yes, lobby id 0xffffffffffffffff
Get server challenge number : 0x05a27932, auth prorocol: 0x03, server steam: (hidden here), vac on, dcFriendsReqd false, officialValveServer false

Counter-Strike: Global Offensive
Map: de_mirage
Players: 1 (1 bots) / 10 humans
Build: 8598
Server Number: 142

Receive NetMessage CSVCMsg_CmdKeyValues_t
Receive NetMessage CSVCMsg_ServerInfo_t
Receive NetMessage CNETMsg_Tick_t
Server tick:130, host_computationtime:0, host_computationtime_std_deviation: 0, host_framestarttime_std_deviation: 0
Receive NetMessage CNETMsg_SetConVar_t

cash_team_rescued_hostage 600
bot_autodifficulty_threshold_high 0
cash_team_win_by_defusing_bomb 3500
game_mode 1
mp_force_pick_time 9999
mp_ggtr_bomb_pts_for_upgrade 2
mp_weapons_allow_zeus 5
bot_quota 0
ff_damage_reduction_bullets 0.33
bot_quota_mode fill
mp_join_grace_time 15
cash_player_interact_with_hostage 300
ammo_grenade_limit_total 4
mp_respawn_immunitytime -1
mp_roundtime_defuse 1.92
mp_ggprogressive_round_restart_delay 15
mp_timelimit 0
mp_warmuptime 300
sv_deadtalk 1
mp_randomspawn_los 0
mp_endmatch_votenextmap 0
mp_weapons_allow_map_placed 1
mp_autokick 0
sv_minrate 128000
sv_hosting_lobby 1
mp_technical_timeout_duration_s 120
mp_warmuptime_all_players_connected 60
spec_freeze_time 2
mp_buytime 20
bot_difficulty 2
mp_roundtime_hostage 1.92
mp_freezetime 0
sv_maxcmdrate 128
bot_defer_to_human_goals 1
sv_skyname sky_dust
mp_friendlyfire 1
mp_technical_timeout_per_team 1
cash_team_hostage_interaction 600
spec_freeze_panel_extended_time 0
ff_damage_reduction_other 0.4
mp_molotovusedelay 0
mp_limitteams 0
mp_starting_losses 1
cash_team_elimination_hostage_map_t 3000
ammo_grenade_limit_flashbang 2
tv_snapshotrate 64
mp_roundtime 1.92
mp_halftime 1
mp_ggtr_bomb_respawn_delay 0
cash_team_bonus_shorthanded 1000
think_limit 0
ff_damage_reduction_grenade 0.85
cash_team_elimination_hostage_map_ct 3000
cash_team_win_by_hostage_rescue 2900
bot_join_after_player 0
sv_maxupdaterate 128
Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: downloadables, max_entries: 8192, user_data_size_bits: 0, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: modelprecache, max_entries: 4096, user_data_size_bits: 2, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: genericprecache, max_entries: 512, user_data_size_bits: 2, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: soundprecache, max_entries: 32768, user_data_size_bits: 2, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: decalprecache, max_entries: 512, user_data_size_bits: 2, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: instancebaseline, max_entries: 1024, user_data_size_bits: 0, flags: 0

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: lightstyles, max_entries: 64, user_data_size_bits: 0, flags: 0

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: userinfo, max_entries: 256, user_data_size_bits: 0, flags: 0

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: dynamicmodel, max_entries: 4096, user_data_size_bits: 1, flags: 0

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: server_query_info, max_entries: 4, user_data_size_bits: 0, flags: 0

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: ExtraParticleFilesTable, max_entries: 1024, user_data_size_bits: 0, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: ParticleEffectNames, max_entries: 1024, user_data_size_bits: 0, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: EffectDispatch, max_entries: 1024, user_data_size_bits: 0, flags: 0

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: VguiScreen, max_entries: 256, user_data_size_bits: 0, flags: 0

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: Materials, max_entries: 1024, user_data_size_bits: 0, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: InfoPanel, max_entries: 128, user_data_size_bits: 0, flags: 0

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: Scenes, max_entries: 32768, user_data_size_bits: 0, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: Movies, max_entries: 16, user_data_size_bits: 0, flags: 1

Receive NetMessage CSVCMsg_CreateStringTable_t
StringTable name: GameRulesCreation, max_entries: 1, user_data_size_bits: 0, flags: 0

Receive NetMessage CNETMsg_SignonState_t
signon_state: 3, spawn_count: 142
Disconnect from server : Server uses different class tables
HexMr commented 2 years ago

I guess if you made it easier to compile, more people would help you. You may disagree with that, but I think it would be better. Other people may want to help you, but if they can't compile it, how are they going to help you?

yourmnbbn commented 2 years ago

I guess if you made it easier to compile, more people would help you. You may disagree with that, but I think it would be better. Other people may want to help you, but if they can't compile it, how are they going to help you?

Yeah you're right, I also agree with that. But I have to implement the basic networking and make the client stay alive in server first. Good news is that it's already been done by the last few commits. I've tested the client to be alive in server for an hour, it could be longer. Bad news is that it's still far from complete. We can't retry, changelevel, and we skip receiving a lot of messages like entity packets and more.

Next I'll make it more beginner friendly as you wish.

toorisrael commented 2 years ago

I totally understand it will be a waste of time making this preview easy to run at this point, so of course I can wait. But still - if you find some time to make it easy to compile - I would appreciate, I'd really love to test it (especially running multiple instances) :)

yourmnbbn commented 2 years ago

I totally understand it will be a waste of time making this preview easy to run at this point, so of course I can wait. But still - if you find some time to make it easy to compile - I would appreciate, I'd really love to test it (especially running multiple instances) :)

Latest commit has added the CMake support, compilation is much more beginner friendly.

toorisrael commented 2 years ago

Thank you very much! I've tested this in few scenarios:

  1. VAC secured server: client will only get status "spawning" for about 5 mins, than timeout (even with forced sv_timeout -1).
    Client log Receive NetMessage CSVCMsg_CreateStringTable_t StringTable name: , max_entries: 0, user_data_size_bits: 0, flags: 0

Got unhandle message type A Got unhandle message type 58 Got unhandle message type 70 Receive NetMessage CNETMsg_PlayerAvatarData_t Got unhandle message type 5F Got unhandle message type 33 Got unhandle message type BF Got unhandle message type 6F Got unhandle message type 9F Got unhandle message type 75 Got unhandle message type 30 Got unhandle message type 6D Got unhandle message type 61 Got unhandle message type FF Got unhandle message type 74 Got unhandle message type 33 Got unhandle message type 3F Got unhandle message type CF Disconnect from server : z9wupizg timed out

  1. VAC insecure server: client will get "active" status and stay on server for a long time. EDIT: this worked few times, after more tests I got:

    Log Received fragments: offset 34816 start 136, num 4, length:1024 Total fragment needed: 242, received: 140 Dropped 1608 packets at 1652 out of order packet 44 at 1652 out of order packet 45 at 1652 out of order packet 46 at 1652 out of order packet 47 at 1652 out of order packet 48 at 1652 out of order packet 49 at 1652 out of order packet 50 at 1652 out of order packet 51 at 1652 out of order packet 52 at 1652 out of order packet 53 at 1652 out of order packet 54 at 1652 out of order packet 55 at 1652 out of order packet 56 at 1652 out of order packet 57 at 1652 out of order packet 58 at 1652 out of order packet 59 at 1652 out of order packet 60 at 1652 out of order packet 61 at 1652 out of order packet 62 at 1652 out of order packet 63 at 1652 out of order packet 64 at 1652 out of order packet 65 at 1652 out of order packet 66 at 1652 out of order packet 67 at 1652 out of order packet 68 at 1652 out of order packet 69 at 1652 out of order packet 70 at 1652 out of order packet 71 at 1652 out of order packet 72 at 1652 out of order packet 73 at 1652 out of order packet 74 at 1652 out of order packet 75 at 1652 out of order packet 76 at 1652 out of order packet 77 at 1652 out of order packet 78 at 1652 out of order packet 79 at 1652 out of order packet 80 at 1652 out of order packet 81 at 1652 out of order packet 82 at 1652 out of order packet 83 at 1652 out of order packet 84 at 1652 out of order packet 85 at 1652 out of order packet 86 at 1652 out of order packet 87 at 1652 out of order packet 88 at 1652 out of order packet 89 at 1652 out of order packet 90 at 1652 out of order packet 91 at 1652 out of order packet 92 at 1652 out of order packet 93 at 1652 out of order packet 94 at 1652 out of order packet 95 at 1652 out of order packet 96 at 1652 out of order packet 97 at 1652 out of order packet 98 at 1652 out of order packet 99 at 1652 out of order packet 100 at 1652 out of order packet 101 at 1652 out of order packet 102 at 1652 out of order packet 103 at 1652 out of order packet 104 at 1652 out of order packet 105 at 1652 out of order packet 106 at 1653 out of order packet 107 at 1654 out of order packet 108 at 1655 out of order packet 109 at 1657 out of order packet 110 at 1657 out of order packet 111 at 1659 out of order packet 112 at 1659 out of order packet 113 at 1661 out of order packet 114 at 1662
  2. VAC secured server with detouring IsTimedOut, IsTimingOut, CheckTimeouts etc.: client will get "spawning" status and stay on server for at least 10 mins.

  3. VAC secured server with Steam client VAC bypass: tiny-csgo-client will instantly close after starting.

All tests to internet servers, with few repeats. If a player stays on server, it's visible as authenticated player in Steam API/Internet browser.

yourmnbbn commented 2 years ago

@toorisrael I guess you're testing this on linux server. I'm testing this on windows server and it could stay alive in both secure and insecure server. I have run this to connect a linux server and have the same problem as you, no matter what vac status is.

The problem is that net message stream parsing corrupted at one CSVCMsg_CreateStringTable_t message and ruined all the rest messages. So we can't receive the signon state from server which is located at the very end of the message stream. As a result, we can't change our state from spawning to active because we need information from the CNETMsg_SignonState_t message that server sent to us.

Maybe it has something to do with the fragments receiving. When we send our first signon state to server, server will then send us a bunch of messages about itself listed here. Although those messages are send by udp but they are marked as reliable by the engine which means we have to acknowledge them. Server split those messages into little packets 1024 bytes each. Every time server send us 8 packets then waiting for our acknowledgment. if our next message received by the server is not acknowledgment, those 8 packets will be sent again.

Looking at the source it's not so clear about how to actually acknowledge, so I use packet capture tools for a quick hack to save some time. I send raw acknowledge packet to server and it works. But the problem is the last acknowledgment doesn't seem to work. The server will always resend the last few packets back. So we can't receive the following messages. Now the active state is actually a hack, tiny csgo client skip receiving the following entity packets and more, directly tell server to spawn us to be active.

I've opened another issue about this here, this is supposed to be closed.