Rename CICRadarR -> RDSFactor

This commit is contained in:
Jakob A. Dam 2015-04-10 09:43:25 +02:00 committed by Jakob Aarøe Dam
parent d296781847
commit a29384d872
40 changed files with 810 additions and 810 deletions

View file

@ -1,68 +1,68 @@
Imports System.ServiceProcess Imports System.ServiceProcess
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class CICRadarR Partial Class RDSFactor
Inherits System.ServiceProcess.ServiceBase Inherits System.ServiceProcess.ServiceBase
'UserService overrides dispose to clean up the component list. 'UserService overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _ <System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean) Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try Try
If disposing AndAlso components IsNot Nothing Then If disposing AndAlso components IsNot Nothing Then
components.Dispose() components.Dispose()
End If End If
Finally Finally
MyBase.Dispose(disposing) MyBase.Dispose(disposing)
End Try End Try
End Sub End Sub
' The main entry point for the process ' The main entry point for the process
<MTAThread()> _ <MTAThread()> _
<System.Diagnostics.DebuggerNonUserCode()> _ <System.Diagnostics.DebuggerNonUserCode()> _
Shared Sub Main(ByVal args() As String) Shared Sub Main(ByVal args() As String)
Dim ServicesToRun() As System.ServiceProcess.ServiceBase Dim ServicesToRun() As System.ServiceProcess.ServiceBase
' More than one NT Service may run within the same process. To add ' More than one NT Service may run within the same process. To add
' another service to this process, change the following line to ' another service to this process, change the following line to
' create a second service object. For example, ' create a second service object. For example,
' '
' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService} ' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
' '
Dim server = New CICRadarR() Dim server = New RDSFactor()
If Environment.UserInteractive Then If Environment.UserInteractive Then
server.OnStart(args) server.OnStart(args)
Console.WriteLine("Type any character to exit") Console.WriteLine("Type any character to exit")
Console.Read() Console.Read()
server.OnStop() server.OnStop()
Else Else
ServicesToRun = New System.ServiceProcess.ServiceBase() {server} ServicesToRun = New System.ServiceProcess.ServiceBase() {server}
System.ServiceProcess.ServiceBase.Run(ServicesToRun) System.ServiceProcess.ServiceBase.Run(ServicesToRun)
End If End If
End Sub End Sub
'Required by the Component Designer 'Required by the Component Designer
Private components As System.ComponentModel.IContainer Private components As System.ComponentModel.IContainer
' NOTE: The following procedure is required by the Component Designer ' NOTE: The following procedure is required by the Component Designer
' It can be modified using the Component Designer. ' It can be modified using the Component Designer.
' Do not modify it using the code editor. ' Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _ <System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent() Private Sub InitializeComponent()
Me.TimerCleanUpHash = New System.Timers.Timer() Me.TimerCleanUpHash = New System.Timers.Timer()
CType(Me.TimerCleanUpHash, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.TimerCleanUpHash, System.ComponentModel.ISupportInitialize).BeginInit()
' '
'TimerCleanUpHash 'TimerCleanUpHash
' '
Me.TimerCleanUpHash.Enabled = True Me.TimerCleanUpHash.Enabled = True
Me.TimerCleanUpHash.Interval = 60000.0R Me.TimerCleanUpHash.Interval = 60000.0R
' '
'CICRadarR 'CICRadarR
' '
Me.ServiceName = "Service1" Me.ServiceName = "Service1"
CType(Me.TimerCleanUpHash, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.TimerCleanUpHash, System.ComponentModel.ISupportInitialize).EndInit()
End Sub End Sub
Friend WithEvents TimerCleanUpHash As System.Timers.Timer Friend WithEvents TimerCleanUpHash As System.Timers.Timer
End Class End Class

View file

@ -1,126 +1,126 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader> <resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value> <value>[base64 mime encoded serialized .NET Framework object]</value>
</data> </data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType> <xsd:complexType>
<xsd:choice maxOccurs="unbounded"> <xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata"> <xsd:element name="metadata">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" /> <xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" /> <xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" /> <xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" /> <xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="assembly"> <xsd:element name="assembly">
<xsd:complexType> <xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" /> <xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" /> <xsd:attribute name="name" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="data"> <xsd:element name="data">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" /> <xsd:attribute ref="xml:space" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
<xsd:element name="resheader"> <xsd:element name="resheader">
<xsd:complexType> <xsd:complexType>
<xsd:sequence> <xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" /> <xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:choice> </xsd:choice>
</xsd:complexType> </xsd:complexType>
</xsd:element> </xsd:element>
</xsd:schema> </xsd:schema>
<resheader name="resmimetype"> <resheader name="resmimetype">
<value>text/microsoft-resx</value> <value>text/microsoft-resx</value>
</resheader> </resheader>
<resheader name="version"> <resheader name="version">
<value>2.0</value> <value>2.0</value>
</resheader> </resheader>
<resheader name="reader"> <resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<resheader name="writer"> <resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader> </resheader>
<metadata name="TimerCleanUpHash.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> <metadata name="TimerCleanUpHash.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value> <value>17, 17</value>
</metadata> </metadata>
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> <metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value> <value>False</value>
</metadata> </metadata>
</root> </root>

View file

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Express 2013 for Windows Desktop # Visual Studio Express 2013 for Windows Desktop
VisualStudioVersion = 12.0.31101.0 VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "CICRadarR", "CICRadarR.vbproj", "{04C6C533-9FEA-41B2-B554-A166C7C7FE32}" Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RDSFactor", "RDSFactor.vbproj", "{04C6C533-9FEA-41B2-B554-A166C7C7FE32}"
EndProject EndProject
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RADAR", "..\radar-radius\RADAR\RADAR.vbproj", "{3AB08A4E-C4FA-4571-A5D4-32BBA807C31D}" Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RADAR", "..\radar-radius\RADAR\RADAR.vbproj", "{3AB08A4E-C4FA-4571-A5D4-32BBA807C31D}"
EndProject EndProject

View file

@ -1,377 +1,377 @@
Imports System.DirectoryServices Imports System.DirectoryServices
Imports System.IO Imports System.IO
Imports System.Reflection Imports System.Reflection
Imports CICRadarR.SMS Imports CICRadarR.SMS
Imports CICRadarR.LogFile Imports CICRadarR.LogFile
Imports System.Security.Cryptography Imports System.Security.Cryptography
Imports System.Text Imports System.Text
Imports System Imports System
Imports System.Net.Mail Imports System.Net.Mail
Imports RADAR Imports RADAR
Public Class CICRadarR Public Class RDSFactor
Public Shared LDAPDomain As String = "" Public Shared LDAPDomain As String = ""
Public Shared ADField As String = "" Public Shared ADField As String = ""
Public Shared ADMailField As String = "" Public Shared ADMailField As String = ""
Public Shared EnableOTP As Boolean Public Shared EnableOTP As Boolean
' Shared key: used for challange encryption ' Shared key: used for challange encryption
' TODO: Fix ' TODO: Fix
Public Shared encCode As String = "gewsyy#sjs2!" Public Shared encCode As String = "gewsyy#sjs2!"
Private Shared DEBUG As Boolean Private Shared DEBUG As Boolean
Private Shared UserAccessLog As New LogWriter Private Shared UserAccessLog As New LogWriter
Private Shared Log As New LogWriter Private Shared Log As New LogWriter
Private secrets As NASAuthList Private secrets As NASAuthList
Private radius1812 As RADIUSServer Private radius1812 As RADIUSServer
Private radius1645 As RADIUSServer Private radius1645 As RADIUSServer
Private userHash As New Hashtable Private userHash As New Hashtable
Private packetHash As New Hashtable Private packetHash As New Hashtable
Private clientHash As New Hashtable Private clientHash As New Hashtable
Public Shared NetBiosDomain As String = "" Public Shared NetBiosDomain As String = ""
Private Shared Provider As String = "" Private Shared Provider As String = ""
Private Shared ModemType As String = "" Private Shared ModemType As String = ""
Private Shared ComPort As String = "" Private Shared ComPort As String = ""
Private Shared SmsC As String = "" Private Shared SmsC As String = ""
Private Shared MailServer As String = "" Private Shared MailServer As String = ""
Private Shared SenderEmail As String = "" Private Shared SenderEmail As String = ""
Private TSGW As String = "" Private TSGW As String = ""
Private TSGWSessionIdHash As New Hashtable Private TSGWSessionIdHash As New Hashtable
Private TSGWSessionIdTimeStampHash As New Hashtable Private TSGWSessionIdTimeStampHash As New Hashtable
Private TSGWLaunchIdTimeStampHash As New Hashtable Private TSGWLaunchIdTimeStampHash As New Hashtable
Private TSGWFirstLoginHash As New Hashtable ' Ensure that only one sms is send even if radius need to re-authenticate. Private TSGWFirstLoginHash As New Hashtable ' Ensure that only one sms is send even if radius need to re-authenticate.
Private TSGWFirstLoginTimeStampHash As New Hashtable ' Ensure that only one sms is send even if radius need to re-authenticate. Private TSGWFirstLoginTimeStampHash As New Hashtable ' Ensure that only one sms is send even if radius need to re-authenticate.
Public Shared SessionTimeOut As Integer = 30 ' in minutes Public Shared SessionTimeOut As Integer = 30 ' in minutes
Public Shared LaunchTimeOut As Integer = 30 ' in seconds Public Shared LaunchTimeOut As Integer = 30 ' in seconds
Public Shared EnableSMS As Boolean = False Public Shared EnableSMS As Boolean = False
Public Shared EnableEmail As Boolean = False Public Shared EnableEmail As Boolean = False
Protected Overrides Sub OnStart(ByVal args() As String) Protected Overrides Sub OnStart(ByVal args() As String)
Log.filePath = ApplicationPath() & "\log.txt" Log.filePath = ApplicationPath() & "\log.txt"
UserAccessLog.filePath = ApplicationPath() & "\UserAccessLog.txt" UserAccessLog.filePath = ApplicationPath() & "\UserAccessLog.txt"
Log.WriteLog("---------------------------------------------------------------------------------------------------") Log.WriteLog("---------------------------------------------------------------------------------------------------")
ServerLog("Starting Service") ServerLog("Starting Service")
ServerLog("Loading Configuration...") ServerLog("Loading Configuration...")
Call loadConfiguration() Call loadConfiguration()
ServerLog("Starting Radius listner ports...") ServerLog("Starting Radius listner ports...")
Call StartUpServer() Call StartUpServer()
End Sub End Sub
Public Sub OnstartTest() Public Sub OnstartTest()
Log.filePath = ApplicationPath() & "\log.txt" Log.filePath = ApplicationPath() & "\log.txt"
UserAccessLog.filePath = ApplicationPath() & "\UserAccessLog.txt" UserAccessLog.filePath = ApplicationPath() & "\UserAccessLog.txt"
ServerLog("---------------------------------------------------------------------------------------------------") ServerLog("---------------------------------------------------------------------------------------------------")
ServerLog("Starting Service") ServerLog("Starting Service")
ServerLog("Loading Configuration...") ServerLog("Loading Configuration...")
Call loadConfiguration() Call loadConfiguration()
ServerLog("Starting Radius listner ports...") ServerLog("Starting Radius listner ports...")
Call StartUpServer() Call StartUpServer()
End Sub End Sub
Protected Overrides Sub OnStop() Protected Overrides Sub OnStop()
ServerLog("Stopping Radius listner ports...") ServerLog("Stopping Radius listner ports...")
End Sub End Sub
Public Sub OnStopTest() Public Sub OnStopTest()
ServerLog("Stopping Radius listner ports...") ServerLog("Stopping Radius listner ports...")
End Sub End Sub
Public Sub StartUpServer() Public Sub StartUpServer()
' First, let's load a list of RADIUS shared secrets ' First, let's load a list of RADIUS shared secrets
' in a NASAuthList object (a glorified Dictionary, basically) ' in a NASAuthList object (a glorified Dictionary, basically)
secrets = New NASAuthList secrets = New NASAuthList
' Populate from DB, I suppose ... ' Populate from DB, I suppose ...
For Each cl As DictionaryEntry In clientHash For Each cl As DictionaryEntry In clientHash
ServerLog("Adding Shared Secret to Radius Server") ServerLog("Adding Shared Secret to Radius Server")
secrets.AddSharedSecret(cl.Key, cl.Value) secrets.AddSharedSecret(cl.Key, cl.Value)
Next Next
' Then, we just create a RADIUS server ... ' Then, we just create a RADIUS server ...
Try Try
radius1812 = New RADIUSServer(1812, AddressOf ProcessPacket1812, secrets) radius1812 = New RADIUSServer(1812, AddressOf ProcessPacket1812, secrets)
ServerLog("Starting Radius Server on Port 1812...OK") ServerLog("Starting Radius Server on Port 1812...OK")
Catch Catch
ServerLog("Starting Radius Server on Port 1812...FAILED") ServerLog("Starting Radius Server on Port 1812...FAILED")
End Try End Try
Try Try
radius1645 = New RADIUSServer(1645, AddressOf ProcessPacket1645, secrets) radius1645 = New RADIUSServer(1645, AddressOf ProcessPacket1645, secrets)
ServerLog("Starting Radius Server on Port 1645...OK") ServerLog("Starting Radius Server on Port 1645...OK")
Catch Catch
ServerLog("Starting Radius Server on Port 1645...FAILED") ServerLog("Starting Radius Server on Port 1645...FAILED")
End Try End Try
End Sub End Sub
' Every valid RADIUS request generated by the server(s) we created earlier ' Every valid RADIUS request generated by the server(s) we created earlier
' will fire up the callback procedure. Invalid requests are dropped, per RFC. ' will fire up the callback procedure. Invalid requests are dropped, per RFC.
Private Sub ProcessPacket1812(ByVal packet As RADIUSPacket) Private Sub ProcessPacket1812(ByVal packet As RADIUSPacket)
'Console.WriteLine("packet " & Now) 'Console.WriteLine("packet " & Now)
ProcessPacket(radius1812, packet) ProcessPacket(radius1812, packet)
End Sub End Sub
Private Sub ProcessPacket1645(ByVal packet As RADIUSPacket) Private Sub ProcessPacket1645(ByVal packet As RADIUSPacket)
ProcessPacket(radius1645, packet) ProcessPacket(radius1645, packet)
End Sub End Sub
Public Shared Sub AccessLog(ByVal message) Public Shared Sub AccessLog(ByVal message)
If DEBUG = True Then If DEBUG = True Then
UserAccessLog.WriteLog(Now & ": DEBUG: " & message) UserAccessLog.WriteLog(Now & ": DEBUG: " & message)
' Also write to the console if not a service ' Also write to the console if not a service
If Environment.UserInteractive Then If Environment.UserInteractive Then
Console.WriteLine(Now & ": DEBUG: " & message) Console.WriteLine(Now & ": DEBUG: " & message)
End If End If
End If End If
End Sub End Sub
Public Shared Sub ServerLog(ByVal message) Public Shared Sub ServerLog(ByVal message)
Log.WriteLog(Now & ":" & message) Log.WriteLog(Now & ":" & message)
' Also write to the console if not a service ' Also write to the console if not a service
If Environment.UserInteractive Then If Environment.UserInteractive Then
Console.WriteLine(Now & message) Console.WriteLine(Now & message)
End If End If
End Sub End Sub
Private Sub ProcessPacket(ByVal server As RADIUSServer, ByVal packet As RADIUSPacket) Private Sub ProcessPacket(ByVal server As RADIUSServer, ByVal packet As RADIUSPacket)
If Not packet.IsValid Then If Not packet.IsValid Then
Console.WriteLine("Packet is not valid. Discarding.") Console.WriteLine("Packet is not valid. Discarding.")
Exit Sub Exit Sub
End If End If
Dim handler Dim handler
If TSGW = "1" Then If TSGW = "1" Then
handler = New RDSHandler(packet) handler = New RDSHandler(packet)
Else Else
handler = New CitrixHandler(packet) handler = New CitrixHandler(packet)
End If End If
handler.ProcessRequest() handler.ProcessRequest()
End Sub End Sub
Public Shared Function GenerateCode() As String Public Shared Function GenerateCode() As String
Dim dummy As Integer = 0 Dim dummy As Integer = 0
Dim ordRand As New System.Random() Dim ordRand As New System.Random()
Dim temp As New System.Collections.ArrayList() Dim temp As New System.Collections.ArrayList()
While temp.Count < 6 While temp.Count < 6
dummy = ordRand.[Next](1, 9) dummy = ordRand.[Next](1, 9)
If Not temp.Contains(dummy) Then If Not temp.Contains(dummy) Then
temp.Add(dummy) temp.Add(dummy)
End If End If
End While End While
Dim strVar As String = temp(0).ToString() + temp(1).ToString() + temp(2).ToString() + temp(3).ToString() + temp(4).ToString() + temp(5).ToString() Dim strVar As String = temp(0).ToString() + temp(1).ToString() + temp(2).ToString() + temp(3).ToString() + temp(4).ToString() + temp(5).ToString()
Return strVar Return strVar
End Function End Function
Public Sub loadConfiguration() Public Sub loadConfiguration()
Dim ConfOk As Boolean = True Dim ConfOk As Boolean = True
Dim RConfig As New IniFile Dim RConfig As New IniFile
Try Try
RConfig.Load(ApplicationPath() & "\CICRadarR.ini") RConfig.Load(ApplicationPath() & "\CICRadarR.ini")
DEBUG = RConfig.GetKeyValue("CICRadarR", "Debug") DEBUG = RConfig.GetKeyValue("CICRadarR", "Debug")
NetBiosDomain = RConfig.GetKeyValue("CICRadarR", "NetBiosDomain") NetBiosDomain = RConfig.GetKeyValue("CICRadarR", "NetBiosDomain")
If NetBiosDomain.Length = 0 Then If NetBiosDomain.Length = 0 Then
ServerLog("ERROR: NetBiosDomain can not be empty") ServerLog("ERROR: NetBiosDomain can not be empty")
ConfOk = False ConfOk = False
End If End If
LDAPDomain = RConfig.GetKeyValue("CICRadarR", "LDAPDomain") LDAPDomain = RConfig.GetKeyValue("CICRadarR", "LDAPDomain")
If LDAPDomain.Length = 0 Then If LDAPDomain.Length = 0 Then
ServerLog("ERROR: LDAPDomain can not be empty") ServerLog("ERROR: LDAPDomain can not be empty")
ConfOk = False ConfOk = False
End If End If
TSGW = RConfig.GetKeyValue("CICRadarR", "TSGW") TSGW = RConfig.GetKeyValue("CICRadarR", "TSGW")
EnableOTP = RConfig.GetKeyValue("CICRadarR", "EnableOTP") EnableOTP = RConfig.GetKeyValue("CICRadarR", "EnableOTP")
If EnableOTP = True Then If EnableOTP = True Then
If RConfig.GetKeyValue("CICRadarR", "EnableEmail") = "1" Then If RConfig.GetKeyValue("CICRadarR", "EnableEmail") = "1" Then
EnableEmail = True EnableEmail = True
SenderEmail = RConfig.GetKeyValue("CICRadarR", "SenderEmail") SenderEmail = RConfig.GetKeyValue("CICRadarR", "SenderEmail")
MailServer = RConfig.GetKeyValue("CICRadarR", "MailServer") MailServer = RConfig.GetKeyValue("CICRadarR", "MailServer")
ADMailField = RConfig.GetKeyValue("CICRadarR", "ADMailField") ADMailField = RConfig.GetKeyValue("CICRadarR", "ADMailField")
End If End If
ADField = RConfig.GetKeyValue("CICRadarR", "ADField") ADField = RConfig.GetKeyValue("CICRadarR", "ADField")
If ADField.Length = 0 Then If ADField.Length = 0 Then
ServerLog("ERROR: ADField can not be empty") ServerLog("ERROR: ADField can not be empty")
ConfOk = False ConfOk = False
End If End If
If RConfig.GetKeyValue("CICRadarR", "EnableSMS") = "1" Then If RConfig.GetKeyValue("CICRadarR", "EnableSMS") = "1" Then
EnableSMS = True EnableSMS = True
ModemType = RConfig.GetKeyValue("CICRadarR", "USELOCALMODEM") ModemType = RConfig.GetKeyValue("CICRadarR", "USELOCALMODEM")
Select Case ModemType Select Case ModemType
Case "0" Case "0"
Provider = RConfig.GetKeyValue("CICRadarR", "Provider") Provider = RConfig.GetKeyValue("CICRadarR", "Provider")
If Provider.Length = 0 Then If Provider.Length = 0 Then
ServerLog("ERROR: Provider can not be empty") ServerLog("ERROR: Provider can not be empty")
ConfOk = False ConfOk = False
End If End If
Case "1" Case "1"
ComPort = RConfig.GetKeyValue("CICRadarR", "COMPORT") ComPort = RConfig.GetKeyValue("CICRadarR", "COMPORT")
If ComPort.Length = 0 Then If ComPort.Length = 0 Then
ServerLog("ERROR: ComPort can not be empty") ServerLog("ERROR: ComPort can not be empty")
ConfOk = False ConfOk = False
End If End If
SmsC = RConfig.GetKeyValue("CICRadarR", "SMSC") SmsC = RConfig.GetKeyValue("CICRadarR", "SMSC")
If SmsC.Length = 0 Then If SmsC.Length = 0 Then
ServerLog("ERROR: SMSC can not be empty. See http://smsclist.com/downloads/default.txt for valid values") ServerLog("ERROR: SMSC can not be empty. See http://smsclist.com/downloads/default.txt for valid values")
ConfOk = False ConfOk = False
End If End If
Case Else Case Else
ServerLog("ERROR: USELOCALMODEM contain invalid configuration. Correct value are 1 or 0") ServerLog("ERROR: USELOCALMODEM contain invalid configuration. Correct value are 1 or 0")
ConfOk = False ConfOk = False
End Select End Select
End If End If
End If End If
Dim ClientList As String = "" Dim ClientList As String = ""
ClientList = RConfig.GetKeyValue("CICRadarR", "ClientList") ClientList = RConfig.GetKeyValue("CICRadarR", "ClientList")
Dim ClientArray() As String Dim ClientArray() As String
ClientArray = Split(ClientList, ",") ClientArray = Split(ClientList, ",")
For i As Integer = 0 To ClientArray.Length - 1 For i As Integer = 0 To ClientArray.Length - 1
ServerLog("Loading Shared Secret for Client: " & ClientArray(i)) ServerLog("Loading Shared Secret for Client: " & ClientArray(i))
clientHash.Add(ClientArray(i), EncDec.Decrypt(RConfig.GetKeyValue("Clients", ClientArray(i)), encCode)) clientHash.Add(ClientArray(i), EncDec.Decrypt(RConfig.GetKeyValue("Clients", ClientArray(i)), encCode))
Next Next
If ConfOk = True Then If ConfOk = True Then
ServerLog("Loading Configuration...OK") ServerLog("Loading Configuration...OK")
Else Else
ServerLog("Loading Configuration...FAILED") ServerLog("Loading Configuration...FAILED")
End If End If
Catch Catch
ServerLog("ERROR: Missing CICRadarR.ini from startup path or CICRadarR.ini contains invalid configuration") ServerLog("ERROR: Missing CICRadarR.ini from startup path or CICRadarR.ini contains invalid configuration")
ServerLog("Loading Configuration...FAILED") ServerLog("Loading Configuration...FAILED")
End End
End Try End Try
End Sub End Sub
Public Function ApplicationPath() As String Public Function ApplicationPath() As String
Return Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location) Return Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
End Function End Function
Public Shared Function SendSMS(ByVal number As String, ByVal passcode As String) As String Public Shared Function SendSMS(ByVal number As String, ByVal passcode As String) As String
' test if using online sms provider or local modem ' test if using online sms provider or local modem
If ModemType = 1 Then ' local modem If ModemType = 1 Then ' local modem
Dim modem As New SmsClass(ComPort) Dim modem As New SmsClass(ComPort)
modem.Opens() modem.Opens()
modem.sendSms(number, passcode, SmsC) modem.sendSms(number, passcode, SmsC)
modem.Closes() modem.Closes()
modem = Nothing modem = Nothing
Return "Ok" Return "Ok"
Else Else
Dim baseurl As String = Provider.Split("?")(0) Dim baseurl As String = Provider.Split("?")(0)
Dim client As New System.Net.WebClient() Dim client As New System.Net.WebClient()
' Add a user agent header in case the requested URI contains a query. ' Add a user agent header in case the requested URI contains a query.
client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR1.0.3705;)") client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR1.0.3705;)")
Dim parameters As String = Provider.Split("?")(1) Dim parameters As String = Provider.Split("?")(1)
Dim pary As String() = parameters.Split("&") Dim pary As String() = parameters.Split("&")
For i As Integer = 0 To pary.Length - 1 For i As Integer = 0 To pary.Length - 1
If pary(i).IndexOf("***TEXTMESSAGE***") > 0 Then If pary(i).IndexOf("***TEXTMESSAGE***") > 0 Then
Dim qpar As String() = pary(i).Split("=") Dim qpar As String() = pary(i).Split("=")
client.QueryString.Add(qpar(0), passcode) client.QueryString.Add(qpar(0), passcode)
ElseIf pary(i).IndexOf("***NUMBER***") > 0 Then ElseIf pary(i).IndexOf("***NUMBER***") > 0 Then
Dim qpar As String() = pary(i).Split("=") Dim qpar As String() = pary(i).Split("=")
client.QueryString.Add(qpar(0), number) client.QueryString.Add(qpar(0), number)
Else Else
Dim qpar As String() = pary(i).Split("=") Dim qpar As String() = pary(i).Split("=")
client.QueryString.Add(qpar(0), qpar(1)) client.QueryString.Add(qpar(0), qpar(1))
End If End If
Next Next
Dim data As Stream = client.OpenRead(baseurl) Dim data As Stream = client.OpenRead(baseurl)
Dim reader As New StreamReader(data) Dim reader As New StreamReader(data)
Dim s As String = reader.ReadToEnd() Dim s As String = reader.ReadToEnd()
data.Close() data.Close()
reader.Close() reader.Close()
Return (s) Return (s)
End If End If
End Function End Function
Public Shared Function SendEmail(email As String, passcode As String) As String Public Shared Function SendEmail(email As String, passcode As String) As String
Dim mail As New MailMessage() Dim mail As New MailMessage()
mail.To.Add(email) mail.To.Add(email)
mail.From = New MailAddress(SenderEmail) mail.From = New MailAddress(SenderEmail)
mail.Subject = "Token: " & passcode mail.Subject = "Token: " & passcode
mail.Body = "Subject contains the token code to login to you site" mail.Body = "Subject contains the token code to login to you site"
mail.IsBodyHtml = False mail.IsBodyHtml = False
Dim smtp As New SmtpClient(MailServer) Dim smtp As New SmtpClient(MailServer)
Try Try
smtp.Send(mail) smtp.Send(mail)
If DEBUG = True Then If DEBUG = True Then
AccessLog(Now & ": Mail send to: " & email) AccessLog(Now & ": Mail send to: " & email)
End If End If
Return "SEND" Return "SEND"
Catch e As InvalidCastException Catch e As InvalidCastException
If DEBUG = True Then If DEBUG = True Then
AccessLog(Now & " : Debug: " & e.Message) AccessLog(Now & " : Debug: " & e.Message)
AccessLog(Now & " : Unable to send mail to: " & email & " ## Check that MAILSERVER and SENDEREMAIL are configured correctly in smscode.conf. Also check that your Webinterface server is allowed to relay through the mail server specified") AccessLog(Now & " : Unable to send mail to: " & email & " ## Check that MAILSERVER and SENDEREMAIL are configured correctly in smscode.conf. Also check that your Webinterface server is allowed to relay through the mail server specified")
End If End If
Return "FAILED" Return "FAILED"
End Try End Try
End Function End Function
Private Sub TimerCleanUpHash_Elapsed(sender As System.Object, e As System.Timers.ElapsedEventArgs) Handles TimerCleanUpHash.Elapsed Private Sub TimerCleanUpHash_Elapsed(sender As System.Object, e As System.Timers.ElapsedEventArgs) Handles TimerCleanUpHash.Elapsed
' Clean Session and Launch hash for TSGW ' Clean Session and Launch hash for TSGW
Try Try
Dim Item As DictionaryEntry Dim Item As DictionaryEntry
For Each Item In TSGWSessionIdTimeStampHash For Each Item In TSGWSessionIdTimeStampHash
Dim hTime As DateTime = DirectCast(Item.Value, DateTime) Dim hTime As DateTime = DirectCast(Item.Value, DateTime)
Dim tValid = DateDiff(DateInterval.Minute, hTime, Now) Dim tValid = DateDiff(DateInterval.Minute, hTime, Now)
If tValid >= SessionTimeOut Then If tValid >= SessionTimeOut Then
TSGWSessionIdTimeStampHash.Remove(Item.Key) TSGWSessionIdTimeStampHash.Remove(Item.Key)
If TSGWSessionIdHash.Contains(Item.Key) Then If TSGWSessionIdHash.Contains(Item.Key) Then
TSGWSessionIdHash.Remove(Item.Key) TSGWSessionIdHash.Remove(Item.Key)
End If End If
End If End If
Next Next
For Each Item In TSGWLaunchIdTimeStampHash For Each Item In TSGWLaunchIdTimeStampHash
Dim hTime As DateTime = DirectCast(Item.Value, DateTime) Dim hTime As DateTime = DirectCast(Item.Value, DateTime)
Dim tValid = DateDiff(DateInterval.Second, hTime, Now) Dim tValid = DateDiff(DateInterval.Second, hTime, Now)
If tValid >= LaunchTimeOut Then If tValid >= LaunchTimeOut Then
TSGWLaunchIdTimeStampHash.Remove(Item.Key) TSGWLaunchIdTimeStampHash.Remove(Item.Key)
End If End If
Next Next
Catch Catch
End Try End Try
End Sub End Sub
End Class End Class

View file

@ -1,165 +1,165 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform> <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion> <ProductVersion>
</ProductVersion> </ProductVersion>
<SchemaVersion> <SchemaVersion>
</SchemaVersion> </SchemaVersion>
<ProjectGuid>{04C6C533-9FEA-41B2-B554-A166C7C7FE32}</ProjectGuid> <ProjectGuid>{04C6C533-9FEA-41B2-B554-A166C7C7FE32}</ProjectGuid>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<StartupObject>Sub Main</StartupObject> <StartupObject>Sub Main</StartupObject>
<RootNamespace>CICRadarR</RootNamespace> <RootNamespace>CICRadarR</RootNamespace>
<AssemblyName>CICRadarR</AssemblyName> <AssemblyName>CICRadarR</AssemblyName>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<MyType>Console</MyType> <MyType>Console</MyType>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile> <TargetFrameworkProfile>Client</TargetFrameworkProfile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<DefineDebug>true</DefineDebug> <DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace> <DefineTrace>true</DefineTrace>
<OutputPath>bin\Debug\</OutputPath> <OutputPath>bin\Debug\</OutputPath>
<DocumentationFile>CICRadarR.xml</DocumentationFile> <DocumentationFile>CICRadarR.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<DefineDebug>false</DefineDebug> <DefineDebug>false</DefineDebug>
<DefineTrace>true</DefineTrace> <DefineTrace>true</DefineTrace>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath> <OutputPath>bin\Release\</OutputPath>
<DocumentationFile>CICRadarR.xml</DocumentationFile> <DocumentationFile>CICRadarR.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn> <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<OptionExplicit>On</OptionExplicit> <OptionExplicit>On</OptionExplicit>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<OptionCompare>Binary</OptionCompare> <OptionCompare>Binary</OptionCompare>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<OptionStrict>Off</OptionStrict> <OptionStrict>Off</OptionStrict>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<OptionInfer>On</OptionInfer> <OptionInfer>On</OptionInfer>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<ApplicationManifest>My Project\app.manifest</ApplicationManifest> <ApplicationManifest>My Project\app.manifest</ApplicationManifest>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration.Install" /> <Reference Include="System.Configuration.Install" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Deployment" /> <Reference Include="System.Deployment" />
<Reference Include="System.DirectoryServices" /> <Reference Include="System.DirectoryServices" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.ServiceProcess" /> <Reference Include="System.ServiceProcess" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Import Include="Microsoft.VisualBasic" /> <Import Include="Microsoft.VisualBasic" />
<Import Include="System" /> <Import Include="System" />
<Import Include="System.Collections" /> <Import Include="System.Collections" />
<Import Include="System.Collections.Generic" /> <Import Include="System.Collections.Generic" />
<Import Include="System.Data" /> <Import Include="System.Data" />
<Import Include="System.Diagnostics" /> <Import Include="System.Diagnostics" />
<Import Include="System.Linq" /> <Import Include="System.Linq" />
<Import Include="System.Xml.Linq" /> <Import Include="System.Xml.Linq" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="exceptions\MissingRadiusSecret.vb" /> <Compile Include="exceptions\MissingRadiusSecret.vb" />
<Compile Include="exceptions\MissingUser.vb" /> <Compile Include="exceptions\MissingUser.vb" />
<Compile Include="handlers\CitrixHandler.vb" /> <Compile Include="handlers\CitrixHandler.vb" />
<Compile Include="handlers\RDSHandler.vb" /> <Compile Include="handlers\RDSHandler.vb" />
<Compile Include="Crypto.vb" /> <Compile Include="Crypto.vb" />
<Compile Include="IniFileVb.vb" /> <Compile Include="IniFileVb.vb" />
<Compile Include="Log.vb" /> <Compile Include="Log.vb" />
<Compile Include="My Project\Application.Designer.vb"> <Compile Include="My Project\Application.Designer.vb">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Application.myapp</DependentUpon> <DependentUpon>Application.myapp</DependentUpon>
</Compile> </Compile>
<Compile Include="CICRadarR.vb"> <Compile Include="RDSFactor.vb">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="CICRadarR.Designer.vb"> <Compile Include="RDSFactor.Designer.vb">
<DependentUpon>CICRadarR.vb</DependentUpon> <DependentUpon>RDSFactor.vb</DependentUpon>
</Compile> </Compile>
<Compile Include="My Project\AssemblyInfo.vb" /> <Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Resources.Designer.vb"> <Compile Include="My Project\Resources.Designer.vb">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DesignTime>True</DesignTime> <DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon> <DependentUpon>Resources.resx</DependentUpon>
</Compile> </Compile>
<Compile Include="My Project\Settings.Designer.vb"> <Compile Include="My Project\Settings.Designer.vb">
<AutoGen>True</AutoGen> <AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile> </Compile>
<Compile Include="ProjectInstaller.Designer.vb"> <Compile Include="ProjectInstaller.Designer.vb">
<DependentUpon>ProjectInstaller.vb</DependentUpon> <DependentUpon>ProjectInstaller.vb</DependentUpon>
</Compile> </Compile>
<Compile Include="ProjectInstaller.vb"> <Compile Include="ProjectInstaller.vb">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
<Compile Include="SmsClass.vb" /> <Compile Include="SmsClass.vb" />
<Compile Include="TestService.Designer.vb"> <Compile Include="TestService.Designer.vb">
<DependentUpon>TestService.vb</DependentUpon> <DependentUpon>TestService.vb</DependentUpon>
</Compile> </Compile>
<Compile Include="TestService.vb"> <Compile Include="TestService.vb">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="CICRadarR.resx"> <EmbeddedResource Include="RDSFactor.resx">
<DependentUpon>CICRadarR.vb</DependentUpon> <DependentUpon>RDSFactor.vb</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx"> <EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator> <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput> <LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace> <CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="ProjectInstaller.resx"> <EmbeddedResource Include="ProjectInstaller.resx">
<DependentUpon>ProjectInstaller.vb</DependentUpon> <DependentUpon>ProjectInstaller.vb</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="TestService.resx"> <EmbeddedResource Include="TestService.resx">
<DependentUpon>TestService.vb</DependentUpon> <DependentUpon>TestService.vb</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="My Project\app.manifest" /> <None Include="My Project\app.manifest" />
<None Include="My Project\Application.myapp"> <None Include="My Project\Application.myapp">
<Generator>MyApplicationCodeGenerator</Generator> <Generator>MyApplicationCodeGenerator</Generator>
<LastGenOutput>Application.Designer.vb</LastGenOutput> <LastGenOutput>Application.Designer.vb</LastGenOutput>
</None> </None>
<None Include="My Project\Settings.settings"> <None Include="My Project\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>
<CustomToolNamespace>My</CustomToolNamespace> <CustomToolNamespace>My</CustomToolNamespace>
<LastGenOutput>Settings.Designer.vb</LastGenOutput> <LastGenOutput>Settings.Designer.vb</LastGenOutput>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\radar-radius\RADAR\RADAR.vbproj"> <ProjectReference Include="..\radar-radius\RADAR\RADAR.vbproj">
<Project>{3ab08a4e-c4fa-4571-a5d4-32bba807c31d}</Project> <Project>{3ab08a4e-c4fa-4571-a5d4-32bba807c31d}</Project>
<Name>RADAR</Name> <Name>RADAR</Name>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>

View file

@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project> </Project>

View file

@ -2,7 +2,7 @@
Public Class TestService Public Class TestService
Private Radius_Service As New CICRadarR Private Radius_Service As New RDSFactor
Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
btnStart.Enabled = False btnStart.Enabled = False
Call Radius_Service.OnstartTest() Call Radius_Service.OnstartTest()

View file

@ -17,7 +17,7 @@ Public Class CitrixHandler
' and drop other requests silently ... ' and drop other requests silently ...
If packet.Code <> RadiusPacketCode.AccessRequest Then If packet.Code <> RadiusPacketCode.AccessRequest Then
CICRadarR.AccessLog("Not a valid radius packet.. Drop!") RDSFactor.AccessLog("Not a valid radius packet.. Drop!")
Exit Sub Exit Sub
End If End If
@ -36,11 +36,11 @@ Public Class CitrixHandler
' will return Nothing. ' will return Nothing.
If username Is Nothing Then If username Is Nothing Then
' Technically, this case is against RFC, so ... drop. ' Technically, this case is against RFC, so ... drop.
CICRadarR.AccessLog("Not a valid radius packet.. No username pressent.. Drop!") RDSFactor.AccessLog("Not a valid radius packet.. No username pressent.. Drop!")
Exit Sub Exit Sub
End If End If
CICRadarR.AccessLog("Processing packet for user: " & username.ToString) RDSFactor.AccessLog("Processing packet for user: " & username.ToString)
'If packetHash.ContainsKey(username.GetString & "_" & pass.GetString) Then 'If packetHash.ContainsKey(username.GetString & "_" & pass.GetString) Then
' Exit Sub ' Exit Sub
@ -49,27 +49,27 @@ Public Class CitrixHandler
Dim existState As Boolean = packet.Attributes.AttributeExists(RadiusAttributeType.State) Dim existState As Boolean = packet.Attributes.AttributeExists(RadiusAttributeType.State)
CICRadarR.AccessLog("Packet contains a state attribute? State=" & existState.ToString) RDSFactor.AccessLog("Packet contains a state attribute? State=" & existState.ToString)
If existState = True Then ' Ok we have at packet with the State attribute set. Check if we can identify the authtentication packet. If existState = True Then ' Ok we have at packet with the State attribute set. Check if we can identify the authtentication packet.
Dim state As String = packet.Attributes.GetFirstAttribute(RadiusAttributeType.State).ToString Dim state As String = packet.Attributes.GetFirstAttribute(RadiusAttributeType.State).ToString
CICRadarR.AccessLog("Packet contains a state attribute State=" & state) RDSFactor.AccessLog("Packet contains a state attribute State=" & state)
Dim UserDomain As String = "" Dim UserDomain As String = ""
'lets see if user login using upd or UPN name 'lets see if user login using upd or UPN name
Dim sUserName As String = username.ToString Dim sUserName As String = username.ToString
Dim sPassword As String = packet.UserPassword Dim sPassword As String = packet.UserPassword
CICRadarR.AccessLog("SMSToken supplied by user: " & sUserName) RDSFactor.AccessLog("SMSToken supplied by user: " & sUserName)
sid = "" sid = ""
If InStr(sUserName, "@") > 0 Then 'UPN If InStr(sUserName, "@") > 0 Then 'UPN
UserDomain = sUserName UserDomain = sUserName
Else 'UPD Else 'UPD
'read domain from Hashtable 'read domain from Hashtable
UserDomain = CICRadarR.NetBiosDomain & "\" & sUserName UserDomain = RDSFactor.NetBiosDomain & "\" & sUserName
End If End If
sid = EncDec.Encrypt(UserDomain & "_" & packet.UserPassword, CICRadarR.encCode) sid = EncDec.Encrypt(UserDomain & "_" & packet.UserPassword, RDSFactor.encCode)
CICRadarR.AccessLog("Checking for userHash " & sid) RDSFactor.AccessLog("Checking for userHash " & sid)
If sid = state Then If sid = state Then
packet.AcceptAccessRequest() packet.AcceptAccessRequest()
Else Else
@ -97,15 +97,15 @@ Public Class CitrixHandler
UserDomain = sUserName UserDomain = sUserName
Else 'UPD Else 'UPD
'read domain from Hashtable 'read domain from Hashtable
UserDomain = CICRadarR.NetBiosDomain & "\" & sUserName UserDomain = RDSFactor.NetBiosDomain & "\" & sUserName
End If End If
CICRadarR.AccessLog("User " & UserDomain & " is trying to log in ...") RDSFactor.AccessLog("User " & UserDomain & " is trying to log in ...")
Try Try
Dim dirEntry As New DirectoryEntry("LDAP://" & CICRadarR.LDAPDomain, UserDomain, sPassword) Dim dirEntry As New DirectoryEntry("LDAP://" & RDSFactor.LDAPDomain, UserDomain, sPassword)
Dim obj As Object = dirEntry.NativeObject Dim obj As Object = dirEntry.NativeObject
Dim search As New DirectorySearcher(dirEntry) Dim search As New DirectorySearcher(dirEntry)
@ -118,17 +118,17 @@ Public Class CitrixHandler
'Load the Properties we need from AD 'Load the Properties we need from AD
search.PropertiesToLoad.Add("distinguishedName") search.PropertiesToLoad.Add("distinguishedName")
'search.PropertiesToLoad.Add("primaryTelexNumber") 'search.PropertiesToLoad.Add("primaryTelexNumber")
If CICRadarR.EnableOTP = True Then If RDSFactor.EnableOTP = True Then
If CICRadarR.EnableEmail = True Then If RDSFactor.EnableEmail = True Then
search.PropertiesToLoad.Add(CICRadarR.ADMailField) search.PropertiesToLoad.Add(RDSFactor.ADMailField)
End If End If
If CICRadarR.EnableSMS = True Then If RDSFactor.EnableSMS = True Then
search.PropertiesToLoad.Add(CICRadarR.ADField) search.PropertiesToLoad.Add(RDSFactor.ADField)
End If End If
End If End If
' Time to find out if user entered the correct username and pasword ' Time to find out if user entered the correct username and pasword
CICRadarR.AccessLog("Trying to authenticate user agains Active Directory using te following parameters: " & "LDAPPAth: " & "LDAP://" & CICRadarR.LDAPDomain & ", Username: " & UserDomain & ", Password: " & sPassword) RDSFactor.AccessLog("Trying to authenticate user agains Active Directory using te following parameters: " & "LDAPPAth: " & "LDAP://" & RDSFactor.LDAPDomain & ", Username: " & UserDomain & ", Password: " & sPassword)
Dim result As SearchResult = search.FindOne() Dim result As SearchResult = search.FindOne()
'Get the setting form AD. Yes we uses the field primaryTelexNumber, for who the f... still users telex. (I bet half the people reading this code don't even know what a telex is!) 'Get the setting form AD. Yes we uses the field primaryTelexNumber, for who the f... still users telex. (I bet half the people reading this code don't even know what a telex is!)
@ -137,43 +137,43 @@ Public Class CitrixHandler
'Dim userLdap As String = "LDAP://" & LDAPPath & "/" & result.Properties("distinguishedName")(0) 'Dim userLdap As String = "LDAP://" & LDAPPath & "/" & result.Properties("distinguishedName")(0)
'Dim userEntry As New DirectoryEntry(userLdap, UserDomain, sPassword) 'Dim userEntry As New DirectoryEntry(userLdap, UserDomain, sPassword)
If CICRadarR.EnableOTP = True Then If RDSFactor.EnableOTP = True Then
smsCode = CICRadarR.GenerateCode() smsCode = RDSFactor.GenerateCode()
' REMEMBER to put at check for empty phone string ' REMEMBER to put at check for empty phone string
If CICRadarR.EnableEmail = True Then If RDSFactor.EnableEmail = True Then
Try Try
UserEmail = DirectCast(result.Properties(CICRadarR.ADMailField)(0), String) UserEmail = DirectCast(result.Properties(RDSFactor.ADMailField)(0), String)
If UserEmail.Trim.Length = 0 Or InStr(UserEmail, "@") = 0 Then If UserEmail.Trim.Length = 0 Or InStr(UserEmail, "@") = 0 Then
success = False success = False
CICRadarR.AccessLog("Unable to find correct email for user " & UserDomain) RDSFactor.AccessLog("Unable to find correct email for user " & UserDomain)
Else Else
success = True success = True
End If End If
Catch Catch
CICRadarR.AccessLog("Unable to find correct email for user " & UserDomain) RDSFactor.AccessLog("Unable to find correct email for user " & UserDomain)
success = False success = False
End Try End Try
End If End If
If CICRadarR.EnableSMS = True Then If RDSFactor.EnableSMS = True Then
Try Try
mobile = DirectCast(result.Properties(CICRadarR.ADField)(0), String) mobile = DirectCast(result.Properties(RDSFactor.ADField)(0), String)
mobile = Replace(mobile, "+", "") mobile = Replace(mobile, "+", "")
If mobile.Trim.Length = 0 Then If mobile.Trim.Length = 0 Then
success = False success = False
CICRadarR.AccessLog("Unable to find correct phone number for user " & UserDomain) RDSFactor.AccessLog("Unable to find correct phone number for user " & UserDomain)
Else Else
success = True success = True
End If End If
Catch Catch
CICRadarR.AccessLog("Unable to find correct phone number for user " & UserDomain) RDSFactor.AccessLog("Unable to find correct phone number for user " & UserDomain)
success = False success = False
End Try End Try
End If End If
sid = EncDec.Encrypt(UserDomain & "_" & smsCode, CICRadarR.encCode) 'generate unique code sid = EncDec.Encrypt(UserDomain & "_" & smsCode, RDSFactor.encCode) 'generate unique code
End If End If
' sid = UserDomain & "_" & smsCode ' sid = UserDomain & "_" & smsCode
'userEntry.Properties("primaryTelexNumber").Value = aCode(0) & "/" & smsCode & "/" & aCode(2) & "/" & aCode(3) 'userEntry.Properties("primaryTelexNumber").Value = aCode(0) & "/" & smsCode & "/" & aCode(2) & "/" & aCode(3)
@ -199,7 +199,7 @@ Public Class CitrixHandler
success = False success = False
End If End If
Catch Catch
CICRadarR.AccessLog("Failed to authenticate user agains Active Directory using the following parameters: " & "LDAPPAth: " & "LDAP://" & CICRadarR.LDAPDomain & ", Username: " & UserDomain & ", Password: " & sPassword) RDSFactor.AccessLog("Failed to authenticate user agains Active Directory using the following parameters: " & "LDAPPAth: " & "LDAP://" & RDSFactor.LDAPDomain & ", Username: " & UserDomain & ", Password: " & sPassword)
success = False success = False
End Try End Try
@ -207,8 +207,8 @@ Public Class CitrixHandler
Dim attributes As New RADIUSAttributes Dim attributes As New RADIUSAttributes
If success Then ' Yay! Someone guess the password ... If success Then ' Yay! Someone guess the password ...
CICRadarR.AccessLog("User " & UserDomain & " authenticated agains Active Directory") RDSFactor.AccessLog("User " & UserDomain & " authenticated agains Active Directory")
If CICRadarR.EnableOTP = True Then If RDSFactor.EnableOTP = True Then
Dim attr As New RADIUSAttribute(RadiusAttributeType.ReplyMessage, "SMS Token") Dim attr As New RADIUSAttribute(RadiusAttributeType.ReplyMessage, "SMS Token")
attributes.Add(attr) attributes.Add(attr)
Dim state As New RADIUSAttribute(RadiusAttributeType.State, sid) Dim state As New RADIUSAttribute(RadiusAttributeType.State, sid)
@ -219,22 +219,22 @@ Public Class CitrixHandler
packet.Identifier, attributes, _ packet.Identifier, attributes, _
packet.EndPoint), _ packet.EndPoint), _
packet.Authenticator) packet.Authenticator)
If CICRadarR.EnableSMS = True Then If RDSFactor.EnableSMS = True Then
CICRadarR.AccessLog("Sending access token: " & smsCode & " to phonenumber " & mobile) RDSFactor.AccessLog("Sending access token: " & smsCode & " to phonenumber " & mobile)
Call CICRadarR.SendSMS(mobile, smsCode) Call RDSFactor.SendSMS(mobile, smsCode)
End If End If
If CICRadarR.EnableEmail = True Then If RDSFactor.EnableEmail = True Then
CICRadarR.AccessLog("Sending access token: " & smsCode & " to email " & UserEmail) RDSFactor.AccessLog("Sending access token: " & smsCode & " to email " & UserEmail)
Call CICRadarR.SendEmail(UserEmail, smsCode) Call RDSFactor.SendEmail(UserEmail, smsCode)
End If End If
Else Else
CICRadarR.AccessLog("One time Password not enabled, so we let the user in") RDSFactor.AccessLog("One time Password not enabled, so we let the user in")
packet.AcceptAccessRequest() packet.AcceptAccessRequest()
End If End If
' packetHash.Remove(username.GetString & "_" & pass.GetString) ' packetHash.Remove(username.GetString & "_" & pass.GetString)
Else ' Wrong username / password ... Else ' Wrong username / password ...
CICRadarR.AccessLog("User " & UserDomain & " failed to authenticate against Active Directory") RDSFactor.AccessLog("User " & UserDomain & " failed to authenticate against Active Directory")
Dim pk As New RADIUSPacket(RadiusPacketCode.AccessReject, packet.Identifier, Nothing, packet.EndPoint) Dim pk As New RADIUSPacket(RadiusPacketCode.AccessReject, packet.Identifier, Nothing, packet.EndPoint)
server.SendAsResponse(pk, packet.Authenticator) server.SendAsResponse(pk, packet.Authenticator)
' FYI ... if no additional attributes need to be added ' FYI ... if no additional attributes need to be added

View file

@ -75,7 +75,7 @@ Public Class RDSHandler
' NOTE: Requests contain the session GUID in the password attribute ' NOTE: Requests contain the session GUID in the password attribute
' of the packet. ' of the packet.
Public Sub ProcessAppLaunchRequest() Public Sub ProcessAppLaunchRequest()
CICRadarR.AccessLog("ProcessAppLaunchRequest") RDSFactor.AccessLog("ProcessAppLaunchRequest")
' When the packet is an AppLaunchRequest the password attribute contains the session id! ' When the packet is an AppLaunchRequest the password attribute contains the session id!
Dim packetSessionId = mPassword Dim packetSessionId = mPassword
@ -83,15 +83,15 @@ Public Class RDSHandler
Dim sessionTimestamp = sessionTimestamps(mUsername) Dim sessionTimestamp = sessionTimestamps(mUsername)
If storedSessionId = Nothing Or sessionTimestamp = Nothing Then If storedSessionId = Nothing Or sessionTimestamp = Nothing Then
CICRadarR.AccessLog("User has no session. MUST re-authenticate!") RDSFactor.AccessLog("User has no session. MUST re-authenticate!")
mPacket.RejectAccessRequest() mPacket.RejectAccessRequest()
Exit Sub Exit Sub
End If End If
If packetSessionId = storedSessionId Then If packetSessionId = storedSessionId Then
Dim minsSinceLastActivity = DateDiff(DateInterval.Minute, sessionTimestamp, Now) Dim minsSinceLastActivity = DateDiff(DateInterval.Minute, sessionTimestamp, Now)
If minsSinceLastActivity < CICRadarR.SessionTimeOut Then If minsSinceLastActivity < RDSFactor.SessionTimeOut Then
CICRadarR.AccessLog("Opening window for: " & mUsername) RDSFactor.AccessLog("Opening window for: " & mUsername)
' Pro-long session ' Pro-long session
sessionTimestamps(storedSessionId) = Now sessionTimestamps(storedSessionId) = Now
' Open launch window ' Open launch window
@ -99,12 +99,12 @@ Public Class RDSHandler
mPacket.AcceptAccessRequest() mPacket.AcceptAccessRequest()
Exit Sub Exit Sub
Else Else
CICRadarR.AccessLog("Session timed out -- User MUST re-authenticate") RDSFactor.AccessLog("Session timed out -- User MUST re-authenticate")
userSessions.Remove(mUsername) userSessions.Remove(mUsername)
sessionTimestamps.Remove(mUsername) sessionTimestamps.Remove(mUsername)
End If End If
Else Else
CICRadarR.AccessLog("Stored session id didn't match packet session id!") RDSFactor.AccessLog("Stored session id didn't match packet session id!")
End If End If
mPacket.RejectAccessRequest() mPacket.RejectAccessRequest()
@ -122,14 +122,14 @@ Public Class RDSHandler
' TODO: Fix race-condition RD Web vs. Gateway. Don't start RDP client in RD Web ' TODO: Fix race-condition RD Web vs. Gateway. Don't start RDP client in RD Web
' before ensuring App Launch request was successful ' before ensuring App Launch request was successful
Public Sub ProcessGatewayRequest() Public Sub ProcessGatewayRequest()
CICRadarR.AccessLog("Gateway Request for user: " & mUsername) RDSFactor.AccessLog("Gateway Request for user: " & mUsername)
Dim sessionId = userSessions(mUsername) Dim sessionId = userSessions(mUsername)
Dim launchTimestamp = userLaunchTimestamps(mUsername) Dim launchTimestamp = userLaunchTimestamps(mUsername)
Dim attributes As New RADIUSAttributes Dim attributes As New RADIUSAttributes
If sessionId = Nothing Or launchTimestamp = Nothing Then If sessionId = Nothing Or launchTimestamp = Nothing Then
CICRadarR.AccessLog("User's has no launch window. User must re-authenticate") RDSFactor.AccessLog("User's has no launch window. User must re-authenticate")
mPacket.RejectAccessRequest() mPacket.RejectAccessRequest()
Exit Sub Exit Sub
End If End If
@ -141,11 +141,11 @@ Public Class RDSHandler
End If End If
Dim secondsSinceLaunch = DateDiff(DateInterval.Second, launchTimestamp, Now) Dim secondsSinceLaunch = DateDiff(DateInterval.Second, launchTimestamp, Now)
If secondsSinceLaunch < CICRadarR.LaunchTimeOut Then If secondsSinceLaunch < RDSFactor.LaunchTimeOut Then
CICRadarR.AccessLog("Allowing access through gateway for user: " & mUsername & " -- closing window") RDSFactor.AccessLog("Allowing access through gateway for user: " & mUsername & " -- closing window")
mPacket.AcceptAccessRequest(attributes) mPacket.AcceptAccessRequest(attributes)
Else Else
CICRadarR.AccessLog("Launch window has closed!") RDSFactor.AccessLog("Launch window has closed!")
End If End If
' close window ' close window
@ -160,24 +160,24 @@ Public Class RDSHandler
Exit Sub Exit Sub
End If End If
CICRadarR.AccessLog("ProcessAccessRequest") RDSFactor.AccessLog("ProcessAccessRequest")
Try Try
Dim ldapResult = Authenticate() Dim ldapResult = Authenticate()
If CICRadarR.EnableOTP Then If RDSFactor.EnableOTP Then
TwoFactorChallenge() TwoFactorChallenge()
Exit Sub Exit Sub
Else Else
Accept() Accept()
End If End If
Catch ex As Exception Catch ex As Exception
CICRadarR.AccessLog("Authentication failed. Sending reject. Error: " & ex.Message) RDSFactor.AccessLog("Authentication failed. Sending reject. Error: " & ex.Message)
mPacket.RejectAccessRequest() mPacket.RejectAccessRequest()
End Try End Try
End Sub End Sub
Private Sub Accept() Private Sub Accept()
CICRadarR.AccessLog("Accept") RDSFactor.AccessLog("Accept")
Dim sGUID As String = System.Guid.NewGuid.ToString() Dim sGUID As String = System.Guid.NewGuid.ToString()
userSessions(mUsername) = sGUID userSessions(mUsername) = sGUID
sessionTimestamps(mUsername) = Now sessionTimestamps(mUsername) = Now
@ -190,13 +190,13 @@ Public Class RDSHandler
End Sub End Sub
Private Sub ProcessChallengeResponse() Private Sub ProcessChallengeResponse()
CICRadarR.AccessLog("ProcessChallengeResponse") RDSFactor.AccessLog("ProcessChallengeResponse")
' When the packet is an Challange-Response the password attr. contains the token ' When the packet is an Challange-Response the password attr. contains the token
Dim challangeCode = mPassword Dim challangeCode = mPassword
Dim state = mPacket.Attributes.GetFirstAttribute(RadiusAttributeType.State) Dim state = mPacket.Attributes.GetFirstAttribute(RadiusAttributeType.State)
Dim sid = EncDec.Encrypt(mUsername & "_" & challangeCode, CICRadarR.encCode) Dim sid = EncDec.Encrypt(mUsername & "_" & challangeCode, RDSFactor.encCode)
If sid = state.ToString Then If sid = state.ToString Then
Accept() Accept()
Else Else
@ -205,19 +205,19 @@ Public Class RDSHandler
End Sub End Sub
Private Sub TwoFactorChallenge() Private Sub TwoFactorChallenge()
Dim code = CICRadarR.GenerateCode Dim code = RDSFactor.GenerateCode
Dim sid = EncDec.Encrypt(mUsername & "_" & code, CICRadarR.encCode) 'generate unique code Dim sid = EncDec.Encrypt(mUsername & "_" & code, RDSFactor.encCode) 'generate unique code
CICRadarR.AccessLog("Access Challange Code: " & code) RDSFactor.AccessLog("Access Challange Code: " & code)
userSidTokens(mUsername) = sid userSidTokens(mUsername) = sid
tokenTimestamps(mUsername) = Now tokenTimestamps(mUsername) = Now
If mUseSMSFactor Then If mUseSMSFactor Then
CICRadarR.AccessLog("TODO: Send SMS") RDSFactor.AccessLog("TODO: Send SMS")
End If End If
If mUseEmailFactor Then If mUseEmailFactor Then
CICRadarR.AccessLog("TODO: Send Email") RDSFactor.AccessLog("TODO: Send Email")
End If End If
Dim attributes As New RADIUSAttributes Dim attributes As New RADIUSAttributes
@ -233,9 +233,9 @@ Public Class RDSHandler
Private Function Authenticate() As System.DirectoryServices.SearchResult Private Function Authenticate() As System.DirectoryServices.SearchResult
Dim password As String = mPacket.UserPassword Dim password As String = mPacket.UserPassword
Dim ldapDomain As String = CICRadarR.LDAPDomain Dim ldapDomain As String = RDSFactor.LDAPDomain
CICRadarR.AccessLog("Authenticating: LDAPPAth: " & "LDAP://" & ldapDomain & ", Username: " & mUsername) RDSFactor.AccessLog("Authenticating: LDAPPAth: " & "LDAP://" & ldapDomain & ", Username: " & mUsername)
Dim dirEntry As New DirectoryEntry("LDAP://" & ldapDomain, mUsername, password) Dim dirEntry As New DirectoryEntry("LDAP://" & ldapDomain, mUsername, password)
Dim obj As Object = dirEntry.NativeObject Dim obj As Object = dirEntry.NativeObject
@ -248,15 +248,15 @@ Public Class RDSHandler
End If End If
search.PropertiesToLoad.Add("distinguishedName") search.PropertiesToLoad.Add("distinguishedName")
If CICRadarR.EnableOTP = True Then If RDSFactor.EnableOTP = True Then
search.PropertiesToLoad.Add(CICRadarR.ADField) search.PropertiesToLoad.Add(RDSFactor.ADField)
search.PropertiesToLoad.Add(CICRadarR.ADMailField) search.PropertiesToLoad.Add(RDSFactor.ADMailField)
End If End If
Dim result = search.FindOne() Dim result = search.FindOne()
If IsDBNull(result) Then If IsDBNull(result) Then
CICRadarR.AccessLog("Failed to authenticate with Active Directory") RDSFactor.AccessLog("Failed to authenticate with Active Directory")
Throw New MissingUser Throw New MissingUser
End If End If
@ -264,19 +264,19 @@ Public Class RDSHandler
End Function End Function
Private Function LdapGetNumber(result As SearchResult) As String Private Function LdapGetNumber(result As SearchResult) As String
Dim mobile = result.Properties(CICRadarR.ADField)(0) Dim mobile = result.Properties(RDSFactor.ADField)(0)
mobile = Replace(mobile, "+", "") mobile = Replace(mobile, "+", "")
If mobile.Trim.Length = 0 Then If mobile.Trim.Length = 0 Then
CICRadarR.AccessLog("Unable to find correct phone number for user " & mUsername) RDSFactor.AccessLog("Unable to find correct phone number for user " & mUsername)
End If End If
Return mobile Return mobile
End Function End Function
Private Function LdapGetEmail(result As SearchResult) As String Private Function LdapGetEmail(result As SearchResult) As String
Dim email = result.Properties(CICRadarR.ADMailField)(0) Dim email = result.Properties(RDSFactor.ADMailField)(0)
If InStr(email, "@") = 0 Then If InStr(email, "@") = 0 Then
CICRadarR.AccessLog("Unable to find correct email for user " & mUsername) RDSFactor.AccessLog("Unable to find correct email for user " & mUsername)
End If End If
Return email Return email
End Function End Function