Hallo ich will ein script schreiben was die tcp connections von den port 80 überwacht spricht auflistet und die ips zahlt wen eine ip adresse mehrmals da ist.
das klabt ja alles so weit, blos wen ich das script länger laufen lasse hängt es sich einfach auf. würde mich freuen wen ihr wisst warum hier das script:
#include <Constants.au3>
#Include <Array.au3>
While 1
_Check(_GetConnectionFromPort())
Sleep(2000)
WEnd
Func _GetConnectionFromPort($sPort = '80')
Local $sErgebnis, $aPort
Local $pid = Run(@ComSpec & " /c " & 'netstat -np TCP |findstr ":'&$sPort&'"', "", @SW_HIDE, $STDOUT_CHILD)
Do
$sErgebnis &= StdoutRead($pid)
Until @error
$aPort = StringSplit($sErgebnis, @CRLF, 3)
For $i = UBound($aPort) - 1 To 0 Step -1
If StringInStr($aPort[$i], 'HERGESTELLT') Then
$aPort[$i] = StringRegExpReplace($aPort[$i], '(\s+)(\S+)(\s+)(\S+)(\s+)(\S+):(\S+)(\s+)(\S+)', '$6')
ElseIf StringInStr($aPort[$i], 'WARTEND') Then
$aPort[$i] = StringRegExpReplace($aPort[$i], '(\s+)(\S+)(\s+)(\S+)(\s+)(\S+):(\S+)(\s+)(\S+)', '$6')
Else
_ArrayDelete($aPort, $i)
EndIf
Next
If Not IsArray($aPort) Then Return SetError(1, 0, "")
$check = ""
For $x = 1 to UBound($aPort)-1
$check &= $aPort[$x]&@CRLF
Next
$aFile = StringSplit($check, @CRLF,1)
Global $aCounts[$aFile[0] + 1]
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
Global $aOutput[$iCount + 1][2]
$aOutput[0][0] = 1
For $x = 1 To $aFile[0]
If $aFile[$x] = "" Then ContinueLoop
$aOutput[$aOutput[0][0]][0] = $aFile[$x]
$aOutput[$aOutput[0][0]][1] = $aCounts[$x]
$aOutput[0][0] += 1
Next
Return $aOutput
EndFunc
Func _Check($ipbyarray,$mac = "50")
For $x = 0 to UBound($ipbyarray)-1
If $ipbyarray[$x][1] >= "50" Then
_checkBlockIP($ipbyarray[$x][0])
ConsoleWrite("BLOCKED "&$ipbyarray[$x][0]&@CRLF)
EndIf
Next
EndFunc
Func _Add($ip)
$command2 = "netsh ipsec static add filter filterlist=DDoS-Protect srcaddr=" & $ip & " dstaddr=Me"
$CMD = Run(@ComSpec & " /c " & $command2, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
FileWrite("Log\Block.ini",$ip&@CRLF)
; netsh ipsec static add filter filterlist=DDoS-Protect srcaddr=85.181.236.179 dstaddr=Me"
EndFunc ;==>_Add
Func _checkBlockIP($ip)
$str = StringInStr(FileRead("Log\Block.ini"),$ip)
If $str = "0" Then
_Add($ip)
EndIf
EndFunc ;==>_checkBlockIP