10.08.2012, 08:02
Gute Morgen, ich habe seit 3 Tagen massive probleme mit men Win Vserver. Darauf läuft Teamspeak³ server und Garrysmod server. Das probleme daran besteht das ein ehmaliger member mein vserver ddos't , nach dem ich ihn raus geworfen habe. Nun ist frage wie ich ihn raus werfe. Habe schon Nach DDos protect gesucht habe nix vernüpftiges gefunden. Habe code gefunden:
Code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiIPAddress.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <file.au3>
#include <Math.au3>
#include <GuiListView.au3>
#include <Constants.au3>
#include <Timers.au3>
#include <INET.au3>
Global $max = "", $cheksum = "", $incon = ""
Global $fileset = "Log\Settings.ls", $Titel = "Lucidsoft - DDoS Protection © by Lucidsoft"
Global $sPatternIP = "(?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(?=\.?\d)\.)){4}"
Global $sPatternIP2 = "(?:(?:25[0-5]|2[0-4]\d|[01]\d\d|\d?\d)(?(?=\.?\d)\.)){4}"
Global $checkPattern = "(?:" & _GetIP() & ":80\s*)(" & $sPatternIP2 & ")"
Global $nonblockip = _GetIP()
$Form1 = GUICreate("Lucidsoft - DDoS Protection © by Lucidsoft | Coded by Michael", 609, 281, 195, 122)
GUICtrlCreateGroup("Incoming Connection", 8, 0, 241, 241)
$ListView1 = GUICtrlCreateListView("ID|Con", 16, 16, 226, 214)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 40)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("Blocked Connection", 256, 0, 201, 241)
$ListView2 = GUICtrlCreateListView("ID", 264, 16, 186, 214)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 150)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Main Setting´s", 464, 0, 137, 169)
GUICtrlCreateLabel("Check Interval in msec:", 472, 16, 115, 17)
$Input1 = GUICtrlCreateInput("", 472, 40, 113, 21)
GUICtrlCreateLabel("Max Connection:", 472, 64, 84, 17)
$Input2 = GUICtrlCreateInput("", 472, 88, 113, 21)
$Button1 = GUICtrlCreateButton("Save", 472, 136, 123, 25)
GUICtrlCreateLabel("Port:", 480, 112, 28, 17)
$Input3 = GUICtrlCreateInput("", 520, 112, 49, 21)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("Manual Block", 464, 168, 137, 97)
$Button2 = GUICtrlCreateButton("Block", 472, 224, 59, 25)
$Button3 = GUICtrlCreateButton("Deblock", 536, 224, 59, 25)
$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 472, 192, 122, 21)
_GUICtrlIpAddress_Set($IPAddress1, "0.0.0.0")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button4 = GUICtrlCreateButton("Start", 8, 248, 139, 25)
$Button5 = GUICtrlCreateButton("Stop", 152, 248, 139, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
$Button6 = GUICtrlCreateButton("Login", 296, 248, 163, 25)
GUICtrlSetState(-1, $GUI_DISABLE)
GUISetState(@SW_SHOW)
_checkBlockIP2()
_startsettings()
GUIRegisterMsg($WM_TIMER, "WM_TIMER")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $Button1
_savesettings()
$max = GUICtrlRead($Input2)
Case $Button2
_ReloadListBlock()
Case $Button3
_deletblock(_GUICtrlIpAddress_Get($IPAddress1))
_ReloadListBlock()
Case $Button4
GUICtrlSetState($Button4, $GUI_DISABLE)
GUICtrlSetState($Button5, $GUI_ENABLE)
$max = IniRead("Log\Settings.ls", "HP", "Con", "")
$iTimer1 = _Timer_SetTimer($Form1, GUICtrlRead($Input1))
Case $Button5
GUICtrlSetState($Button5, $GUI_DISABLE)
GUICtrlSetState($Button4, $GUI_ENABLE)
_Timer_KillTimer($Form1, $iTimer1)
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func _savesettings()
IniWrite($fileset, "HP", "Con", GUICtrlRead($Input3))
IniWrite($fileset, "HP", "Port", GUICtrlRead($Input2))
IniWrite($fileset, "Check", "Time", GUICtrlRead($Input1))
EndFunc ;==>_savesettings
Func WM_TIMER($hWnd, $iMsg, $iwParam)
Switch _Timer_GetTimerID($iwParam)
Case $iTimer1
$starttime = _Timer_Init()
_check()
ConsoleWrite(_Timer_Diff($starttime) & @CRLF)
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_TIMER
Func _deletblock($ip)
$CMD = Run(@ComSpec & " /c netsh ipsec static delete filter filterlist=DDoS-Protect srcaddr=" & $ip & " dstaddr=Me", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
_checkBlockIP2()
EndFunc ;==>_deletblock
Func _checkBlockIP2()
$read = _CMDRead("netsh ipsec static show all")
$aRecords = StringRegExp($read, $sPatternIP, 3)
$Blockip = ""
For $x = 0 To UBound($aRecords) - 1
$Blockip &= $aRecords[$x] & @CRLF
GUICtrlCreateListViewItem($aRecords[$x], $ListView2)
$x = $x + 1
Next
FileDelete("Log/CBlock.ini")
FileWrite("Log/CBlock.ini", $Blockip)
EndFunc ;==>_checkBlockIP2
Func _startsettings()
DirCreate("Log")
If FileExists("Log\Settings.ls") Then
$create = IniRead("Log\Settings.ls", "Create", "Policy", "")
GUICtrlSetData($Input1, IniRead("Log\Settings.ls", "Check", "Time", ""))
GUICtrlSetData($Input2, IniRead("Log\Settings.ls", "HP", "Con", ""))
GUICtrlSetData($Input3, IniRead("Log\Settings.ls", "HP", "Port", ""))
$max = IniRead("Log\Settings.ls", "HP", "Con", "")
EndIf
If FileExists("Log\CBlock.ini") Then
_Listblock()
EndIf
If $create = 0 Then
_createIPsec()
EndIf
EndFunc ;==>_startsettings
Func _createIPsec()
Run(@ComSpec & " /c netsh ipsec static add filterlist name=DDoS-Protect", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Sleep(1000)
Run(@ComSpec & " /c netsh ipsec static add filteraction name=BlockIP action=block", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Sleep(1000)
Run(@ComSpec & " /c netsh ipsec static add filter filterlist=DDoS-Protect srcaddr=192.168.192.100 dstaddr=Me", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Sleep(1000)
Run(@ComSpec & " /c netsh ipsec static add policy name=DDoS-Protec-Policy assign=yes", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Sleep(1000)
Run(@ComSpec & " /c netsh ipsec static add rule name=DDoSProtectRule policy=DDoS-Protec-Policy filterlist=DDoS-Protect filteraction=BlockIP", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Sleep(100)
Run(@ComSpec & " /c netsh ipsec static delete filter filterlist=DDoS-Protect srcaddr=192.168.192.100 dstaddr=Me", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
Sleep(1000)
IniWrite("Log\Settings.ls", "Create", "Policy", "1")
EndFunc ;==>_createIPsec
Func _Listblock()
If FileExists("Log\CBlock.ini") Then
_GUICtrlListView_DeleteAllItems($ListView2)
Dim $aRecords
If Not _FileReadToArray("Log\CBlock.ini", $aRecords) Then
Else
If _FileCountLines("Log\CBlock.ini") > 0 Then
For $x = 1 To $aRecords[0]
GUICtrlCreateListViewItem($aRecords[$x], $ListView2)
Next
EndIf
EndIf
EndIf
EndFunc ;==>_Listblock
Func _ReloadListBlock()
_Listblock()
EndFunc ;==>_ReloadListBlock
Func _LoadConList($ip, $count)
$incon = ""
$check = _GUICtrlListView_FindInText($ListView1, $ip)
If $check = "-1" Then
If Int($count) >= Int($max) Then
_checkBlockIP($ip)
Else
GUICtrlCreateListViewItem($ip & "|" & $count, $ListView1)
$incon &= $ip & "|"
EndIf
Else
$incon &= $ip & "|"
$itemtext = _GUICtrlListView_GetItemTextString($ListView1, $check)
$str = StringSplit($itemtext, "|")
If $str[2] <> $count Then
If Int($count) >= Int($max) Then
_checkBlockIP($ip)
Else
_GUICtrlListView_SetItemText($ListView1, $check, $count, 2)
EndIf
EndIf
EndIf
EndFunc ;==>_LoadConList
Func _check()
$msg = ""
$port = IniRead("Log/Settings.ls", "Port", "Port", "")
$read = _CMDRead("netstat -n")
$aRecords = StringRegExp($read, $checkPattern, 3)
$check = ""
For $x = 1 To UBound($aRecords) - 1
$check &= $aRecords[$x] & @CRLF
Next
$aFile = StringSplit($check, @CRLF, 1)
Global $aCounts[$aFile[0] + 1] ;eine temporäre array für die zählung erstellen
Global $iCount = 0
For $x = 1 To $aFile[0]
If $aFile[$x] = "" Then ContinueLoop
$aCounts[$x] = 1
$iCount += 1
For $i = $x + 1 To $aFile[0]
If $aFile[$x] = $aFile[$i] Then
$aCounts[$x] += 1
$aFile[$i] = ""
EndIf
Next
Next
For $x = 1 To $aFile[0]
If $aFile[$x] = "" Then ContinueLoop
_LoadConList($aFile[$x], $aCounts[$x])
Next
$items = _GUICtrlListView_GetItemCount($ListView1)
For $y = 0 To $items
$search = _GUICtrlListView_GetItemText($ListView1, $y)
$string = StringInStr($incon, $search)
If $string = 0 Then
_GUICtrlListView_DeleteItem($ListView1, $y)
EndIf
Next
EndFunc ;==>_check
Func _checkBlockIP($ip)
$str = StringInStr(FileRead("Log\CBlock.ini"), $ip)
If $str = 0 Then
_Add($ip)
EndIf
EndFunc ;==>_checkBlockIP
Func _CMDRead($command)
Local $line
$CMD = Run(@ComSpec & " /c " & $command, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
While 1
$line &= StdoutRead($CMD)
If @error Then ExitLoop
WEnd
Return $line
ProcessClose($CMD)
EndFunc ;==>_CMDRead
Func _Add($ip)
$command2 = "netsh ipsec static add filter filterlist=DDoS-Protect srcaddr=" & $ip & " dstaddr=Me"
FileWrite("Log\CBlock.ini", $ip & @CRLF)
GUICtrlCreateListViewItem($ip, $ListView2)
$CMD = Run(@ComSpec & " /c " & $command2, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
EndFunc ;==>_Add
Func _ReduceMem()
Local $ai_Return = DllCall("psapi.dll", 'int', 'EmptyWorkingSet', 'long', -1)
Return SetError(@error, @extended, $ai_Return[0])
EndFunc ;==>_ReduceMem
Doch wenn ich starte stürtz das Programm ab 

ansonsten muss man auf Unterstützung seines Hosters hoffen oder für ein paar viele Euronen mehr zu einem Hoster umziehen, der so eine Technik anbietet - die jedoch nicht ganz günstig ist.