Guest User

Untitled

a guest
Jul 2nd, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.14 KB | None | 0 0
  1. Private Sub HandleLogin(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)
  2. Dim Buffer As clsBuffer
  3. Dim Username As String, Password As String, Version As String
  4. Dim loginToken As String
  5.  
  6. On Error GoTo HandleLogin_Error
  7.  
  8. If isArrayEmpty(Data) Then
  9. HackingAttempt Index, "Packet Manipulation: Empty packet data. (HandleLogin)"
  10. Exit Sub
  11. End If
  12.  
  13. Set Buffer = New clsBuffer
  14. Buffer.WriteBytes Data()
  15.  
  16. Username = Buffer.ReadString
  17. Password = Buffer.ReadString
  18. Version = Buffer.ReadString
  19.  
  20. If Not IsAlphaNumeric(Username) Or Not IsAlphaNumeric(Password) Then
  21. SendClientMsg Index, AUTH_ERR_ILLEGAL_CHARS, MenuStates.Login
  22. Exit Sub
  23. End If
  24.  
  25. If Len(Username) < 3 Or Len(Password) < 3 Then
  26. SendClientMsg Index, AUTH_ERR_LENGTH, MenuStates.Login
  27. Exit Sub
  28. End If
  29.  
  30. 'Dim userInfo As Recordset
  31. 'Dim rsPassword As String, rsPasswordSalt As String, rsUserID As Long
  32.  
  33. 'Set userInfo = GetUser(Username, Password)
  34.  
  35. ' Check if we can authenicate
  36. 'If userInfo Is Nothing Then
  37. ' SendClientMsg Index, AUTH_ERR_GENERAL, MenuStates.Login
  38. ' Exit Sub
  39. 'End If
  40.  
  41. 'If Not userInfo.EOF Then
  42. ' USERNAME Found
  43. ' rsUserID = userInfo.Fields(UserTableFields.UserID).value
  44. ' rsPassword = userInfo.Fields(UserTableFields.Password).value
  45. ' rsPasswordSalt = userInfo.Fields(UserTableFields.PasswordSalt).value
  46. ' ' Check Password againest record
  47. ' If rsPassword <> MD5.DigestStrToHexStr(Password & rsPasswordSalt) Then
  48. ' SendClientMsg Index, AUTH_ERR, MenuStates.Login
  49. ' Exit Sub
  50. ' End If
  51.  
  52. ' Check if user is activated
  53. ' If LenB(userInfo.Fields(UserTableFields.ActivationCode)) Then
  54. ' SendClientMsg Index, AUTH_ERR_ACTIVATION, MenuStates.Login
  55. ' Exit Sub
  56. ' End If
  57. 'Else
  58. ' SendClientMsg Index, AUTH_ERR, MenuStates.Login
  59. ' Exit Sub
  60. 'End If
  61.  
  62. 'If Not IsBetaTester(rsUserID) Then
  63. ' SendClientMsg Index, AUTH_ERR_BETA_TESTER, MenuStates.Login
  64. ' Exit Sub
  65. 'End If
  66.  
  67. ' If Not AuthenicateUser(Username, Password) Then
  68. ' SendClientMsg Index, AUTH_ERR, MenuStates.Login
  69. ' Exit Sub
  70. ' End If
  71.  
  72. ' Everything passed, create the token and send it off
  73. loginToken = RandomString("AN-##AA-ANHHAN-H")
  74.  
  75. SendLoginTokenToGameServer Username, loginToken
  76. SendLoginTokenToPlayer Index, loginToken
  77. 'AddText frmServer.txtText, "LoginToken created for " & Username
  78.  
  79. DoEvents
  80. CloseSocket Index
  81. 'Dim Name As String, Password As String, Version As String
  82. '
  83. '' If Not IsPlaying(Index) Then
  84. '' If Not IsLoggedIn(Index) Then
  85. '
  86. ' Set Buffer = New clsBuffer
  87. ' Buffer.WriteBytes Data()
  88. '
  89. ' Name = Buffer.ReadString
  90. ' Password = Buffer.ReadString
  91. ' Version = Buffer.ReadString
  92. '
  93. '' If IsMultiIPOnline(Current_IP(Index)) Then
  94. '' SendAlertMsg Index, "Only one account per computer can be logged in."
  95. '' Exit Sub
  96. '' End If
  97. '
  98. ' If InStr(Name, "/") Then
  99. ' SendClientMsg Index, "Name contains illegal characters.", Login
  100. ' Exit Sub
  101. ' End If
  102. '
  103. ' If InStr(Name, "\") Then
  104. ' SendClientMsg Index, "Name contains illegal characters.", Login
  105. ' Exit Sub
  106. ' End If
  107. '
  108. ' If IsMultiAccounts(Name) Then
  109. ' SendClientMsg Index, "Account is already online. (Err: #11)", Login
  110. ' Exit Sub
  111. ' End If
  112. '
  113. ' If Len(Name) < 3 Or Len(Password) < 3 Then
  114. ' SendClientMsg Index, "Account / Password is too short. (Err: #8)", Login
  115. ' Exit Sub
  116. ' End If
  117. '
  118. ' If Not AccountExist(Name) Then
  119. ' SendClientMsg Index, "Account name does not exist. (Err: #9)", Login
  120. ' Exit Sub
  121. ' End If
  122. '
  123. ' If Not PasswordOK(Name, Password) Then
  124. ' SendClientMsg Index, "Incorrect Password. (Err: #10)", Login
  125. ' Exit Sub
  126. ' End If
  127. '
  128. ' 'version
  129. ' If Version <> ClientVersion Then
  130. ' SendClientMsg Index, "Version " & Version & " is out of date. (Err: #12)", Login
  131. ' Exit Sub
  132. ' End If
  133. '
  134. ' ' Everything went ok
  135. '
  136. ' ' Load the player
  137. ' Update_Login Index, Name
  138. ' Update_Password Index, Password
  139. ' SendChars Index
  140. '
  141. ' ' Show the player up on the socket status
  142. ' AddLog Current_Login(Index) & " has logged in from " & Current_IP(Index) & ".", PLAYER_LOG
  143. ' AddText frmServer.txtText, Current_Login(Index) & " has logged in from " & Current_IP(Index) & "."
  144. ' End If
  145. ' End If
  146.  
  147. Exit Sub
  148.  
  149. HandleLogin_Error:
  150.  
  151. AddLog "Error " & Err.Number & " (" & Err.Description & ") in procedure HandleLogin of Module modHandleData", AUTH_LOG
  152. End Sub
Add Comment
Please, Sign In to add comment