diff --git a/CICRadarR/CICRadarR.vbproj b/CICRadarR/CICRadarR.vbproj index f18c53a..01aaee7 100644 --- a/CICRadarR/CICRadarR.vbproj +++ b/CICRadarR/CICRadarR.vbproj @@ -78,7 +78,8 @@ - + + diff --git a/CICRadarR/RADIUSServer.vb b/CICRadarR/RADIUSServer.vb index 690dfce..63ee8d5 100644 --- a/CICRadarR/RADIUSServer.vb +++ b/CICRadarR/RADIUSServer.vb @@ -67,6 +67,11 @@ Public Class RADIUSServer Dim hasher As System.Security.Cryptography.MD5 = System.Security.Cryptography.MD5.Create Dim hash() As Byte = {} Dim secret As String = mSecrets.GetSharedSecret(packet.EndPoint.Address.ToString) + + If secret = Nothing Then + Throw New MissingRadiusSecret(packet.EndPoint.Address.ToString) + End If + Array.Resize(hash, data.Length + secret.Length) data.CopyTo(hash, 0) ConvertToBytes(secret).CopyTo(hash, data.Length) diff --git a/CICRadarR/exceptions/MissingRadiusSecret.vb b/CICRadarR/exceptions/MissingRadiusSecret.vb new file mode 100644 index 0000000..c6c2321 --- /dev/null +++ b/CICRadarR/exceptions/MissingRadiusSecret.vb @@ -0,0 +1,9 @@ +Public Class MissingRadiusSecret + + Inherits Exception + + Public Sub New(ByVal ip As String) + MyBase.New("No shared secret for ip: " & ip & ". This MUST be inserted in the config file.") + End Sub + +End Class diff --git a/CICRadarR/exceptions/MissingUser.vb b/CICRadarR/exceptions/MissingUser.vb new file mode 100644 index 0000000..d31b77d --- /dev/null +++ b/CICRadarR/exceptions/MissingUser.vb @@ -0,0 +1,3 @@ +Public Class MissingUser + Inherits Exception +End Class diff --git a/CICRadarR/exceptions/MissingUserException.vb b/CICRadarR/exceptions/MissingUserException.vb deleted file mode 100644 index 6710dcb..0000000 --- a/CICRadarR/exceptions/MissingUserException.vb +++ /dev/null @@ -1,3 +0,0 @@ -Public Class MissingUserException - Inherits Exception -End Class diff --git a/CICRadarR/handlers/RDSHandler.vb b/CICRadarR/handlers/RDSHandler.vb index 8e407dc..631f774 100644 --- a/CICRadarR/handlers/RDSHandler.vb +++ b/CICRadarR/handlers/RDSHandler.vb @@ -122,6 +122,7 @@ Public Class RDSHandler Accept() End If Catch ex As Exception + Console.WriteLine("Authentication failed. Sending reject.") mPacket.RejectAccessRequest() End Try End Sub @@ -179,6 +180,7 @@ Public Class RDSHandler Dim password As String = mPacket.UserPassword Dim ldapDomain As String = CICRadarR.LDAPDomain + Console.WriteLine("Authenticating: LDAPPAth: " & "LDAP://" & ldapDomain & ", Username: " & packetUsername) Dim dirEntry As New DirectoryEntry("LDAP://" & ldapDomain, packetUsername, password) Dim obj As Object = dirEntry.NativeObject @@ -196,12 +198,11 @@ Public Class RDSHandler search.PropertiesToLoad.Add(CICRadarR.ADMailField) End If - Console.WriteLine("Authenticating: LDAPPAth: " & "LDAP://" & ldapDomain & ", Username: " & packetUsername) Dim result = search.FindOne() If IsDBNull(result) Then Console.WriteLine("Failed to authenticate with Active Directory") - Throw New MissingUserException + Throw New MissingUser End If Return result