el truco consiste en tener un contador de paquetes, y usarlo como pw para encriptar/desencriptar todos los paquetes, lo bueno es que esta clave cambia cada ves que sale un paquete desde el cliente, y por eso es 100% dinámica, además de que NO alarga demasiado el string (ojo, yo no hice la encriptación , fué la primera que encontré en google a las 5 am), es corto y funcional.
empezamos .
agregamos TANTO SERVIDOR COMO CLIENTE, un nuevo módulo y lo llenamos con esto
- ' #################################################
- ' #################################################
- ' #################################################
- ' #################################################
- ' http://www.elguille.info/colabora/2008/ ... riptar.htm
- ' #################################################
- ' #################################################
- ' #################################################
- ' #################################################
- Function EncryptStr(ByVal S As String, ByVal P As String) As String
- Dim i As Integer, R As String
- Dim C1 As Integer, C2 As Integer
- R = ""
- If Len(P) > 0 Then
- For i = 1 To Len(S)
- C1 = Asc(mid(S, i, 1))
- If i > Len(P) Then
- C2 = Asc(mid(P, i Mod Len(P) + 1, 1))
- Else
- C2 = Asc(mid(P, i, 1))
- End If
- C1 = C1 + C2 + 64
- If C1 > 255 Then C1 = C1 - 256
- R = R + Chr(C1)
- Next i
- Else
- R = S
- End If
- EncryptStr = R
- End Function
- 'Desencripta una cadena de caracteres.
- 'S = Cadena a desencriptar
- 'P = Password
- Function UnEncryptStr(ByVal S As String, ByVal P As String) As String
- Dim i As Integer, R As String
- Dim C1 As Integer, C2 As Integer
- R = ""
- If Len(P) > 0 Then
- For i = 1 To Len(S)
- C1 = Asc(mid(S, i, 1))
- If i > Len(P) Then
- C2 = Asc(mid(P, i Mod Len(P) + 1, 1))
- Else
- C2 = Asc(mid(P, i, 1))
- End If
- C1 = C1 - C2 - 64
- If Sgn(C1) = -1 Then C1 = 256 + C1
- R = R + Chr(C1)
- Next i
- Else
- R = S
- End If
- UnEncryptStr = R
- End Function
buscan el sub EventoSockRead y lo remplazan por este.
- Public Sub EventoSockRead(ByVal Slot As Integer, ByRef Datos As String)
- #If UsarQueSocket = 1 Then
- Dim T() As String
- Dim LoopC As Long
- UserList(Slot).RDBuffer = UserList(Slot).RDBuffer & Datos
- ' ########## Sumo el contador
- If UserList(Slot).flags.UserLogged Then
- UserList(Slot).security.Count = UserList(Slot).security.Count + 13
- End If
- ' ########## Desencripto!.
- T = Split(UnEncryptStr(UserList(Slot).RDBuffer, CStr(UserList(Slot).security.Count)), ENDC)
- If UBound(T) > 0 Then
- UserList(Slot).RDBuffer = T(UBound(T))
- For LoopC = 0 To UBound(T) - 1
- '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- '%%% SI ESTA OPCION SE ACTIVA SOLUCIONA %%%
- '%%% EL PROBLEMA DEL SPEEDHACK %%%
- '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- If ClientsCommandsQueue = 1 Then
- If T(LoopC) <> "" Then If Not UserList(Slot).CommandsBuffer.Push(T(LoopC)) Then Call CloseSocket(Slot)
- Else ' no encolamos los comandos (MUY VIEJO)
- If UserList(Slot).ConnID <> -1 Then
- Call HandleData(Slot, T(LoopC))
- Else
- Exit Sub
- End If
- End If
- Next LoopC
- End If
- #End If
- End Sub
un poco mas arriba está el sub EventoSockAccept
en el mismo buscamos esto
- UserList(NewIndex).ConnIDValida = True
- Set UserList(NewIndex).CommandsBuffer = New CColaArray
- Set UserList(NewIndex).ColaSalida = New Collection
arriba/abajo da igual, agregamos
- UserList(NewIndex).security.Count = 0
mas abajo en ese mismo módulo encontramos el sub EventoSockClose
buscamos esto en ese sub
- 'Es el mismo user al que está revisando el centinela??
abajo agregamos
- UserList(Slot).security.Count = 0
bien , ahora buscamos el Type User y en el esto.
- showName As Boolean 'Permite que los GMs oculten su nick con el comando /SHOWNAME
abajo agregamos
- security As securityData
abajo del End Type o en cualquier otro módulo (preferentemente Modulo declaraciones) ponemos
- ' ### SEGURIDAD ###
- Type securityData
- Count As Double 'Contador de paquetes.
- 'mRotation as sentidoGirarChars 'NO SE USA
- End Type
Pasamos al cliente, y remplazamos el sub SendData por este.
- Sub SendData(ByVal sdData As String)
- 'No enviamos nada si no estamos conectados
- If frmMain.Winsock1.State <> sckConnected Then Exit Sub
- Dim AuxCmd As String
- AuxCmd = UCase$(Left$(sdData, 5))
- 'Debug.Print ">> " & sdData
- sdData = sdData & ENDC
- 'Para evitar el spamming
- If AuxCmd = "DEMSG" And Len(sdData) > 8000 Then
- Exit Sub
- ElseIf Len(sdData) > 300 And AuxCmd <> "DEMSG" Then
- Exit Sub
- End If
- If UCase$(Left$(sdData, 6)) = "OLOGIN" Then
- packageCount = 0
- Else
- packageCount = packageCount + 13
- End If
- Debug.Print "SALE DATA : " & sdData
- sdData = EncryptStr(sdData, cstr(packageCount))
- Debug.Print "SALE DATA CRYPT : " & sdData
- Call frmMain.Winsock1.SendData(sdData)
- End Sub
y por último, declaramos
- Public PackageCount as Double
con esto estaría todo , pueden comprobar que el string no se alarga tanto, con 1 ejemplo
SALE DATA : M3
SALE DATA CRYPT : ¿¨q
SALE DATA : RC51,52
SALE DATA CRYPT : ĸ§¦ž§§r
SALE DATA : M3
SALE DATA CRYPT : ¿¨s
SALE DATA : M3
SALE DATA CRYPT : ¿¨t
SALE DATA : M4
SALE DATA CRYPT : ¿©u




799![Oraculo [5] Oraculo [5]](./images/ranks/Rango29.gif)



![Destructor de Mentes [4] Destructor de Mentes [4]](./images/ranks/Rango16.gif)



![Dragon Ancestral [2] Dragon Ancestral [2]](./images/ranks/Rango31.gif)


![Aprendiz [6] Aprendiz [6]](./images/ranks/Rango11.gif)

![Oraculo [1] Oraculo [1]](./images/ranks/Rango25.gif)

![Aprendiz [3] Aprendiz [3]](./images/ranks/Rango8.gif)



![Destructor de Mentes [11] Destructor de Mentes [11]](./images/ranks/Rango23.gif)




