G
Guest
Hi Guys,
OK this is my very first attempt at development and whilst it does what i
want it to i know that in actual the fact the coding is awful. The first
thing you will notice is the amount of repetition of similiar code that does
the same thing.
Im hoping that someone will take the time to look at the code and offer some
advice as to how to curtail the amount of lines of code. As it is obvious to
even the naivest coder there is some way of eliminating the repetition.
Im not asking for someone to rewrite the thing, what i am after is someone
to try explain the error of my ways and show me some ways of cleaning the
code up, as im sure that there will be occasions where i will be able to
apply lessons learnt.
Thanks
Darren
Public Class Form1
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
Application.Exit()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If TabControl1.SelectedTab.Name = "TabPage1" Then
CheckBox1.Checked = True
CheckBox2.Checked = True
CheckBox3.Checked = True
CheckBox4.Checked = True
CheckBox5.Checked = True
CheckBox6.Checked = True
CheckBox7.Checked = True
CheckBox8.Checked = True
CheckBox9.Checked = True
CheckBox10.Checked = True
CheckBox11.Checked = True
CheckBox12.Checked = True
CheckBox13.Checked = True
Else
CheckBox14.Checked = True
CheckBox15.Checked = True
CheckBox16.Checked = True
CheckBox17.Checked = True
End If
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
If TabControl1.SelectedTab.Name = "TabPage1" Then
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = False
CheckBox4.Checked = False
CheckBox5.Checked = False
CheckBox6.Checked = False
CheckBox7.Checked = False
CheckBox8.Checked = False
CheckBox9.Checked = False
CheckBox10.Checked = False
CheckBox11.Checked = False
CheckBox12.Checked = False
CheckBox13.Checked = False
Else
CheckBox14.Checked = False
CheckBox15.Checked = False
CheckBox16.Checked = False
CheckBox17.Checked = False
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
GetCurrentRegValues()
Dim OSVersion As String = Environment.OSVersion.ToString
If InStr(Environment.OSVersion.ToString, "5.0") > 0 Then
' Windows 2000 - 5.0, XP - 5.1, Windows 2003 - 5.2
'Set TextBox Values to Windows 2000 Settings (TCP/IP Stack)
' Hardening Values
TextBox14.Text = "0"
TextBox15.Text = "2"
TextBox16.Text = "3"
TextBox17.Text = "500"
TextBox18.Text = "400"
TextBox19.Text = "1"
TextBox20.Text = "3"
TextBox21.Text = "0"
TextBox22.Text = "0"
TextBox23.Text = "1"
TextBox24.Text = "1"
TextBox25.Text = "0"
TextBox26.Text = "300000"
TextBox35.Text = "0"
TextBox36.Text = "1"
TextBox37.Text = "NP"
TextBox38.Text = "NP"
TextBox39.Text = "NP"
TextBox40.Text = "NP"
TextBox41.Text = "NP"
TextBox42.Text = "NP"
TextBox43.Text = "NP"
TextBox44.Text = "1"
TextBox45.Text = "1"
TextBox46.Text = "0"
TextBox47.Text = "NP"
'Set TextBox Values to Windows 2000 Settings (Winsock)
TextBox31.Text = "1"
TextBox32.Text = "20"
TextBox33.Text = "20000"
TextBox34.Text = "10"
' Default Settings
TextBox48.Text = "NP"
TextBox49.Text = "NP"
TextBox50.Text = "NP"
TextBox51.Text = "NP"
ElseIf InStr(Environment.OSVersion.ToString, "5.1") > 0 Then
'Set TextBox Values to Windows XP Settings
TextBox14.Text = "0"
TextBox15.Text = "2"
TextBox16.Text = "3"
TextBox17.Text = "100"
TextBox18.Text = "80"
TextBox19.Text = "1"
TextBox20.Text = "3"
TextBox21.Text = "0"
TextBox22.Text = "0"
TextBox23.Text = "1"
TextBox24.Text = "1"
TextBox25.Text = "0"
TextBox26.Text = "300000"
TextBox35.Text = "0"
TextBox36.Text = "1"
TextBox37.Text = "NP"
TextBox38.Text = "NP"
TextBox39.Text = "NP"
TextBox40.Text = "NP"
TextBox41.Text = "NP"
TextBox42.Text = "NP"
TextBox43.Text = "NP"
TextBox44.Text = "1"
TextBox45.Text = "1"
TextBox46.Text = "0"
TextBox47.Text = "NP"
'Set TextBox Values to Windows XP Settings (Winsock)
TextBox31.Text = "1"
TextBox32.Text = "20"
TextBox33.Text = "20000"
TextBox34.Text = "10"
' Default Settings
TextBox48.Text = "NP"
TextBox49.Text = "NP"
TextBox50.Text = "NP"
TextBox51.Text = "NP"
ElseIf InStr(Environment.OSVersion.ToString, "5.2") > 0 Then
'Set TextBox Values to Windows 2003 Settings
TextBox14.Text = "0"
TextBox15.Text = "2"
TextBox16.Text = "3"
TextBox17.Text = "500"
TextBox18.Text = "400"
TextBox19.Text = "1"
TextBox20.Text = "3"
TextBox21.Text = "0"
TextBox22.Text = "0"
TextBox23.Text = "1"
TextBox24.Text = "1"
TextBox25.Text = "0"
TextBox26.Text = "300000"
TextBox35.Text = "1"
TextBox36.Text = "NP"
TextBox37.Text = "NP"
TextBox38.Text = "NP"
TextBox39.Text = "NP"
TextBox40.Text = "NP"
TextBox41.Text = "NP"
TextBox42.Text = "NP"
TextBox43.Text = "NP"
TextBox44.Text = "NP"
TextBox45.Text = "NP"
TextBox46.Text = "NP"
TextBox47.Text = "NP"
'Set TextBox Values to Windows 2003 Settings (Winsock)
TextBox31.Text = "1"
TextBox32.Text = "20"
TextBox33.Text = "20000"
TextBox34.Text = "10"
' Default Settings
TextBox48.Text = "NP"
TextBox49.Text = "NP"
TextBox50.Text = "NP"
TextBox51.Text = "NP"
End If
End Sub
Private Sub GetCurrentRegValue(ByVal KeyName As String, ByVal ValueName
As String, ByVal TextBox As TextBox)
TextBox.Text = My.Computer.Registry.GetValue(KeyName, ValueName, "NP")
End Sub
Private Sub GetCurrentRegValues()
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "EnableICMPRedirect", TextBox1)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "SynAttackProtect", TextBox2)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "TCPMaxConnectResponseRetransmissions", TextBox3)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "TcpMaxHalfOpen", TextBox4)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "TCPMaxHalfOpenRetired", TextBox5)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "TCPMaxPortsExhausted", TextBox6)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "TCPMaxDataRetransmissions", TextBox7)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "EnableDeadGwDetect", TextBox8)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "EnablePmtuDiscovery", TextBox9)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "DisableIPSourceRouting", TextBox10)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "NonameReleaseOnDemand", TextBox11)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "PerformRouterDiscovery", TextBox12)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "KeepAliveTime", TextBox13)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters", "EnableDynamicBacklog", TextBox27)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters", "MinimumDynamicBacklog", TextBox28)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters", "MaximumDynamicBacklog", TextBox29)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters", "DynamicBacklogGrowthDelta", TextBox30)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
If TabControl1.SelectedTab.Name = "TabPage1" Then
If CheckBox1.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnableICMPRedirect", TextBox14.Text, Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox2.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"SynAttackProtect", TextBox15.Text, Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox3.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"TCPMaxConnectResponseRetransmissions", TextBox16.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox4.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"TcpMaxHalfOpen", TextBox17.Text, Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox5.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"TCPMaxHalfOpenRetired", TextBox18.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox6.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"TCPMaxPortsExhausted", TextBox19.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox7.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"TCPMaxDataRetransmissions", TextBox20.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox8.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnableDeadGWDetect", TextBox21.Text, Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox9.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnablePMTUDiscovery", TextBox22.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox10.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"DisableIPSourceRouting", TextBox23.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox11.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"NoNameReleaseOnDemand", TextBox24.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox12.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"PerformRouterDiscovery", TextBox25.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox13.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"KeepAliveTime", TextBox26.Text, Microsoft.Win32.RegistryValueKind.DWord)
End If
Else
If CheckBox14.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters",
"EnableDynamicBacklog", TextBox31.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox15.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters",
"MinimumDynamicBacklog", TextBox32.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox16.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters",
"MaximumDynamicBacklog", TextBox33.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox17.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters",
"DynamicBacklogGrowthDelta", TextBox34.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
End If
GetCurrentRegValues()
If TabControl1.SelectedTab.Name = "TabPage1" Then
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = False
CheckBox4.Checked = False
CheckBox5.Checked = False
CheckBox6.Checked = False
CheckBox7.Checked = False
CheckBox8.Checked = False
CheckBox9.Checked = False
CheckBox10.Checked = False
CheckBox11.Checked = False
CheckBox12.Checked = False
CheckBox13.Checked = False
Else
CheckBox14.Checked = False
CheckBox15.Checked = False
CheckBox16.Checked = False
CheckBox17.Checked = False
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
If TabControl1.SelectedTab.Name = "TabPage1" Then
If InStr(Environment.OSVersion.ToString, "5.0") > 0 Then
If CheckBox1.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnableICMPRedirect", "1", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox2.Checked = True Then
DeleteRegValue("SynAttackProtect")
End If
If CheckBox3.Checked = True Then
DeleteRegValue("TcpMaxConnectResponseRetransmissions")
End If
If CheckBox4.Checked = True Then
DeleteRegValue("TcpMaxHalfOpen")
End If
If CheckBox5.Checked = True Then
DeleteRegValue("TcpMaxHalfOpenRetired")
End If
If CheckBox6.Checked = True Then
DeleteRegValue("TcpMaxPortsExhausted")
End If
If CheckBox7.Checked = True Then
DeleteRegValue("TcpMaxDataRetransmissions")
End If
If CheckBox8.Checked = True Then
DeleteRegValue("EnableDeadGWDetect")
End If
If CheckBox9.Checked = True Then
DeleteRegValue("EnablePMTUDiscovery")
End If
If CheckBox10.Checked = True Then
DeleteRegValue("DisableIPSourceRouting")
End If
If CheckBox11.Checked = True Then
DeleteRegValue("NoNameReleaseOnDemand")
End If
If CheckBox12.Checked = True Then
DeleteRegValue("PerformRouterDiscovery")
End If
If CheckBox13.Checked = True Then
DeleteRegValue("KeepAliveTime")
End If
ElseIf InStr(Environment.OSVersion.ToString, "5.1") > 0 Then
If CheckBox1.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnableICMPRedirect", "0", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox2.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"SynAttackProtect", "1", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox3.Checked = True Then
DeleteRegValue("TcpMaxConnectResponseRetransmissions")
End If
If CheckBox4.Checked = True Then
DeleteRegValue("TcpMaxHalfOpen")
End If
If CheckBox5.Checked = True Then
DeleteRegValue("TcpMaxHalfOpenRetired")
End If
If CheckBox6.Checked = True Then
DeleteRegValue("TcpMaxPortsExhausted")
End If
If CheckBox7.Checked = True Then
DeleteRegValue("TcpMaxDataRetransmissions")
End If
If CheckBox8.Checked = True Then
DeleteRegValue("EnableDeadGWDetect")
End If
If CheckBox9.Checked = True Then
DeleteRegValue("EnablePMTUDiscovery")
End If
If CheckBox10.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"DisableIPSourceRouting", "1", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox11.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"NoNameReleaseOnDemand", "1", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox12.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"PerformRouterDiscovery", "0", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox13.Checked = True Then
DeleteRegValue("KeepAliveTime")
End If
ElseIf InStr(Environment.OSVersion.ToString, "5.2") > 0 Then
If CheckBox1.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnableICMPRedirect", "1", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox2.Checked = True Then
DeleteRegValue("SynAttackProtect")
End If
If CheckBox3.Checked = True Then
DeleteRegValue("TcpMaxConnectResponseRetransmissions")
End If
If CheckBox4.Checked = True Then
DeleteRegValue("TcpMaxHalfOpen")
End If
If CheckBox5.Checked = True Then
DeleteRegValue("TcpMaxHalfOpenRetired")
End If
If CheckBox6.Checked = True Then
DeleteRegValue("TcpMaxPortsExhausted")
End If
If CheckBox7.Checked = True Then
DeleteRegValue("TcpMaxDataRetransmissions")
End If
If CheckBox8.Checked = True Then
DeleteRegValue("EnableDeadGWDetect")
End If
If CheckBox9.Checked = True Then
DeleteRegValue("EnablePMTUDiscovery")
End If
If CheckBox10.Checked = True Then
DeleteRegValue("DisableIPSourceRouting")
End If
If CheckBox11.Checked = True Then
DeleteRegValue("NoNameReleaseOnDemand")
End If
If CheckBox12.Checked = True Then
DeleteRegValue("PerformRouterDiscovery")
End If
If CheckBox13.Checked = True Then
DeleteRegValue("KeepAliveTime")
End If
End If
Else
If CheckBox14.Checked = True Then
DeleteRegValue("EnableDynamicBacklog")
End If
If CheckBox15.Checked = True Then
DeleteRegValue("MinimumDynamicBacklog")
End If
If CheckBox16.Checked = True Then
DeleteRegValue("MaximumDynamicBacklog")
End If
If CheckBox17.Checked = True Then
DeleteRegValue("DynamicBacklogGrowthDelta")
End If
End If
GetCurrentRegValues()
If TabControl1.SelectedTab.Name = "TabPage1" Then
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = False
CheckBox4.Checked = False
CheckBox5.Checked = False
CheckBox6.Checked = False
CheckBox7.Checked = False
CheckBox8.Checked = False
CheckBox9.Checked = False
CheckBox10.Checked = False
CheckBox11.Checked = False
CheckBox12.Checked = False
CheckBox13.Checked = False
Else
CheckBox14.Checked = False
CheckBox15.Checked = False
CheckBox16.Checked = False
CheckBox17.Checked = False
End If
End Sub
Private Sub DeleteRegValue(ByVal RegValue As String)
Dim RegKeyPath As String
If TabControl1.SelectedTab.Name = "TabPage1" Then
RegKeyPath = "System\CurrentControlSet\Services\Tcpip\Parameters"
Else
RegKeyPath = "System\CurrentControlSet\Services\AFD\Parameters"
End If
My.Computer.Registry.LocalMachine.OpenSubKey(RegKeyPath,
True).DeleteValue(RegValue, False)
End Sub
Private Sub Label7_MouseHover(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label7.MouseHover
RichTextBox1.Text = "more information..........."
End Sub
Private Sub Label8_Hover(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label8.MouseHover
Dim FilePath As String
FilePath = "c:\MyFile.rtf"
RichTextBox1.LoadFile(FilePath)
'RichTextBox1.LoadFile(FilePath, RichTextBoxStreamType.RichText)
' RichTextBox1.Text = "even more information..........."
End Sub
End Class
OK this is my very first attempt at development and whilst it does what i
want it to i know that in actual the fact the coding is awful. The first
thing you will notice is the amount of repetition of similiar code that does
the same thing.
Im hoping that someone will take the time to look at the code and offer some
advice as to how to curtail the amount of lines of code. As it is obvious to
even the naivest coder there is some way of eliminating the repetition.
Im not asking for someone to rewrite the thing, what i am after is someone
to try explain the error of my ways and show me some ways of cleaning the
code up, as im sure that there will be occasions where i will be able to
apply lessons learnt.
Thanks
Darren
Public Class Form1
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button5.Click
Application.Exit()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
If TabControl1.SelectedTab.Name = "TabPage1" Then
CheckBox1.Checked = True
CheckBox2.Checked = True
CheckBox3.Checked = True
CheckBox4.Checked = True
CheckBox5.Checked = True
CheckBox6.Checked = True
CheckBox7.Checked = True
CheckBox8.Checked = True
CheckBox9.Checked = True
CheckBox10.Checked = True
CheckBox11.Checked = True
CheckBox12.Checked = True
CheckBox13.Checked = True
Else
CheckBox14.Checked = True
CheckBox15.Checked = True
CheckBox16.Checked = True
CheckBox17.Checked = True
End If
End Sub
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
If TabControl1.SelectedTab.Name = "TabPage1" Then
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = False
CheckBox4.Checked = False
CheckBox5.Checked = False
CheckBox6.Checked = False
CheckBox7.Checked = False
CheckBox8.Checked = False
CheckBox9.Checked = False
CheckBox10.Checked = False
CheckBox11.Checked = False
CheckBox12.Checked = False
CheckBox13.Checked = False
Else
CheckBox14.Checked = False
CheckBox15.Checked = False
CheckBox16.Checked = False
CheckBox17.Checked = False
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
GetCurrentRegValues()
Dim OSVersion As String = Environment.OSVersion.ToString
If InStr(Environment.OSVersion.ToString, "5.0") > 0 Then
' Windows 2000 - 5.0, XP - 5.1, Windows 2003 - 5.2
'Set TextBox Values to Windows 2000 Settings (TCP/IP Stack)
' Hardening Values
TextBox14.Text = "0"
TextBox15.Text = "2"
TextBox16.Text = "3"
TextBox17.Text = "500"
TextBox18.Text = "400"
TextBox19.Text = "1"
TextBox20.Text = "3"
TextBox21.Text = "0"
TextBox22.Text = "0"
TextBox23.Text = "1"
TextBox24.Text = "1"
TextBox25.Text = "0"
TextBox26.Text = "300000"
TextBox35.Text = "0"
TextBox36.Text = "1"
TextBox37.Text = "NP"
TextBox38.Text = "NP"
TextBox39.Text = "NP"
TextBox40.Text = "NP"
TextBox41.Text = "NP"
TextBox42.Text = "NP"
TextBox43.Text = "NP"
TextBox44.Text = "1"
TextBox45.Text = "1"
TextBox46.Text = "0"
TextBox47.Text = "NP"
'Set TextBox Values to Windows 2000 Settings (Winsock)
TextBox31.Text = "1"
TextBox32.Text = "20"
TextBox33.Text = "20000"
TextBox34.Text = "10"
' Default Settings
TextBox48.Text = "NP"
TextBox49.Text = "NP"
TextBox50.Text = "NP"
TextBox51.Text = "NP"
ElseIf InStr(Environment.OSVersion.ToString, "5.1") > 0 Then
'Set TextBox Values to Windows XP Settings
TextBox14.Text = "0"
TextBox15.Text = "2"
TextBox16.Text = "3"
TextBox17.Text = "100"
TextBox18.Text = "80"
TextBox19.Text = "1"
TextBox20.Text = "3"
TextBox21.Text = "0"
TextBox22.Text = "0"
TextBox23.Text = "1"
TextBox24.Text = "1"
TextBox25.Text = "0"
TextBox26.Text = "300000"
TextBox35.Text = "0"
TextBox36.Text = "1"
TextBox37.Text = "NP"
TextBox38.Text = "NP"
TextBox39.Text = "NP"
TextBox40.Text = "NP"
TextBox41.Text = "NP"
TextBox42.Text = "NP"
TextBox43.Text = "NP"
TextBox44.Text = "1"
TextBox45.Text = "1"
TextBox46.Text = "0"
TextBox47.Text = "NP"
'Set TextBox Values to Windows XP Settings (Winsock)
TextBox31.Text = "1"
TextBox32.Text = "20"
TextBox33.Text = "20000"
TextBox34.Text = "10"
' Default Settings
TextBox48.Text = "NP"
TextBox49.Text = "NP"
TextBox50.Text = "NP"
TextBox51.Text = "NP"
ElseIf InStr(Environment.OSVersion.ToString, "5.2") > 0 Then
'Set TextBox Values to Windows 2003 Settings
TextBox14.Text = "0"
TextBox15.Text = "2"
TextBox16.Text = "3"
TextBox17.Text = "500"
TextBox18.Text = "400"
TextBox19.Text = "1"
TextBox20.Text = "3"
TextBox21.Text = "0"
TextBox22.Text = "0"
TextBox23.Text = "1"
TextBox24.Text = "1"
TextBox25.Text = "0"
TextBox26.Text = "300000"
TextBox35.Text = "1"
TextBox36.Text = "NP"
TextBox37.Text = "NP"
TextBox38.Text = "NP"
TextBox39.Text = "NP"
TextBox40.Text = "NP"
TextBox41.Text = "NP"
TextBox42.Text = "NP"
TextBox43.Text = "NP"
TextBox44.Text = "NP"
TextBox45.Text = "NP"
TextBox46.Text = "NP"
TextBox47.Text = "NP"
'Set TextBox Values to Windows 2003 Settings (Winsock)
TextBox31.Text = "1"
TextBox32.Text = "20"
TextBox33.Text = "20000"
TextBox34.Text = "10"
' Default Settings
TextBox48.Text = "NP"
TextBox49.Text = "NP"
TextBox50.Text = "NP"
TextBox51.Text = "NP"
End If
End Sub
Private Sub GetCurrentRegValue(ByVal KeyName As String, ByVal ValueName
As String, ByVal TextBox As TextBox)
TextBox.Text = My.Computer.Registry.GetValue(KeyName, ValueName, "NP")
End Sub
Private Sub GetCurrentRegValues()
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "EnableICMPRedirect", TextBox1)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "SynAttackProtect", TextBox2)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "TCPMaxConnectResponseRetransmissions", TextBox3)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "TcpMaxHalfOpen", TextBox4)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "TCPMaxHalfOpenRetired", TextBox5)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "TCPMaxPortsExhausted", TextBox6)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "TCPMaxDataRetransmissions", TextBox7)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "EnableDeadGwDetect", TextBox8)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "EnablePmtuDiscovery", TextBox9)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "DisableIPSourceRouting", TextBox10)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "NonameReleaseOnDemand", TextBox11)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "PerformRouterDiscovery", TextBox12)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters", "KeepAliveTime", TextBox13)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters", "EnableDynamicBacklog", TextBox27)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters", "MinimumDynamicBacklog", TextBox28)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters", "MaximumDynamicBacklog", TextBox29)
GetCurrentRegValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters", "DynamicBacklogGrowthDelta", TextBox30)
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
If TabControl1.SelectedTab.Name = "TabPage1" Then
If CheckBox1.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnableICMPRedirect", TextBox14.Text, Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox2.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"SynAttackProtect", TextBox15.Text, Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox3.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"TCPMaxConnectResponseRetransmissions", TextBox16.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox4.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"TcpMaxHalfOpen", TextBox17.Text, Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox5.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"TCPMaxHalfOpenRetired", TextBox18.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox6.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"TCPMaxPortsExhausted", TextBox19.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox7.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"TCPMaxDataRetransmissions", TextBox20.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox8.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnableDeadGWDetect", TextBox21.Text, Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox9.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnablePMTUDiscovery", TextBox22.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox10.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"DisableIPSourceRouting", TextBox23.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox11.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"NoNameReleaseOnDemand", TextBox24.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox12.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"PerformRouterDiscovery", TextBox25.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox13.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"KeepAliveTime", TextBox26.Text, Microsoft.Win32.RegistryValueKind.DWord)
End If
Else
If CheckBox14.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters",
"EnableDynamicBacklog", TextBox31.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox15.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters",
"MinimumDynamicBacklog", TextBox32.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox16.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters",
"MaximumDynamicBacklog", TextBox33.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox17.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\AFD\Parameters",
"DynamicBacklogGrowthDelta", TextBox34.Text,
Microsoft.Win32.RegistryValueKind.DWord)
End If
End If
GetCurrentRegValues()
If TabControl1.SelectedTab.Name = "TabPage1" Then
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = False
CheckBox4.Checked = False
CheckBox5.Checked = False
CheckBox6.Checked = False
CheckBox7.Checked = False
CheckBox8.Checked = False
CheckBox9.Checked = False
CheckBox10.Checked = False
CheckBox11.Checked = False
CheckBox12.Checked = False
CheckBox13.Checked = False
Else
CheckBox14.Checked = False
CheckBox15.Checked = False
CheckBox16.Checked = False
CheckBox17.Checked = False
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button3.Click
If TabControl1.SelectedTab.Name = "TabPage1" Then
If InStr(Environment.OSVersion.ToString, "5.0") > 0 Then
If CheckBox1.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnableICMPRedirect", "1", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox2.Checked = True Then
DeleteRegValue("SynAttackProtect")
End If
If CheckBox3.Checked = True Then
DeleteRegValue("TcpMaxConnectResponseRetransmissions")
End If
If CheckBox4.Checked = True Then
DeleteRegValue("TcpMaxHalfOpen")
End If
If CheckBox5.Checked = True Then
DeleteRegValue("TcpMaxHalfOpenRetired")
End If
If CheckBox6.Checked = True Then
DeleteRegValue("TcpMaxPortsExhausted")
End If
If CheckBox7.Checked = True Then
DeleteRegValue("TcpMaxDataRetransmissions")
End If
If CheckBox8.Checked = True Then
DeleteRegValue("EnableDeadGWDetect")
End If
If CheckBox9.Checked = True Then
DeleteRegValue("EnablePMTUDiscovery")
End If
If CheckBox10.Checked = True Then
DeleteRegValue("DisableIPSourceRouting")
End If
If CheckBox11.Checked = True Then
DeleteRegValue("NoNameReleaseOnDemand")
End If
If CheckBox12.Checked = True Then
DeleteRegValue("PerformRouterDiscovery")
End If
If CheckBox13.Checked = True Then
DeleteRegValue("KeepAliveTime")
End If
ElseIf InStr(Environment.OSVersion.ToString, "5.1") > 0 Then
If CheckBox1.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnableICMPRedirect", "0", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox2.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"SynAttackProtect", "1", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox3.Checked = True Then
DeleteRegValue("TcpMaxConnectResponseRetransmissions")
End If
If CheckBox4.Checked = True Then
DeleteRegValue("TcpMaxHalfOpen")
End If
If CheckBox5.Checked = True Then
DeleteRegValue("TcpMaxHalfOpenRetired")
End If
If CheckBox6.Checked = True Then
DeleteRegValue("TcpMaxPortsExhausted")
End If
If CheckBox7.Checked = True Then
DeleteRegValue("TcpMaxDataRetransmissions")
End If
If CheckBox8.Checked = True Then
DeleteRegValue("EnableDeadGWDetect")
End If
If CheckBox9.Checked = True Then
DeleteRegValue("EnablePMTUDiscovery")
End If
If CheckBox10.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"DisableIPSourceRouting", "1", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox11.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"NoNameReleaseOnDemand", "1", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox12.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"PerformRouterDiscovery", "0", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox13.Checked = True Then
DeleteRegValue("KeepAliveTime")
End If
ElseIf InStr(Environment.OSVersion.ToString, "5.2") > 0 Then
If CheckBox1.Checked = True Then
My.Computer.Registry.SetValue("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters",
"EnableICMPRedirect", "1", Microsoft.Win32.RegistryValueKind.DWord)
End If
If CheckBox2.Checked = True Then
DeleteRegValue("SynAttackProtect")
End If
If CheckBox3.Checked = True Then
DeleteRegValue("TcpMaxConnectResponseRetransmissions")
End If
If CheckBox4.Checked = True Then
DeleteRegValue("TcpMaxHalfOpen")
End If
If CheckBox5.Checked = True Then
DeleteRegValue("TcpMaxHalfOpenRetired")
End If
If CheckBox6.Checked = True Then
DeleteRegValue("TcpMaxPortsExhausted")
End If
If CheckBox7.Checked = True Then
DeleteRegValue("TcpMaxDataRetransmissions")
End If
If CheckBox8.Checked = True Then
DeleteRegValue("EnableDeadGWDetect")
End If
If CheckBox9.Checked = True Then
DeleteRegValue("EnablePMTUDiscovery")
End If
If CheckBox10.Checked = True Then
DeleteRegValue("DisableIPSourceRouting")
End If
If CheckBox11.Checked = True Then
DeleteRegValue("NoNameReleaseOnDemand")
End If
If CheckBox12.Checked = True Then
DeleteRegValue("PerformRouterDiscovery")
End If
If CheckBox13.Checked = True Then
DeleteRegValue("KeepAliveTime")
End If
End If
Else
If CheckBox14.Checked = True Then
DeleteRegValue("EnableDynamicBacklog")
End If
If CheckBox15.Checked = True Then
DeleteRegValue("MinimumDynamicBacklog")
End If
If CheckBox16.Checked = True Then
DeleteRegValue("MaximumDynamicBacklog")
End If
If CheckBox17.Checked = True Then
DeleteRegValue("DynamicBacklogGrowthDelta")
End If
End If
GetCurrentRegValues()
If TabControl1.SelectedTab.Name = "TabPage1" Then
CheckBox1.Checked = False
CheckBox2.Checked = False
CheckBox3.Checked = False
CheckBox4.Checked = False
CheckBox5.Checked = False
CheckBox6.Checked = False
CheckBox7.Checked = False
CheckBox8.Checked = False
CheckBox9.Checked = False
CheckBox10.Checked = False
CheckBox11.Checked = False
CheckBox12.Checked = False
CheckBox13.Checked = False
Else
CheckBox14.Checked = False
CheckBox15.Checked = False
CheckBox16.Checked = False
CheckBox17.Checked = False
End If
End Sub
Private Sub DeleteRegValue(ByVal RegValue As String)
Dim RegKeyPath As String
If TabControl1.SelectedTab.Name = "TabPage1" Then
RegKeyPath = "System\CurrentControlSet\Services\Tcpip\Parameters"
Else
RegKeyPath = "System\CurrentControlSet\Services\AFD\Parameters"
End If
My.Computer.Registry.LocalMachine.OpenSubKey(RegKeyPath,
True).DeleteValue(RegValue, False)
End Sub
Private Sub Label7_MouseHover(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label7.MouseHover
RichTextBox1.Text = "more information..........."
End Sub
Private Sub Label8_Hover(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Label8.MouseHover
Dim FilePath As String
FilePath = "c:\MyFile.rtf"
RichTextBox1.LoadFile(FilePath)
'RichTextBox1.LoadFile(FilePath, RichTextBoxStreamType.RichText)
' RichTextBox1.Text = "even more information..........."
End Sub
End Class