Jump to content

Recommended Posts

Posted

Hi,

I'm french and my english is not good (very bad) but i'll try to explain my problem in shakespeare's language :

I try to build a script that can warn user that there is a new request on a TCP port. Example : i use vnc on my computer and it's listening on port 5900, but there is no connexion... if one request is incoming i would like to be warn by a script, how can i do it ? it's like a small firewall.

Don't laugh against my english, i'm learning and french people are not known to be open to the other language... lol

AkorxMail akorx@yahoo.fr

Posted

Show what code you have tried and you might get more help. If you are unsure where to start, maybe the operating system command named Netstat with the "-a" option will give you some ideas. Look at AutoIt's STDIO and array functions.

Netstat -a

STDIO to an array

Netstat -a

STDIO to a second array

compare arrays looking for a new port

You can search the forums for how others have coded Netstat and STDIO. Here is but one example:

http://www.autoitscript.com/forum/index.ph...st&p=487731

have fun and enjoy AutoIt :-)

[size="1"][font="Arial"].[u].[/u][/font][/size]

Posted

This is my script but i don't see how i can threat the cases where i'm using the port 5900 to reach another computer (in this case i don't want to be warn) and there is a computer that is trying to connect to mine (i want to be warn):

exemple :

-> netstat -an return : TCP myip:1234 205.211.115.27:5900 ESTABLISHED (i'm reaching another computer on port 5900 so i don't want to be warn)

-> netstat -an return : TCP myip:5900 205.211.115.28:2125 ESTABLISHED (this is a real connection to my computer on port 5900 and i want to be warn)

Do you have an idea ?

#include <Array.au3>

Opt("ExpandEnvStrings", 1)

;while 1

RunWait(@ComSpec & " /C " & "netstat -an |find ""5900"" > %SystemDrive%\netstat1.tmp")

$file = FileReadLine ("%SystemDrive%\netstat1.tmp")

;MsgBox (0,"",@Tempdir)

$part = StringSplit ($file," ")

;_ArrayDisplay ($part,"tab")

_ArraySort( $part)

;_ArrayDisplay ($part, "sort")

$iString = 1

While $iString <> 0

$iString = _ArrayBinarySearch ( $part, "" )

If Not @error Then

_ArrayDelete ( $part, $iString)

Else

$istring =0

EndIf

Wend

_ArrayDisplay ($part,"Tab filtré")

$result = _ArraySearch($part,"ESTABLISHED")

if $result<> -1 Then

MsgBox(0,"","Connexion entrante")

EndIf

;MsgBox (0,"",$result)

;WEnd

AkorxMail akorx@yahoo.fr

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...