Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

omp user detection & server to client encryption for omp users #1026

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

AmyrAhmady
Copy link
Member

@AmyrAhmady AmyrAhmady commented Dec 7, 2024

i dont like poles
385371624980873228_512x512

@AmyrAhmady
Copy link
Member Author

Some explanations:
For connection request packet SAMP uses 3 bytes (one for packet id, the other two for cookie seed I guess...)
I've changed this for omp launcher users and now it's 14 openmultiplayer/RakNet@7bfb64a...20bd25b#diff-5ebcaa4fdb0b73ba98c95b61d3428b26f7e2297d05bf2e0287048bad76be2834R4103

Which is handled here: openmultiplayer/RakNet@7bfb64a...20bd25b#diff-e5d7976b6cdaaee7a6be2e173c0251ae68161545e8023844925bceb5abf20979R677
Basically checks if length is 14, if it is, check if it has omp bytes in it, if so, get the data we need out of it, which is omp version and player's encryption randomized seed.

Then it configures player settings and then reply back to client with this openmultiplayer/RakNet@7bfb64a...20bd25b#diff-e5d7976b6cdaaee7a6be2e173c0251ae68161545e8023844925bceb5abf20979R656
This is client's way of knowing it has connected to an omp server. that "magic" number is only there so there's no conflict between our usage of this packet ID and other people's third party plugins. Client also checks server version and warns the user if there's a mismatch

Encryption is pretty easy to understand as well openmultiplayer/RakNet@7bfb64a...20bd25b#diff-e5d7976b6cdaaee7a6be2e173c0251ae68161545e8023844925bceb5abf20979R328
It's just the same as client to server encryption, instead I've made it much simpler by only having a XOR against player's random seed value. also have a checksum thingy just like client to server again, it's only there to tell both sides the arriving packet is valid and needs to be processed. if checksum fails it means it's not good for processing.

Now with all that, it means it is required to know whether a user is using omp launcher or not, and since we keep track of that, I also added IsPlayerUsingOmp for both SDK users and Pawn users

@AmyrAhmady
Copy link
Member Author

Do not merge this yet by the way, I could be changing some stuff first.

@NexiusTailer
Copy link
Contributor

NexiusTailer commented Dec 7, 2024

Just one little note about the naming of native added. We already have IsPlayerUsingOfficialClient and now we also will have another to determine that a player is playing from omp launcher/client mod. But IsPlayerUsingOfficialClient and IsPlayerUsingOmp may seem mutually exclusive for a scripter, so I'd suggest a bit different name, like more specific IsPlayerUsingOmpLauncher or HasPlayerOmpClientMod.

@Hual
Copy link
Collaborator

Hual commented Dec 8, 2024

Client -> server should be encrypted too ideally

@AmyrAhmady
Copy link
Member Author

Update
Now omp uses a new value for petarded (yes) and it's 0x6D70, bytes for mp, in ID_OPEN_CONNECTION_REQUEST packet
then now in a new way, instead of using gpci, it's just a random uint32 encryption seed, and it is generated on the server side then later sent, right after receiving ID_OPEN_CONNECTION_REQUEST

The reason behind these changes is so many hosting providers have their custom set of firewall rules so I'm not able to send or customize packets from client to server in any way I want, so I had to re-use current packet without customization (like ID_OPEN_CONNECTION_REQUEST)

Also latest raknet changes are synced too so this PR contains race condition fixes too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants