Jump to content
Sign in to follow this  
andyvl

portlistening

Recommended Posts

andyvl

Environement.

computer with lan connection and direct connection to internet

(no server or proxy)

What I need:

script that listens to an array of ports on that computer. (and logs the result)

if a port of a second array (ports 20;21;8080;...) is open or used it needs to be blocked /closed immediatly

purpose:

restrict what a user can do (no http, telnet, ftp,...)

found some examples of firewalls here, but none of them are working for me.

I still can surf the internet

Please help

Share this post


Link to post
Share on other sites
andyvl

I used bellow example to start from

Dim $IP = @IPAddress1
Dim $nPORT = 8080

TCPStartup()
$MainSocket = TCPListen($IP2, $nPORT)
; write mainsocket is
If $MainSocket == -1 Then
    MsgBox( 0, "TCP Error", "Error Listening on TCP" & @CRLF & "@error = " & @error )
    Exit
EndIf
;write startwhileloop
While 1
    $Socket = TCPAccept($MainSocket)
  ;write socket:
    If $Socket >= 0 Then
        $recv = ''
        While $recv = ''
            $recv = TCPRecv($Socket, 10000)
        WEnd
       ;Do something here based on the request
        ConsoleWrite($recv)
    EndIf
WEnd

the ;write are the places I write debug stuff to the logs

bellow is the log I receive

26/08-2007 18:09:16 tcpstartup:

26/08-2007 18:09:16 $mainsocket is: 264

26/08-2007 18:09:17 startwhileloop

26/08-2007 18:09:17 $socket: -1

26/08-2007 18:09:17 $socket: -1

26/08-2007 18:09:17 $socket: -1

....

(the socket -1 keeps going on)

First of all, what does the value -1 mean. I know this is a failure. But in practical terms.

That my port don't answer?

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.