mirror of
https://github.com/jakobadam/RDSFactor.git
synced 2025-06-13 07:54:33 +02:00
Rename CICRadarR -> RDSFactor
This commit is contained in:
parent
d296781847
commit
a29384d872
40 changed files with 810 additions and 810 deletions
|
@ -1,68 +1,68 @@
|
|||
Imports System.ServiceProcess
|
||||
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
Partial Class CICRadarR
|
||||
Inherits System.ServiceProcess.ServiceBase
|
||||
|
||||
'UserService overrides dispose to clean up the component list.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
Try
|
||||
If disposing AndAlso components IsNot Nothing Then
|
||||
components.Dispose()
|
||||
End If
|
||||
Finally
|
||||
MyBase.Dispose(disposing)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
' The main entry point for the process
|
||||
<MTAThread()> _
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
Shared Sub Main(ByVal args() As String)
|
||||
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
|
||||
|
||||
' More than one NT Service may run within the same process. To add
|
||||
' another service to this process, change the following line to
|
||||
' create a second service object. For example,
|
||||
'
|
||||
' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
|
||||
'
|
||||
Dim server = New CICRadarR()
|
||||
|
||||
If Environment.UserInteractive Then
|
||||
server.OnStart(args)
|
||||
Console.WriteLine("Type any character to exit")
|
||||
Console.Read()
|
||||
server.OnStop()
|
||||
Else
|
||||
ServicesToRun = New System.ServiceProcess.ServiceBase() {server}
|
||||
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Required by the Component Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
' NOTE: The following procedure is required by the Component Designer
|
||||
' It can be modified using the Component Designer.
|
||||
' Do not modify it using the code editor.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Me.TimerCleanUpHash = New System.Timers.Timer()
|
||||
CType(Me.TimerCleanUpHash, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
'
|
||||
'TimerCleanUpHash
|
||||
'
|
||||
Me.TimerCleanUpHash.Enabled = True
|
||||
Me.TimerCleanUpHash.Interval = 60000.0R
|
||||
'
|
||||
'CICRadarR
|
||||
'
|
||||
Me.ServiceName = "Service1"
|
||||
CType(Me.TimerCleanUpHash, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
|
||||
End Sub
|
||||
Friend WithEvents TimerCleanUpHash As System.Timers.Timer
|
||||
|
||||
End Class
|
||||
Imports System.ServiceProcess
|
||||
|
||||
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
|
||||
Partial Class RDSFactor
|
||||
Inherits System.ServiceProcess.ServiceBase
|
||||
|
||||
'UserService overrides dispose to clean up the component list.
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
|
||||
Try
|
||||
If disposing AndAlso components IsNot Nothing Then
|
||||
components.Dispose()
|
||||
End If
|
||||
Finally
|
||||
MyBase.Dispose(disposing)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
' The main entry point for the process
|
||||
<MTAThread()> _
|
||||
<System.Diagnostics.DebuggerNonUserCode()> _
|
||||
Shared Sub Main(ByVal args() As String)
|
||||
Dim ServicesToRun() As System.ServiceProcess.ServiceBase
|
||||
|
||||
' More than one NT Service may run within the same process. To add
|
||||
' another service to this process, change the following line to
|
||||
' create a second service object. For example,
|
||||
'
|
||||
' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService}
|
||||
'
|
||||
Dim server = New RDSFactor()
|
||||
|
||||
If Environment.UserInteractive Then
|
||||
server.OnStart(args)
|
||||
Console.WriteLine("Type any character to exit")
|
||||
Console.Read()
|
||||
server.OnStop()
|
||||
Else
|
||||
ServicesToRun = New System.ServiceProcess.ServiceBase() {server}
|
||||
System.ServiceProcess.ServiceBase.Run(ServicesToRun)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
'Required by the Component Designer
|
||||
Private components As System.ComponentModel.IContainer
|
||||
|
||||
' NOTE: The following procedure is required by the Component Designer
|
||||
' It can be modified using the Component Designer.
|
||||
' Do not modify it using the code editor.
|
||||
<System.Diagnostics.DebuggerStepThrough()> _
|
||||
Private Sub InitializeComponent()
|
||||
Me.TimerCleanUpHash = New System.Timers.Timer()
|
||||
CType(Me.TimerCleanUpHash, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
'
|
||||
'TimerCleanUpHash
|
||||
'
|
||||
Me.TimerCleanUpHash.Enabled = True
|
||||
Me.TimerCleanUpHash.Interval = 60000.0R
|
||||
'
|
||||
'CICRadarR
|
||||
'
|
||||
Me.ServiceName = "Service1"
|
||||
CType(Me.TimerCleanUpHash, System.ComponentModel.ISupportInitialize).EndInit()
|
||||
|
||||
End Sub
|
||||
Friend WithEvents TimerCleanUpHash As System.Timers.Timer
|
||||
|
||||
End Class
|
|
@ -1,126 +1,126 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, 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="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<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>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: 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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<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:sequence>
|
||||
<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="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="TimerCleanUpHash.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, 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="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<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>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: 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:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<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:sequence>
|
||||
<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="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="TimerCleanUpHash.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
</root>
|
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||
# Visual Studio Express 2013 for Windows Desktop
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
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
|
||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "RADAR", "..\radar-radius\RADAR\RADAR.vbproj", "{3AB08A4E-C4FA-4571-A5D4-32BBA807C31D}"
|
||||
EndProject
|
|
@ -1,377 +1,377 @@
|
|||
Imports System.DirectoryServices
|
||||
Imports System.IO
|
||||
Imports System.Reflection
|
||||
Imports CICRadarR.SMS
|
||||
Imports CICRadarR.LogFile
|
||||
Imports System.Security.Cryptography
|
||||
Imports System.Text
|
||||
Imports System
|
||||
Imports System.Net.Mail
|
||||
Imports RADAR
|
||||
|
||||
Public Class CICRadarR
|
||||
|
||||
Public Shared LDAPDomain As String = ""
|
||||
Public Shared ADField As String = ""
|
||||
Public Shared ADMailField As String = ""
|
||||
Public Shared EnableOTP As Boolean
|
||||
|
||||
' Shared key: used for challange encryption
|
||||
' TODO: Fix
|
||||
Public Shared encCode As String = "gewsyy#sjs2!"
|
||||
|
||||
Private Shared DEBUG As Boolean
|
||||
|
||||
Private Shared UserAccessLog As New LogWriter
|
||||
Private Shared Log As New LogWriter
|
||||
|
||||
Private secrets As NASAuthList
|
||||
Private radius1812 As RADIUSServer
|
||||
Private radius1645 As RADIUSServer
|
||||
Private userHash As New Hashtable
|
||||
Private packetHash As New Hashtable
|
||||
Private clientHash As New Hashtable
|
||||
|
||||
Public Shared NetBiosDomain As String = ""
|
||||
|
||||
Private Shared Provider As String = ""
|
||||
|
||||
|
||||
Private Shared ModemType As String = ""
|
||||
Private Shared ComPort As String = ""
|
||||
Private Shared SmsC As String = ""
|
||||
Private Shared MailServer As String = ""
|
||||
Private Shared SenderEmail As String = ""
|
||||
|
||||
Private TSGW As String = ""
|
||||
Private TSGWSessionIdHash As New Hashtable
|
||||
Private TSGWSessionIdTimeStampHash 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 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 LaunchTimeOut As Integer = 30 ' in seconds
|
||||
Public Shared EnableSMS As Boolean = False
|
||||
Public Shared EnableEmail As Boolean = False
|
||||
|
||||
Protected Overrides Sub OnStart(ByVal args() As String)
|
||||
|
||||
Log.filePath = ApplicationPath() & "\log.txt"
|
||||
UserAccessLog.filePath = ApplicationPath() & "\UserAccessLog.txt"
|
||||
|
||||
Log.WriteLog("---------------------------------------------------------------------------------------------------")
|
||||
ServerLog("Starting Service")
|
||||
ServerLog("Loading Configuration...")
|
||||
Call loadConfiguration()
|
||||
ServerLog("Starting Radius listner ports...")
|
||||
Call StartUpServer()
|
||||
End Sub
|
||||
|
||||
Public Sub OnstartTest()
|
||||
Log.filePath = ApplicationPath() & "\log.txt"
|
||||
UserAccessLog.filePath = ApplicationPath() & "\UserAccessLog.txt"
|
||||
|
||||
ServerLog("---------------------------------------------------------------------------------------------------")
|
||||
ServerLog("Starting Service")
|
||||
ServerLog("Loading Configuration...")
|
||||
Call loadConfiguration()
|
||||
ServerLog("Starting Radius listner ports...")
|
||||
Call StartUpServer()
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnStop()
|
||||
ServerLog("Stopping Radius listner ports...")
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub OnStopTest()
|
||||
ServerLog("Stopping Radius listner ports...")
|
||||
End Sub
|
||||
|
||||
Public Sub StartUpServer()
|
||||
|
||||
' First, let's load a list of RADIUS shared secrets
|
||||
' in a NASAuthList object (a glorified Dictionary, basically)
|
||||
secrets = New NASAuthList
|
||||
' Populate from DB, I suppose ...
|
||||
|
||||
For Each cl As DictionaryEntry In clientHash
|
||||
ServerLog("Adding Shared Secret to Radius Server")
|
||||
secrets.AddSharedSecret(cl.Key, cl.Value)
|
||||
Next
|
||||
' Then, we just create a RADIUS server ...
|
||||
Try
|
||||
radius1812 = New RADIUSServer(1812, AddressOf ProcessPacket1812, secrets)
|
||||
ServerLog("Starting Radius Server on Port 1812...OK")
|
||||
Catch
|
||||
ServerLog("Starting Radius Server on Port 1812...FAILED")
|
||||
End Try
|
||||
|
||||
Try
|
||||
radius1645 = New RADIUSServer(1645, AddressOf ProcessPacket1645, secrets)
|
||||
ServerLog("Starting Radius Server on Port 1645...OK")
|
||||
Catch
|
||||
ServerLog("Starting Radius Server on Port 1645...FAILED")
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
' Every valid RADIUS request generated by the server(s) we created earlier
|
||||
' will fire up the callback procedure. Invalid requests are dropped, per RFC.
|
||||
Private Sub ProcessPacket1812(ByVal packet As RADIUSPacket)
|
||||
'Console.WriteLine("packet " & Now)
|
||||
ProcessPacket(radius1812, packet)
|
||||
End Sub
|
||||
|
||||
Private Sub ProcessPacket1645(ByVal packet As RADIUSPacket)
|
||||
ProcessPacket(radius1645, packet)
|
||||
End Sub
|
||||
|
||||
Public Shared Sub AccessLog(ByVal message)
|
||||
If DEBUG = True Then
|
||||
UserAccessLog.WriteLog(Now & ": DEBUG: " & message)
|
||||
|
||||
' Also write to the console if not a service
|
||||
If Environment.UserInteractive Then
|
||||
Console.WriteLine(Now & ": DEBUG: " & message)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Shared Sub ServerLog(ByVal message)
|
||||
Log.WriteLog(Now & ":" & message)
|
||||
' Also write to the console if not a service
|
||||
If Environment.UserInteractive Then
|
||||
Console.WriteLine(Now & message)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ProcessPacket(ByVal server As RADIUSServer, ByVal packet As RADIUSPacket)
|
||||
If Not packet.IsValid Then
|
||||
Console.WriteLine("Packet is not valid. Discarding.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim handler
|
||||
If TSGW = "1" Then
|
||||
handler = New RDSHandler(packet)
|
||||
Else
|
||||
handler = New CitrixHandler(packet)
|
||||
End If
|
||||
|
||||
handler.ProcessRequest()
|
||||
End Sub
|
||||
|
||||
Public Shared Function GenerateCode() As String
|
||||
Dim dummy As Integer = 0
|
||||
|
||||
Dim ordRand As New System.Random()
|
||||
Dim temp As New System.Collections.ArrayList()
|
||||
While temp.Count < 6
|
||||
dummy = ordRand.[Next](1, 9)
|
||||
If Not temp.Contains(dummy) Then
|
||||
temp.Add(dummy)
|
||||
End If
|
||||
End While
|
||||
Dim strVar As String = temp(0).ToString() + temp(1).ToString() + temp(2).ToString() + temp(3).ToString() + temp(4).ToString() + temp(5).ToString()
|
||||
Return strVar
|
||||
|
||||
End Function
|
||||
|
||||
Public Sub loadConfiguration()
|
||||
Dim ConfOk As Boolean = True
|
||||
Dim RConfig As New IniFile
|
||||
Try
|
||||
RConfig.Load(ApplicationPath() & "\CICRadarR.ini")
|
||||
DEBUG = RConfig.GetKeyValue("CICRadarR", "Debug")
|
||||
NetBiosDomain = RConfig.GetKeyValue("CICRadarR", "NetBiosDomain")
|
||||
If NetBiosDomain.Length = 0 Then
|
||||
ServerLog("ERROR: NetBiosDomain can not be empty")
|
||||
ConfOk = False
|
||||
End If
|
||||
LDAPDomain = RConfig.GetKeyValue("CICRadarR", "LDAPDomain")
|
||||
If LDAPDomain.Length = 0 Then
|
||||
ServerLog("ERROR: LDAPDomain can not be empty")
|
||||
ConfOk = False
|
||||
End If
|
||||
|
||||
TSGW = RConfig.GetKeyValue("CICRadarR", "TSGW")
|
||||
|
||||
EnableOTP = RConfig.GetKeyValue("CICRadarR", "EnableOTP")
|
||||
|
||||
If EnableOTP = True Then
|
||||
If RConfig.GetKeyValue("CICRadarR", "EnableEmail") = "1" Then
|
||||
EnableEmail = True
|
||||
SenderEmail = RConfig.GetKeyValue("CICRadarR", "SenderEmail")
|
||||
MailServer = RConfig.GetKeyValue("CICRadarR", "MailServer")
|
||||
ADMailField = RConfig.GetKeyValue("CICRadarR", "ADMailField")
|
||||
End If
|
||||
|
||||
ADField = RConfig.GetKeyValue("CICRadarR", "ADField")
|
||||
If ADField.Length = 0 Then
|
||||
ServerLog("ERROR: ADField can not be empty")
|
||||
ConfOk = False
|
||||
End If
|
||||
|
||||
If RConfig.GetKeyValue("CICRadarR", "EnableSMS") = "1" Then
|
||||
EnableSMS = True
|
||||
ModemType = RConfig.GetKeyValue("CICRadarR", "USELOCALMODEM")
|
||||
Select Case ModemType
|
||||
Case "0"
|
||||
Provider = RConfig.GetKeyValue("CICRadarR", "Provider")
|
||||
If Provider.Length = 0 Then
|
||||
ServerLog("ERROR: Provider can not be empty")
|
||||
ConfOk = False
|
||||
End If
|
||||
Case "1"
|
||||
ComPort = RConfig.GetKeyValue("CICRadarR", "COMPORT")
|
||||
If ComPort.Length = 0 Then
|
||||
ServerLog("ERROR: ComPort can not be empty")
|
||||
ConfOk = False
|
||||
End If
|
||||
SmsC = RConfig.GetKeyValue("CICRadarR", "SMSC")
|
||||
If SmsC.Length = 0 Then
|
||||
ServerLog("ERROR: SMSC can not be empty. See http://smsclist.com/downloads/default.txt for valid values")
|
||||
ConfOk = False
|
||||
End If
|
||||
Case Else
|
||||
ServerLog("ERROR: USELOCALMODEM contain invalid configuration. Correct value are 1 or 0")
|
||||
ConfOk = False
|
||||
End Select
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Dim ClientList As String = ""
|
||||
ClientList = RConfig.GetKeyValue("CICRadarR", "ClientList")
|
||||
|
||||
Dim ClientArray() As String
|
||||
ClientArray = Split(ClientList, ",")
|
||||
|
||||
For i As Integer = 0 To ClientArray.Length - 1
|
||||
ServerLog("Loading Shared Secret for Client: " & ClientArray(i))
|
||||
clientHash.Add(ClientArray(i), EncDec.Decrypt(RConfig.GetKeyValue("Clients", ClientArray(i)), encCode))
|
||||
Next
|
||||
|
||||
If ConfOk = True Then
|
||||
ServerLog("Loading Configuration...OK")
|
||||
Else
|
||||
ServerLog("Loading Configuration...FAILED")
|
||||
End If
|
||||
Catch
|
||||
ServerLog("ERROR: Missing CICRadarR.ini from startup path or CICRadarR.ini contains invalid configuration")
|
||||
ServerLog("Loading Configuration...FAILED")
|
||||
End
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Function ApplicationPath() As String
|
||||
Return Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
|
||||
End Function
|
||||
|
||||
Public Shared Function SendSMS(ByVal number As String, ByVal passcode As String) As String
|
||||
|
||||
' test if using online sms provider or local modem
|
||||
If ModemType = 1 Then ' local modem
|
||||
Dim modem As New SmsClass(ComPort)
|
||||
modem.Opens()
|
||||
modem.sendSms(number, passcode, SmsC)
|
||||
modem.Closes()
|
||||
modem = Nothing
|
||||
Return "Ok"
|
||||
Else
|
||||
|
||||
|
||||
Dim baseurl As String = Provider.Split("?")(0)
|
||||
Dim client As New System.Net.WebClient()
|
||||
' 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;)")
|
||||
|
||||
Dim parameters As String = Provider.Split("?")(1)
|
||||
Dim pary As String() = parameters.Split("&")
|
||||
|
||||
For i As Integer = 0 To pary.Length - 1
|
||||
If pary(i).IndexOf("***TEXTMESSAGE***") > 0 Then
|
||||
Dim qpar As String() = pary(i).Split("=")
|
||||
client.QueryString.Add(qpar(0), passcode)
|
||||
ElseIf pary(i).IndexOf("***NUMBER***") > 0 Then
|
||||
Dim qpar As String() = pary(i).Split("=")
|
||||
client.QueryString.Add(qpar(0), number)
|
||||
Else
|
||||
|
||||
Dim qpar As String() = pary(i).Split("=")
|
||||
client.QueryString.Add(qpar(0), qpar(1))
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
Dim data As Stream = client.OpenRead(baseurl)
|
||||
Dim reader As New StreamReader(data)
|
||||
Dim s As String = reader.ReadToEnd()
|
||||
data.Close()
|
||||
reader.Close()
|
||||
Return (s)
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Function SendEmail(email As String, passcode As String) As String
|
||||
|
||||
|
||||
Dim mail As New MailMessage()
|
||||
mail.To.Add(email)
|
||||
mail.From = New MailAddress(SenderEmail)
|
||||
mail.Subject = "Token: " & passcode
|
||||
mail.Body = "Subject contains the token code to login to you site"
|
||||
mail.IsBodyHtml = False
|
||||
Dim smtp As New SmtpClient(MailServer)
|
||||
|
||||
|
||||
Try
|
||||
smtp.Send(mail)
|
||||
If DEBUG = True Then
|
||||
AccessLog(Now & ": Mail send to: " & email)
|
||||
End If
|
||||
Return "SEND"
|
||||
Catch e As InvalidCastException
|
||||
|
||||
If DEBUG = True Then
|
||||
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")
|
||||
End If
|
||||
Return "FAILED"
|
||||
End Try
|
||||
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
Private Sub TimerCleanUpHash_Elapsed(sender As System.Object, e As System.Timers.ElapsedEventArgs) Handles TimerCleanUpHash.Elapsed
|
||||
' Clean Session and Launch hash for TSGW
|
||||
Try
|
||||
Dim Item As DictionaryEntry
|
||||
For Each Item In TSGWSessionIdTimeStampHash
|
||||
Dim hTime As DateTime = DirectCast(Item.Value, DateTime)
|
||||
Dim tValid = DateDiff(DateInterval.Minute, hTime, Now)
|
||||
If tValid >= SessionTimeOut Then
|
||||
TSGWSessionIdTimeStampHash.Remove(Item.Key)
|
||||
If TSGWSessionIdHash.Contains(Item.Key) Then
|
||||
TSGWSessionIdHash.Remove(Item.Key)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
For Each Item In TSGWLaunchIdTimeStampHash
|
||||
Dim hTime As DateTime = DirectCast(Item.Value, DateTime)
|
||||
Dim tValid = DateDiff(DateInterval.Second, hTime, Now)
|
||||
If tValid >= LaunchTimeOut Then
|
||||
TSGWLaunchIdTimeStampHash.Remove(Item.Key)
|
||||
End If
|
||||
Next
|
||||
Catch
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
Imports System.DirectoryServices
|
||||
Imports System.IO
|
||||
Imports System.Reflection
|
||||
Imports CICRadarR.SMS
|
||||
Imports CICRadarR.LogFile
|
||||
Imports System.Security.Cryptography
|
||||
Imports System.Text
|
||||
Imports System
|
||||
Imports System.Net.Mail
|
||||
Imports RADAR
|
||||
|
||||
Public Class RDSFactor
|
||||
|
||||
Public Shared LDAPDomain As String = ""
|
||||
Public Shared ADField As String = ""
|
||||
Public Shared ADMailField As String = ""
|
||||
Public Shared EnableOTP As Boolean
|
||||
|
||||
' Shared key: used for challange encryption
|
||||
' TODO: Fix
|
||||
Public Shared encCode As String = "gewsyy#sjs2!"
|
||||
|
||||
Private Shared DEBUG As Boolean
|
||||
|
||||
Private Shared UserAccessLog As New LogWriter
|
||||
Private Shared Log As New LogWriter
|
||||
|
||||
Private secrets As NASAuthList
|
||||
Private radius1812 As RADIUSServer
|
||||
Private radius1645 As RADIUSServer
|
||||
Private userHash As New Hashtable
|
||||
Private packetHash As New Hashtable
|
||||
Private clientHash As New Hashtable
|
||||
|
||||
Public Shared NetBiosDomain As String = ""
|
||||
|
||||
Private Shared Provider As String = ""
|
||||
|
||||
|
||||
Private Shared ModemType As String = ""
|
||||
Private Shared ComPort As String = ""
|
||||
Private Shared SmsC As String = ""
|
||||
Private Shared MailServer As String = ""
|
||||
Private Shared SenderEmail As String = ""
|
||||
|
||||
Private TSGW As String = ""
|
||||
Private TSGWSessionIdHash As New Hashtable
|
||||
Private TSGWSessionIdTimeStampHash 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 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 LaunchTimeOut As Integer = 30 ' in seconds
|
||||
Public Shared EnableSMS As Boolean = False
|
||||
Public Shared EnableEmail As Boolean = False
|
||||
|
||||
Protected Overrides Sub OnStart(ByVal args() As String)
|
||||
|
||||
Log.filePath = ApplicationPath() & "\log.txt"
|
||||
UserAccessLog.filePath = ApplicationPath() & "\UserAccessLog.txt"
|
||||
|
||||
Log.WriteLog("---------------------------------------------------------------------------------------------------")
|
||||
ServerLog("Starting Service")
|
||||
ServerLog("Loading Configuration...")
|
||||
Call loadConfiguration()
|
||||
ServerLog("Starting Radius listner ports...")
|
||||
Call StartUpServer()
|
||||
End Sub
|
||||
|
||||
Public Sub OnstartTest()
|
||||
Log.filePath = ApplicationPath() & "\log.txt"
|
||||
UserAccessLog.filePath = ApplicationPath() & "\UserAccessLog.txt"
|
||||
|
||||
ServerLog("---------------------------------------------------------------------------------------------------")
|
||||
ServerLog("Starting Service")
|
||||
ServerLog("Loading Configuration...")
|
||||
Call loadConfiguration()
|
||||
ServerLog("Starting Radius listner ports...")
|
||||
Call StartUpServer()
|
||||
End Sub
|
||||
|
||||
Protected Overrides Sub OnStop()
|
||||
ServerLog("Stopping Radius listner ports...")
|
||||
|
||||
End Sub
|
||||
|
||||
Public Sub OnStopTest()
|
||||
ServerLog("Stopping Radius listner ports...")
|
||||
End Sub
|
||||
|
||||
Public Sub StartUpServer()
|
||||
|
||||
' First, let's load a list of RADIUS shared secrets
|
||||
' in a NASAuthList object (a glorified Dictionary, basically)
|
||||
secrets = New NASAuthList
|
||||
' Populate from DB, I suppose ...
|
||||
|
||||
For Each cl As DictionaryEntry In clientHash
|
||||
ServerLog("Adding Shared Secret to Radius Server")
|
||||
secrets.AddSharedSecret(cl.Key, cl.Value)
|
||||
Next
|
||||
' Then, we just create a RADIUS server ...
|
||||
Try
|
||||
radius1812 = New RADIUSServer(1812, AddressOf ProcessPacket1812, secrets)
|
||||
ServerLog("Starting Radius Server on Port 1812...OK")
|
||||
Catch
|
||||
ServerLog("Starting Radius Server on Port 1812...FAILED")
|
||||
End Try
|
||||
|
||||
Try
|
||||
radius1645 = New RADIUSServer(1645, AddressOf ProcessPacket1645, secrets)
|
||||
ServerLog("Starting Radius Server on Port 1645...OK")
|
||||
Catch
|
||||
ServerLog("Starting Radius Server on Port 1645...FAILED")
|
||||
End Try
|
||||
|
||||
End Sub
|
||||
|
||||
|
||||
' Every valid RADIUS request generated by the server(s) we created earlier
|
||||
' will fire up the callback procedure. Invalid requests are dropped, per RFC.
|
||||
Private Sub ProcessPacket1812(ByVal packet As RADIUSPacket)
|
||||
'Console.WriteLine("packet " & Now)
|
||||
ProcessPacket(radius1812, packet)
|
||||
End Sub
|
||||
|
||||
Private Sub ProcessPacket1645(ByVal packet As RADIUSPacket)
|
||||
ProcessPacket(radius1645, packet)
|
||||
End Sub
|
||||
|
||||
Public Shared Sub AccessLog(ByVal message)
|
||||
If DEBUG = True Then
|
||||
UserAccessLog.WriteLog(Now & ": DEBUG: " & message)
|
||||
|
||||
' Also write to the console if not a service
|
||||
If Environment.UserInteractive Then
|
||||
Console.WriteLine(Now & ": DEBUG: " & message)
|
||||
End If
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Public Shared Sub ServerLog(ByVal message)
|
||||
Log.WriteLog(Now & ":" & message)
|
||||
' Also write to the console if not a service
|
||||
If Environment.UserInteractive Then
|
||||
Console.WriteLine(Now & message)
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Sub ProcessPacket(ByVal server As RADIUSServer, ByVal packet As RADIUSPacket)
|
||||
If Not packet.IsValid Then
|
||||
Console.WriteLine("Packet is not valid. Discarding.")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
Dim handler
|
||||
If TSGW = "1" Then
|
||||
handler = New RDSHandler(packet)
|
||||
Else
|
||||
handler = New CitrixHandler(packet)
|
||||
End If
|
||||
|
||||
handler.ProcessRequest()
|
||||
End Sub
|
||||
|
||||
Public Shared Function GenerateCode() As String
|
||||
Dim dummy As Integer = 0
|
||||
|
||||
Dim ordRand As New System.Random()
|
||||
Dim temp As New System.Collections.ArrayList()
|
||||
While temp.Count < 6
|
||||
dummy = ordRand.[Next](1, 9)
|
||||
If Not temp.Contains(dummy) Then
|
||||
temp.Add(dummy)
|
||||
End If
|
||||
End While
|
||||
Dim strVar As String = temp(0).ToString() + temp(1).ToString() + temp(2).ToString() + temp(3).ToString() + temp(4).ToString() + temp(5).ToString()
|
||||
Return strVar
|
||||
|
||||
End Function
|
||||
|
||||
Public Sub loadConfiguration()
|
||||
Dim ConfOk As Boolean = True
|
||||
Dim RConfig As New IniFile
|
||||
Try
|
||||
RConfig.Load(ApplicationPath() & "\CICRadarR.ini")
|
||||
DEBUG = RConfig.GetKeyValue("CICRadarR", "Debug")
|
||||
NetBiosDomain = RConfig.GetKeyValue("CICRadarR", "NetBiosDomain")
|
||||
If NetBiosDomain.Length = 0 Then
|
||||
ServerLog("ERROR: NetBiosDomain can not be empty")
|
||||
ConfOk = False
|
||||
End If
|
||||
LDAPDomain = RConfig.GetKeyValue("CICRadarR", "LDAPDomain")
|
||||
If LDAPDomain.Length = 0 Then
|
||||
ServerLog("ERROR: LDAPDomain can not be empty")
|
||||
ConfOk = False
|
||||
End If
|
||||
|
||||
TSGW = RConfig.GetKeyValue("CICRadarR", "TSGW")
|
||||
|
||||
EnableOTP = RConfig.GetKeyValue("CICRadarR", "EnableOTP")
|
||||
|
||||
If EnableOTP = True Then
|
||||
If RConfig.GetKeyValue("CICRadarR", "EnableEmail") = "1" Then
|
||||
EnableEmail = True
|
||||
SenderEmail = RConfig.GetKeyValue("CICRadarR", "SenderEmail")
|
||||
MailServer = RConfig.GetKeyValue("CICRadarR", "MailServer")
|
||||
ADMailField = RConfig.GetKeyValue("CICRadarR", "ADMailField")
|
||||
End If
|
||||
|
||||
ADField = RConfig.GetKeyValue("CICRadarR", "ADField")
|
||||
If ADField.Length = 0 Then
|
||||
ServerLog("ERROR: ADField can not be empty")
|
||||
ConfOk = False
|
||||
End If
|
||||
|
||||
If RConfig.GetKeyValue("CICRadarR", "EnableSMS") = "1" Then
|
||||
EnableSMS = True
|
||||
ModemType = RConfig.GetKeyValue("CICRadarR", "USELOCALMODEM")
|
||||
Select Case ModemType
|
||||
Case "0"
|
||||
Provider = RConfig.GetKeyValue("CICRadarR", "Provider")
|
||||
If Provider.Length = 0 Then
|
||||
ServerLog("ERROR: Provider can not be empty")
|
||||
ConfOk = False
|
||||
End If
|
||||
Case "1"
|
||||
ComPort = RConfig.GetKeyValue("CICRadarR", "COMPORT")
|
||||
If ComPort.Length = 0 Then
|
||||
ServerLog("ERROR: ComPort can not be empty")
|
||||
ConfOk = False
|
||||
End If
|
||||
SmsC = RConfig.GetKeyValue("CICRadarR", "SMSC")
|
||||
If SmsC.Length = 0 Then
|
||||
ServerLog("ERROR: SMSC can not be empty. See http://smsclist.com/downloads/default.txt for valid values")
|
||||
ConfOk = False
|
||||
End If
|
||||
Case Else
|
||||
ServerLog("ERROR: USELOCALMODEM contain invalid configuration. Correct value are 1 or 0")
|
||||
ConfOk = False
|
||||
End Select
|
||||
End If
|
||||
|
||||
End If
|
||||
|
||||
Dim ClientList As String = ""
|
||||
ClientList = RConfig.GetKeyValue("CICRadarR", "ClientList")
|
||||
|
||||
Dim ClientArray() As String
|
||||
ClientArray = Split(ClientList, ",")
|
||||
|
||||
For i As Integer = 0 To ClientArray.Length - 1
|
||||
ServerLog("Loading Shared Secret for Client: " & ClientArray(i))
|
||||
clientHash.Add(ClientArray(i), EncDec.Decrypt(RConfig.GetKeyValue("Clients", ClientArray(i)), encCode))
|
||||
Next
|
||||
|
||||
If ConfOk = True Then
|
||||
ServerLog("Loading Configuration...OK")
|
||||
Else
|
||||
ServerLog("Loading Configuration...FAILED")
|
||||
End If
|
||||
Catch
|
||||
ServerLog("ERROR: Missing CICRadarR.ini from startup path or CICRadarR.ini contains invalid configuration")
|
||||
ServerLog("Loading Configuration...FAILED")
|
||||
End
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Public Function ApplicationPath() As String
|
||||
Return Path.GetDirectoryName([Assembly].GetExecutingAssembly().Location)
|
||||
End Function
|
||||
|
||||
Public Shared Function SendSMS(ByVal number As String, ByVal passcode As String) As String
|
||||
|
||||
' test if using online sms provider or local modem
|
||||
If ModemType = 1 Then ' local modem
|
||||
Dim modem As New SmsClass(ComPort)
|
||||
modem.Opens()
|
||||
modem.sendSms(number, passcode, SmsC)
|
||||
modem.Closes()
|
||||
modem = Nothing
|
||||
Return "Ok"
|
||||
Else
|
||||
|
||||
|
||||
Dim baseurl As String = Provider.Split("?")(0)
|
||||
Dim client As New System.Net.WebClient()
|
||||
' 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;)")
|
||||
|
||||
Dim parameters As String = Provider.Split("?")(1)
|
||||
Dim pary As String() = parameters.Split("&")
|
||||
|
||||
For i As Integer = 0 To pary.Length - 1
|
||||
If pary(i).IndexOf("***TEXTMESSAGE***") > 0 Then
|
||||
Dim qpar As String() = pary(i).Split("=")
|
||||
client.QueryString.Add(qpar(0), passcode)
|
||||
ElseIf pary(i).IndexOf("***NUMBER***") > 0 Then
|
||||
Dim qpar As String() = pary(i).Split("=")
|
||||
client.QueryString.Add(qpar(0), number)
|
||||
Else
|
||||
|
||||
Dim qpar As String() = pary(i).Split("=")
|
||||
client.QueryString.Add(qpar(0), qpar(1))
|
||||
End If
|
||||
Next
|
||||
|
||||
|
||||
Dim data As Stream = client.OpenRead(baseurl)
|
||||
Dim reader As New StreamReader(data)
|
||||
Dim s As String = reader.ReadToEnd()
|
||||
data.Close()
|
||||
reader.Close()
|
||||
Return (s)
|
||||
End If
|
||||
|
||||
End Function
|
||||
|
||||
Public Shared Function SendEmail(email As String, passcode As String) As String
|
||||
|
||||
|
||||
Dim mail As New MailMessage()
|
||||
mail.To.Add(email)
|
||||
mail.From = New MailAddress(SenderEmail)
|
||||
mail.Subject = "Token: " & passcode
|
||||
mail.Body = "Subject contains the token code to login to you site"
|
||||
mail.IsBodyHtml = False
|
||||
Dim smtp As New SmtpClient(MailServer)
|
||||
|
||||
|
||||
Try
|
||||
smtp.Send(mail)
|
||||
If DEBUG = True Then
|
||||
AccessLog(Now & ": Mail send to: " & email)
|
||||
End If
|
||||
Return "SEND"
|
||||
Catch e As InvalidCastException
|
||||
|
||||
If DEBUG = True Then
|
||||
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")
|
||||
End If
|
||||
Return "FAILED"
|
||||
End Try
|
||||
|
||||
|
||||
|
||||
End Function
|
||||
|
||||
Private Sub TimerCleanUpHash_Elapsed(sender As System.Object, e As System.Timers.ElapsedEventArgs) Handles TimerCleanUpHash.Elapsed
|
||||
' Clean Session and Launch hash for TSGW
|
||||
Try
|
||||
Dim Item As DictionaryEntry
|
||||
For Each Item In TSGWSessionIdTimeStampHash
|
||||
Dim hTime As DateTime = DirectCast(Item.Value, DateTime)
|
||||
Dim tValid = DateDiff(DateInterval.Minute, hTime, Now)
|
||||
If tValid >= SessionTimeOut Then
|
||||
TSGWSessionIdTimeStampHash.Remove(Item.Key)
|
||||
If TSGWSessionIdHash.Contains(Item.Key) Then
|
||||
TSGWSessionIdHash.Remove(Item.Key)
|
||||
End If
|
||||
End If
|
||||
Next
|
||||
|
||||
For Each Item In TSGWLaunchIdTimeStampHash
|
||||
Dim hTime As DateTime = DirectCast(Item.Value, DateTime)
|
||||
Dim tValid = DateDiff(DateInterval.Second, hTime, Now)
|
||||
If tValid >= LaunchTimeOut Then
|
||||
TSGWLaunchIdTimeStampHash.Remove(Item.Key)
|
||||
End If
|
||||
Next
|
||||
Catch
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
|
@ -1,165 +1,165 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>
|
||||
</SchemaVersion>
|
||||
<ProjectGuid>{04C6C533-9FEA-41B2-B554-A166C7C7FE32}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<StartupObject>Sub Main</StartupObject>
|
||||
<RootNamespace>CICRadarR</RootNamespace>
|
||||
<AssemblyName>CICRadarR</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Console</MyType>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>CICRadarR.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>CICRadarR.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>My Project\app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.DirectoryServices" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="exceptions\MissingRadiusSecret.vb" />
|
||||
<Compile Include="exceptions\MissingUser.vb" />
|
||||
<Compile Include="handlers\CitrixHandler.vb" />
|
||||
<Compile Include="handlers\RDSHandler.vb" />
|
||||
<Compile Include="Crypto.vb" />
|
||||
<Compile Include="IniFileVb.vb" />
|
||||
<Compile Include="Log.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CICRadarR.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CICRadarR.Designer.vb">
|
||||
<DependentUpon>CICRadarR.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="ProjectInstaller.Designer.vb">
|
||||
<DependentUpon>ProjectInstaller.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProjectInstaller.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SmsClass.vb" />
|
||||
<Compile Include="TestService.Designer.vb">
|
||||
<DependentUpon>TestService.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="TestService.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="CICRadarR.resx">
|
||||
<DependentUpon>CICRadarR.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ProjectInstaller.resx">
|
||||
<DependentUpon>ProjectInstaller.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="TestService.resx">
|
||||
<DependentUpon>TestService.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="My Project\app.manifest" />
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\radar-radius\RADAR\RADAR.vbproj">
|
||||
<Project>{3ab08a4e-c4fa-4571-a5d4-32bba807c31d}</Project>
|
||||
<Name>RADAR</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
<!-- 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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>
|
||||
</ProductVersion>
|
||||
<SchemaVersion>
|
||||
</SchemaVersion>
|
||||
<ProjectGuid>{04C6C533-9FEA-41B2-B554-A166C7C7FE32}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<StartupObject>Sub Main</StartupObject>
|
||||
<RootNamespace>CICRadarR</RootNamespace>
|
||||
<AssemblyName>CICRadarR</AssemblyName>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<MyType>Console</MyType>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<DefineDebug>true</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DocumentationFile>CICRadarR.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<DefineDebug>false</DefineDebug>
|
||||
<DefineTrace>true</DefineTrace>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DocumentationFile>CICRadarR.xml</DocumentationFile>
|
||||
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionExplicit>On</OptionExplicit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionCompare>Binary</OptionCompare>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionStrict>Off</OptionStrict>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<OptionInfer>On</OptionInfer>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationManifest>My Project\app.manifest</ApplicationManifest>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.DirectoryServices" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Import Include="Microsoft.VisualBasic" />
|
||||
<Import Include="System" />
|
||||
<Import Include="System.Collections" />
|
||||
<Import Include="System.Collections.Generic" />
|
||||
<Import Include="System.Data" />
|
||||
<Import Include="System.Diagnostics" />
|
||||
<Import Include="System.Linq" />
|
||||
<Import Include="System.Xml.Linq" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="exceptions\MissingRadiusSecret.vb" />
|
||||
<Compile Include="exceptions\MissingUser.vb" />
|
||||
<Compile Include="handlers\CitrixHandler.vb" />
|
||||
<Compile Include="handlers\RDSHandler.vb" />
|
||||
<Compile Include="Crypto.vb" />
|
||||
<Compile Include="IniFileVb.vb" />
|
||||
<Compile Include="Log.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Application.myapp</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="RDSFactor.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="RDSFactor.Designer.vb">
|
||||
<DependentUpon>RDSFactor.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Resources.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="My Project\Settings.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="ProjectInstaller.Designer.vb">
|
||||
<DependentUpon>ProjectInstaller.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ProjectInstaller.vb">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="SmsClass.vb" />
|
||||
<Compile Include="TestService.Designer.vb">
|
||||
<DependentUpon>TestService.vb</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="TestService.vb">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="RDSFactor.resx">
|
||||
<DependentUpon>RDSFactor.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="My Project\Resources.resx">
|
||||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
|
||||
<CustomToolNamespace>My.Resources</CustomToolNamespace>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="ProjectInstaller.resx">
|
||||
<DependentUpon>ProjectInstaller.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="TestService.resx">
|
||||
<DependentUpon>TestService.vb</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="My Project\app.manifest" />
|
||||
<None Include="My Project\Application.myapp">
|
||||
<Generator>MyApplicationCodeGenerator</Generator>
|
||||
<LastGenOutput>Application.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
<None Include="My Project\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<CustomToolNamespace>My</CustomToolNamespace>
|
||||
<LastGenOutput>Settings.Designer.vb</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\radar-radius\RADAR\RADAR.vbproj">
|
||||
<Project>{3ab08a4e-c4fa-4571-a5d4-32bba807c31d}</Project>
|
||||
<Name>RADAR</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
<!-- 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.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
|
@ -1,3 +1,3 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
</Project>
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
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
|
||||
btnStart.Enabled = False
|
||||
Call Radius_Service.OnstartTest()
|
|
@ -17,7 +17,7 @@ Public Class CitrixHandler
|
|||
' and drop other requests silently ...
|
||||
|
||||
If packet.Code <> RadiusPacketCode.AccessRequest Then
|
||||
CICRadarR.AccessLog("Not a valid radius packet.. Drop!")
|
||||
RDSFactor.AccessLog("Not a valid radius packet.. Drop!")
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
|
@ -36,11 +36,11 @@ Public Class CitrixHandler
|
|||
' will return Nothing.
|
||||
If username Is Nothing Then
|
||||
' 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
|
||||
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
|
||||
' Exit Sub
|
||||
|
@ -49,27 +49,27 @@ Public Class CitrixHandler
|
|||
|
||||
|
||||
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.
|
||||
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 = ""
|
||||
'lets see if user login using upd or UPN name
|
||||
Dim sUserName As String = username.ToString
|
||||
Dim sPassword As String = packet.UserPassword
|
||||
|
||||
CICRadarR.AccessLog("SMSToken supplied by user: " & sUserName)
|
||||
RDSFactor.AccessLog("SMSToken supplied by user: " & sUserName)
|
||||
|
||||
sid = ""
|
||||
If InStr(sUserName, "@") > 0 Then 'UPN
|
||||
UserDomain = sUserName
|
||||
Else 'UPD
|
||||
'read domain from Hashtable
|
||||
UserDomain = CICRadarR.NetBiosDomain & "\" & sUserName
|
||||
UserDomain = RDSFactor.NetBiosDomain & "\" & sUserName
|
||||
End If
|
||||
|
||||
sid = EncDec.Encrypt(UserDomain & "_" & packet.UserPassword, CICRadarR.encCode)
|
||||
CICRadarR.AccessLog("Checking for userHash " & sid)
|
||||
sid = EncDec.Encrypt(UserDomain & "_" & packet.UserPassword, RDSFactor.encCode)
|
||||
RDSFactor.AccessLog("Checking for userHash " & sid)
|
||||
If sid = state Then
|
||||
packet.AcceptAccessRequest()
|
||||
Else
|
||||
|
@ -97,15 +97,15 @@ Public Class CitrixHandler
|
|||
UserDomain = sUserName
|
||||
Else 'UPD
|
||||
'read domain from Hashtable
|
||||
UserDomain = CICRadarR.NetBiosDomain & "\" & sUserName
|
||||
UserDomain = RDSFactor.NetBiosDomain & "\" & sUserName
|
||||
End If
|
||||
|
||||
CICRadarR.AccessLog("User " & UserDomain & " is trying to log in ...")
|
||||
RDSFactor.AccessLog("User " & UserDomain & " is trying to log in ...")
|
||||
|
||||
|
||||
|
||||
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 search As New DirectorySearcher(dirEntry)
|
||||
|
@ -118,17 +118,17 @@ Public Class CitrixHandler
|
|||
'Load the Properties we need from AD
|
||||
search.PropertiesToLoad.Add("distinguishedName")
|
||||
'search.PropertiesToLoad.Add("primaryTelexNumber")
|
||||
If CICRadarR.EnableOTP = True Then
|
||||
If CICRadarR.EnableEmail = True Then
|
||||
search.PropertiesToLoad.Add(CICRadarR.ADMailField)
|
||||
If RDSFactor.EnableOTP = True Then
|
||||
If RDSFactor.EnableEmail = True Then
|
||||
search.PropertiesToLoad.Add(RDSFactor.ADMailField)
|
||||
End If
|
||||
If CICRadarR.EnableSMS = True Then
|
||||
search.PropertiesToLoad.Add(CICRadarR.ADField)
|
||||
If RDSFactor.EnableSMS = True Then
|
||||
search.PropertiesToLoad.Add(RDSFactor.ADField)
|
||||
End If
|
||||
|
||||
End If
|
||||
' 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()
|
||||
'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 userEntry As New DirectoryEntry(userLdap, UserDomain, sPassword)
|
||||
If CICRadarR.EnableOTP = True Then
|
||||
smsCode = CICRadarR.GenerateCode()
|
||||
If RDSFactor.EnableOTP = True Then
|
||||
smsCode = RDSFactor.GenerateCode()
|
||||
|
||||
' REMEMBER to put at check for empty phone string
|
||||
If CICRadarR.EnableEmail = True Then
|
||||
If RDSFactor.EnableEmail = True Then
|
||||
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
|
||||
success = False
|
||||
CICRadarR.AccessLog("Unable to find correct email for user " & UserDomain)
|
||||
RDSFactor.AccessLog("Unable to find correct email for user " & UserDomain)
|
||||
Else
|
||||
success = True
|
||||
End If
|
||||
Catch
|
||||
CICRadarR.AccessLog("Unable to find correct email for user " & UserDomain)
|
||||
RDSFactor.AccessLog("Unable to find correct email for user " & UserDomain)
|
||||
success = False
|
||||
End Try
|
||||
End If
|
||||
If CICRadarR.EnableSMS = True Then
|
||||
If RDSFactor.EnableSMS = True Then
|
||||
Try
|
||||
mobile = DirectCast(result.Properties(CICRadarR.ADField)(0), String)
|
||||
mobile = DirectCast(result.Properties(RDSFactor.ADField)(0), String)
|
||||
mobile = Replace(mobile, "+", "")
|
||||
If mobile.Trim.Length = 0 Then
|
||||
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
|
||||
success = True
|
||||
End If
|
||||
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
|
||||
End Try
|
||||
|
||||
End If
|
||||
|
||||
sid = EncDec.Encrypt(UserDomain & "_" & smsCode, CICRadarR.encCode) 'generate unique code
|
||||
sid = EncDec.Encrypt(UserDomain & "_" & smsCode, RDSFactor.encCode) 'generate unique code
|
||||
End If
|
||||
' sid = UserDomain & "_" & smsCode
|
||||
'userEntry.Properties("primaryTelexNumber").Value = aCode(0) & "/" & smsCode & "/" & aCode(2) & "/" & aCode(3)
|
||||
|
@ -199,7 +199,7 @@ Public Class CitrixHandler
|
|||
success = False
|
||||
End If
|
||||
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
|
||||
End Try
|
||||
|
||||
|
@ -207,8 +207,8 @@ Public Class CitrixHandler
|
|||
Dim attributes As New RADIUSAttributes
|
||||
If success Then ' Yay! Someone guess the password ...
|
||||
|
||||
CICRadarR.AccessLog("User " & UserDomain & " authenticated agains Active Directory")
|
||||
If CICRadarR.EnableOTP = True Then
|
||||
RDSFactor.AccessLog("User " & UserDomain & " authenticated agains Active Directory")
|
||||
If RDSFactor.EnableOTP = True Then
|
||||
Dim attr As New RADIUSAttribute(RadiusAttributeType.ReplyMessage, "SMS Token")
|
||||
attributes.Add(attr)
|
||||
Dim state As New RADIUSAttribute(RadiusAttributeType.State, sid)
|
||||
|
@ -219,22 +219,22 @@ Public Class CitrixHandler
|
|||
packet.Identifier, attributes, _
|
||||
packet.EndPoint), _
|
||||
packet.Authenticator)
|
||||
If CICRadarR.EnableSMS = True Then
|
||||
CICRadarR.AccessLog("Sending access token: " & smsCode & " to phonenumber " & mobile)
|
||||
Call CICRadarR.SendSMS(mobile, smsCode)
|
||||
If RDSFactor.EnableSMS = True Then
|
||||
RDSFactor.AccessLog("Sending access token: " & smsCode & " to phonenumber " & mobile)
|
||||
Call RDSFactor.SendSMS(mobile, smsCode)
|
||||
End If
|
||||
If CICRadarR.EnableEmail = True Then
|
||||
CICRadarR.AccessLog("Sending access token: " & smsCode & " to email " & UserEmail)
|
||||
Call CICRadarR.SendEmail(UserEmail, smsCode)
|
||||
If RDSFactor.EnableEmail = True Then
|
||||
RDSFactor.AccessLog("Sending access token: " & smsCode & " to email " & UserEmail)
|
||||
Call RDSFactor.SendEmail(UserEmail, smsCode)
|
||||
End If
|
||||
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()
|
||||
End If
|
||||
' packetHash.Remove(username.GetString & "_" & pass.GetString)
|
||||
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)
|
||||
server.SendAsResponse(pk, packet.Authenticator)
|
||||
' FYI ... if no additional attributes need to be added
|
|
@ -75,7 +75,7 @@ Public Class RDSHandler
|
|||
' NOTE: Requests contain the session GUID in the password attribute
|
||||
' of the packet.
|
||||
Public Sub ProcessAppLaunchRequest()
|
||||
CICRadarR.AccessLog("ProcessAppLaunchRequest")
|
||||
RDSFactor.AccessLog("ProcessAppLaunchRequest")
|
||||
|
||||
' When the packet is an AppLaunchRequest the password attribute contains the session id!
|
||||
Dim packetSessionId = mPassword
|
||||
|
@ -83,15 +83,15 @@ Public Class RDSHandler
|
|||
Dim sessionTimestamp = sessionTimestamps(mUsername)
|
||||
|
||||
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()
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If packetSessionId = storedSessionId Then
|
||||
Dim minsSinceLastActivity = DateDiff(DateInterval.Minute, sessionTimestamp, Now)
|
||||
If minsSinceLastActivity < CICRadarR.SessionTimeOut Then
|
||||
CICRadarR.AccessLog("Opening window for: " & mUsername)
|
||||
If minsSinceLastActivity < RDSFactor.SessionTimeOut Then
|
||||
RDSFactor.AccessLog("Opening window for: " & mUsername)
|
||||
' Pro-long session
|
||||
sessionTimestamps(storedSessionId) = Now
|
||||
' Open launch window
|
||||
|
@ -99,12 +99,12 @@ Public Class RDSHandler
|
|||
mPacket.AcceptAccessRequest()
|
||||
Exit Sub
|
||||
Else
|
||||
CICRadarR.AccessLog("Session timed out -- User MUST re-authenticate")
|
||||
RDSFactor.AccessLog("Session timed out -- User MUST re-authenticate")
|
||||
userSessions.Remove(mUsername)
|
||||
sessionTimestamps.Remove(mUsername)
|
||||
End If
|
||||
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
|
||||
|
||||
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
|
||||
' before ensuring App Launch request was successful
|
||||
Public Sub ProcessGatewayRequest()
|
||||
CICRadarR.AccessLog("Gateway Request for user: " & mUsername)
|
||||
RDSFactor.AccessLog("Gateway Request for user: " & mUsername)
|
||||
|
||||
Dim sessionId = userSessions(mUsername)
|
||||
Dim launchTimestamp = userLaunchTimestamps(mUsername)
|
||||
Dim attributes As New RADIUSAttributes
|
||||
|
||||
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()
|
||||
Exit Sub
|
||||
End If
|
||||
|
@ -141,11 +141,11 @@ Public Class RDSHandler
|
|||
End If
|
||||
|
||||
Dim secondsSinceLaunch = DateDiff(DateInterval.Second, launchTimestamp, Now)
|
||||
If secondsSinceLaunch < CICRadarR.LaunchTimeOut Then
|
||||
CICRadarR.AccessLog("Allowing access through gateway for user: " & mUsername & " -- closing window")
|
||||
If secondsSinceLaunch < RDSFactor.LaunchTimeOut Then
|
||||
RDSFactor.AccessLog("Allowing access through gateway for user: " & mUsername & " -- closing window")
|
||||
mPacket.AcceptAccessRequest(attributes)
|
||||
Else
|
||||
CICRadarR.AccessLog("Launch window has closed!")
|
||||
RDSFactor.AccessLog("Launch window has closed!")
|
||||
End If
|
||||
|
||||
' close window
|
||||
|
@ -160,24 +160,24 @@ Public Class RDSHandler
|
|||
Exit Sub
|
||||
End If
|
||||
|
||||
CICRadarR.AccessLog("ProcessAccessRequest")
|
||||
RDSFactor.AccessLog("ProcessAccessRequest")
|
||||
Try
|
||||
Dim ldapResult = Authenticate()
|
||||
|
||||
If CICRadarR.EnableOTP Then
|
||||
If RDSFactor.EnableOTP Then
|
||||
TwoFactorChallenge()
|
||||
Exit Sub
|
||||
Else
|
||||
Accept()
|
||||
End If
|
||||
Catch ex As Exception
|
||||
CICRadarR.AccessLog("Authentication failed. Sending reject. Error: " & ex.Message)
|
||||
RDSFactor.AccessLog("Authentication failed. Sending reject. Error: " & ex.Message)
|
||||
mPacket.RejectAccessRequest()
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub Accept()
|
||||
CICRadarR.AccessLog("Accept")
|
||||
RDSFactor.AccessLog("Accept")
|
||||
Dim sGUID As String = System.Guid.NewGuid.ToString()
|
||||
userSessions(mUsername) = sGUID
|
||||
sessionTimestamps(mUsername) = Now
|
||||
|
@ -190,13 +190,13 @@ Public Class RDSHandler
|
|||
End Sub
|
||||
|
||||
Private Sub ProcessChallengeResponse()
|
||||
CICRadarR.AccessLog("ProcessChallengeResponse")
|
||||
RDSFactor.AccessLog("ProcessChallengeResponse")
|
||||
|
||||
' When the packet is an Challange-Response the password attr. contains the token
|
||||
Dim challangeCode = mPassword
|
||||
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
|
||||
Accept()
|
||||
Else
|
||||
|
@ -205,19 +205,19 @@ Public Class RDSHandler
|
|||
End Sub
|
||||
|
||||
Private Sub TwoFactorChallenge()
|
||||
Dim code = CICRadarR.GenerateCode
|
||||
Dim sid = EncDec.Encrypt(mUsername & "_" & code, CICRadarR.encCode) 'generate unique code
|
||||
CICRadarR.AccessLog("Access Challange Code: " & code)
|
||||
Dim code = RDSFactor.GenerateCode
|
||||
Dim sid = EncDec.Encrypt(mUsername & "_" & code, RDSFactor.encCode) 'generate unique code
|
||||
RDSFactor.AccessLog("Access Challange Code: " & code)
|
||||
|
||||
userSidTokens(mUsername) = sid
|
||||
tokenTimestamps(mUsername) = Now
|
||||
|
||||
If mUseSMSFactor Then
|
||||
CICRadarR.AccessLog("TODO: Send SMS")
|
||||
RDSFactor.AccessLog("TODO: Send SMS")
|
||||
End If
|
||||
|
||||
If mUseEmailFactor Then
|
||||
CICRadarR.AccessLog("TODO: Send Email")
|
||||
RDSFactor.AccessLog("TODO: Send Email")
|
||||
End If
|
||||
|
||||
Dim attributes As New RADIUSAttributes
|
||||
|
@ -233,9 +233,9 @@ Public Class RDSHandler
|
|||
|
||||
Private Function Authenticate() As System.DirectoryServices.SearchResult
|
||||
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 obj As Object = dirEntry.NativeObject
|
||||
|
@ -248,15 +248,15 @@ Public Class RDSHandler
|
|||
End If
|
||||
|
||||
search.PropertiesToLoad.Add("distinguishedName")
|
||||
If CICRadarR.EnableOTP = True Then
|
||||
search.PropertiesToLoad.Add(CICRadarR.ADField)
|
||||
search.PropertiesToLoad.Add(CICRadarR.ADMailField)
|
||||
If RDSFactor.EnableOTP = True Then
|
||||
search.PropertiesToLoad.Add(RDSFactor.ADField)
|
||||
search.PropertiesToLoad.Add(RDSFactor.ADMailField)
|
||||
End If
|
||||
|
||||
Dim result = search.FindOne()
|
||||
|
||||
If IsDBNull(result) Then
|
||||
CICRadarR.AccessLog("Failed to authenticate with Active Directory")
|
||||
RDSFactor.AccessLog("Failed to authenticate with Active Directory")
|
||||
Throw New MissingUser
|
||||
End If
|
||||
|
||||
|
@ -264,19 +264,19 @@ Public Class RDSHandler
|
|||
End Function
|
||||
|
||||
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, "+", "")
|
||||
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
|
||||
Return mobile
|
||||
End Function
|
||||
|
||||
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
|
||||
CICRadarR.AccessLog("Unable to find correct email for user " & mUsername)
|
||||
RDSFactor.AccessLog("Unable to find correct email for user " & mUsername)
|
||||
End If
|
||||
Return email
|
||||
End Function
|
Loading…
Add table
Add a link
Reference in a new issue