Guest User

Luigi said

a guest
Jun 24th, 2011
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. the problem of samp is that everytime they change something to the protocol so if you want to make a generic tool (for example me with sampfp) there is this boring thing of re-reversing it again and again at each release.
  3. that's also why my sampfp.c code could look a bit chaotic, even more chaotic than my usual C code :)
  5. the good news is that as far as I know (remember that I have never used SA:MP in my life) only the client encrypts the packets while those sent by the server should be all in clear text.
  7. the encryption used in version 0.3x is composed by:
  8. - the first byte of the packet acting like a checksum and the rest is the encrypted data
  9. - this data is simply encrypted with a XOR algorithm based on a static 16bit table
  11. in my code the function that does all this job is samp03_crypt that accepts the following arguments:
  12. - data, the buffer containing the data you want encrypt/decrypt
  13. - size, size of the data
  14. - port, port of the server (for example 7777)
  15. - encdec, use 1 (1 means you want to encrypt the data)
  16. - variant, use 2 (2 is for 0.3c)
  18. the checksum is an 8 bit that is simply the sum of the 4 bits part of all the bytes in the original data.
  19. for example if your data is 41 42 43 than you need to sum 0x01 + 0x02 + 0x03.
  21. for encrypting the data you must:
  22. - scan the table looking for each 8bit part that is equal to the byte you want to encrypt
  23. - the new byte will become the position of this value
  24. - XOR this byte with the port if the current position of the data is odd
  26. for example if you have 0x41 0x42 the first byte will become 0x5c because that one is the position of 0xf941 in the table while the second will be 0x40 resulted by 0x21 (position of 0x7442) is XORed with the port 7777.
  27. (I have written this on the fly so some numbers could be wrong)
  29. maybe this could sound chaotic but it's enough easy and moreover the code is open source so I have tried to explain this only because I had nothing else to do :) (usually I NEVER do this!)
  30. so for other doubts consult the code
RAW Paste Data Copied