Advertisement
Kapa3a

Fix Disable Packets Encryption

Dec 10th, 2023
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.39 KB | Source Code | 0 0
  1. ************************I.Source Binary :*************************
  2.  
  3. ServiceDefs.h
  4. Find:
  5. ####################
  6.  
  7. #define _IMPROVED_PACKET_ENCRYPTION_
  8.  
  9. Replace:
  10. ####################
  11.  
  12. //#define _IMPROVED_PACKET_ENCRYPTION_
  13.  
  14. Locale.cpp
  15. Find:
  16. ####################
  17.  
  18. #define LSS_SECURITY_KEY    "testtesttesttest"
  19.  
  20. Replace:
  21. ####################
  22.  
  23. #define LSS_SECURITY_KEY    "1234abcd5678efgh"
  24.  
  25. ************************II.Source Server :*************************
  26.  
  27.  
  28. service.h
  29. Find:
  30. ####################
  31.  
  32. #define _IMPROVED_PACKET_ENCRYPTION_
  33.  
  34. Replace:
  35. ####################
  36.  
  37. //#define _IMPROVED_PACKET_ENCRYPTION_
  38.  
  39. protocol.h
  40. Find:
  41. #####################
  42.  
  43. //buffer_adjust_size(pbuf, length);
  44.  
  45. Replace:
  46. #####################
  47.  
  48. buffer_adjust_size(pbuf, length);
  49.  
  50. protocol.h
  51. Find:
  52. #####################
  53. #define DEFAULT_PACKET_BUFFER_SIZE .......
  54.  
  55. Replace :
  56. #####################
  57.  
  58. #define DEFAULT_PACKET_BUFFER_SIZE (150*1024) //@warme015 prevent dc if there are many entities
  59.  
  60. desc.cpp
  61. Find:
  62. #####################
  63.  
  64. void DESC::Packet(const void * c_pvData, int iSize)
  65.  
  66. Remplace:
  67. #####################
  68.  
  69. void DESC::Packet(const void * c_pvData, int iSize)
  70. {
  71.     assert(iSize > 0);
  72.  
  73.     if (m_iPhase == PHASE_CLOSE) // 끊는 상태면 보내지 않는다.
  74.         return;
  75.  
  76.     if (m_stRelayName.length() != 0)
  77.     {
  78.         // Relay 패킷은 암호화하지 않는다.
  79.         TPacketGGRelay p;
  80.  
  81.         p.bHeader = HEADER_GG_RELAY;
  82.         strlcpy(p.szName, m_stRelayName.c_str(), sizeof(p.szName));
  83.         p.lSize = iSize;
  84.  
  85.         if (!packet_encode(m_lpOutputBuffer, &p, sizeof(p)))
  86.         {
  87.             m_iPhase = PHASE_CLOSE;
  88.             return;
  89.         }
  90.  
  91.         m_stRelayName.clear();
  92.  
  93.         if (!packet_encode(m_lpOutputBuffer, c_pvData, iSize))
  94.         {
  95.             m_iPhase = PHASE_CLOSE;
  96.             return;
  97.         }
  98.     }
  99.     else
  100.     {
  101.         if (m_lpBufferedOutputBuffer)
  102.         {
  103.             buffer_write(m_lpBufferedOutputBuffer, c_pvData, iSize);
  104.  
  105.             c_pvData = buffer_read_peek(m_lpBufferedOutputBuffer);
  106.             iSize = buffer_size(m_lpBufferedOutputBuffer);
  107.         }
  108.  
  109.         // TRAFFIC_PROFILE
  110.         if (g_bTrafficProfileOn)
  111.             TrafficProfiler::instance().Report(TrafficProfiler::IODIR_OUTPUT, *(BYTE *) c_pvData, iSize);
  112.         // END_OF_TRAFFIC_PROFILER
  113.  
  114. #ifdef _IMPROVED_PACKET_ENCRYPTION_
  115.         void* buf = buffer_write_peek(m_lpOutputBuffer);
  116.  
  117.        
  118.         if (packet_encode(m_lpOutputBuffer, c_pvData, iSize))
  119.         {
  120.             if (cipher_.activated()) {
  121.                 cipher_.Encrypt(buf, iSize);
  122.             }
  123.         }
  124.         else
  125.         {
  126.             m_iPhase = PHASE_CLOSE;
  127.         }
  128. #else
  129.         if (!m_bEncrypted)
  130.         {
  131.             if (!packet_encode(m_lpOutputBuffer, c_pvData, iSize))
  132.             {
  133.                 m_iPhase = PHASE_CLOSE;
  134.             }
  135.         }
  136.         else
  137.         {
  138.             if (buffer_has_space(m_lpOutputBuffer) < iSize + 8)
  139.             {
  140.                 sys_err("desc buffer mem_size overflow. memsize(%u) write_pos(%u) iSize(%d)",
  141.                         m_lpOutputBuffer->mem_size, m_lpOutputBuffer->write_point_pos, iSize);
  142.  
  143.                 m_iPhase = PHASE_CLOSE;
  144.             }
  145.             else
  146.             {
  147.                 // 암호화에 필요한 충분한 버퍼 크기를 확보한다.
  148.                 /* buffer_adjust_size(m_lpOutputBuffer, iSize + 8); */
  149.                 DWORD * pdwWritePoint = (DWORD *) buffer_write_peek(m_lpOutputBuffer);
  150.  
  151.                 if (packet_encode(m_lpOutputBuffer, c_pvData, iSize))
  152.                 {
  153.                     int iSize2 = TEA_Encrypt(pdwWritePoint, pdwWritePoint, GetEncryptionKey(), iSize);
  154.  
  155.                     if (iSize2 > iSize)
  156.                         buffer_write_proceed(m_lpOutputBuffer, iSize2 - iSize);
  157.                 }
  158.             }
  159.         }
  160. #endif // _IMPROVED_PACKET_ENCRYPTION_
  161.  
  162.         SAFE_BUFFER_DELETE(m_lpBufferedOutputBuffer);
  163.     }
  164.  
  165.     //sys_log(0, "%d bytes written (first byte %d)", iSize, *(BYTE *) c_pvData);
  166.     if (m_iPhase != PHASE_CLOSE)
  167.         fdwatch_add_fd(m_lpFdw, m_sock, this, FDW_WRITE, true);
  168. }
  169.  
  170.  
  171. Well, such a thing is quite easy, and I know it since 2011~2012 (when the first 30k game cores were released to be more precise).
  172. You can find some diff patch files of that time for 30k game cores on the web that do this, but I will explain to you how to do it via source code editing.
  173.  
  174. Before all, why the 40k game core files have a login more slower than usual? That's because ymir implemented an additional encryption security using cryptopp, and at login, they added some key agreement checks, which ended up the login to be more slower.
  175.  
  176. You can actually disable such a feature, so that you can have the login fast like the old game revisions had.
  177. Disabling it will actually remove the "key agreement" issue, and will encrypt the connection with xtea instead of some cryptopp algorithms. (no big security issues, so it's safe to do)
  178.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement